From e73c43c5501afe3c26b7ef42db1c2afa70f25af2 Mon Sep 17 00:00:00 2001 From: Irina Dudina Date: Wed, 15 May 2024 11:47:39 +0100 Subject: [PATCH] [CHERI CSA] Enable CSA for BuildCheriBSD project --- pycheribuild/projects/cross/cheribsd.py | 17 +++++++++++++++-- tests/test_argument_parsing.py | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pycheribuild/projects/cross/cheribsd.py b/pycheribuild/projects/cross/cheribsd.py index 58c7397ba..81b6bb69a 100644 --- a/pycheribuild/projects/cross/cheribsd.py +++ b/pycheribuild/projects/cross/cheribsd.py @@ -1005,8 +1005,8 @@ def _setup_cross_toolchain_config(self) -> None: if not xccinfo.is_clang: self.ask_for_confirmation("Cross compiler is not clang, are you sure you want to continue?") self.cross_toolchain_config.set_env( - XCC=self.CC, - XCXX=self.CXX, + XCC=self.cc_wrapper, + XCXX=self.cxx_wrapper, XCPP=self.CPP, X_COMPILER_TYPE=xccinfo.compiler, # This is needed otherwise the build assumes it should build with $CC ) @@ -1196,9 +1196,14 @@ def _buildkernel( # Don't build a compiler if we are using and external toolchain (only build config, etc) if not self.use_bootstrapped_toolchain: kernel_toolchain_opts.set_with_options(LLD_BOOTSTRAP=False, CLANG=False, CLANG_BOOTSTRAP=False) + kernel_toolchain_opts.exclude_from_csa = True self.run_make("kernel-toolchain", options=kernel_toolchain_opts) self.kernel_toolchain_exists = True self.info("Building kernels for configs:", " ".join(kernconfs)) + + if self.use_csa: + kernel_make_args.set(BUILD_WITH_STRICT_TMPPATH=False) # Look for perl in PATH + self.run_make( "buildkernel", options=kernel_make_args, @@ -1523,6 +1528,10 @@ def add_cross_build_options(self) -> None: # links from /usr/bin/mail to /usr/bin/Mail won't work on case-insensitve fs self.make_args.set_with_options(MAIL=False) + if self.use_csa: + ccinfo = self.get_compiler_info(self.host_CC) + self.make_args.set_env(COMPILER_TYPE=ccinfo.compiler) + def libcompat_name(self) -> str: if self.crosscompile_target.is_cheri_purecap(): return "lib64" @@ -1917,6 +1926,10 @@ def setup_config_options(cls, kernel_only_target=False, install_directory_help=N "build the libraries and skip all binaries", ) + @classmethod + def can_build_with_csa(cls) -> bool: + return True + def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) self.extra_kernels_with_mfs: "list[str]" = [] diff --git a/tests/test_argument_parsing.py b/tests/test_argument_parsing.py index ea269292d..1c66a16e2 100644 --- a/tests/test_argument_parsing.py +++ b/tests/test_argument_parsing.py @@ -1280,6 +1280,7 @@ def test_mfs_root_kernel_config_options(): "mfs_root_image", "skip_update", "use_ccache", + "use_csa", "use_lto", "with_clean", "with_debug_files",