From 38a0bc63879ac159449f97ae79f8f20860569aee Mon Sep 17 00:00:00 2001 From: Konrad Witaszczyk Date: Mon, 19 Feb 2024 06:06:36 +0000 Subject: [PATCH] Pass compiler/linker flags to CMake for -native-hybrid (#386) morello-llvm-native on CheriBSD/Morello requires -mabi=aapcs in CFLAGS. Otherwise, it would be compiled with -mabi=purecap that cc uses by default on CheriBSD with purecap world. --- pycheribuild/config/target_info.py | 3 +++ pycheribuild/projects/cmake_project.py | 2 +- pycheribuild/projects/simple_project.py | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pycheribuild/config/target_info.py b/pycheribuild/config/target_info.py index 0ec68003d..d93a8d7c5 100644 --- a/pycheribuild/config/target_info.py +++ b/pycheribuild/config/target_info.py @@ -869,6 +869,9 @@ def is_native(self) -> bool: assert self.target_info_cls is not None return self.target_info_cls.is_native() + def is_native_hybrid(self) -> bool: + return self.is_native() and self._is_cheri_hybrid + def _check_arch(self, arch: CPUArchitecture, include_purecap: "Optional[bool]") -> bool: if self.cpu_architecture is not arch: return False diff --git a/pycheribuild/projects/cmake_project.py b/pycheribuild/projects/cmake_project.py index 10c8fbaf0..876971017 100644 --- a/pycheribuild/projects/cmake_project.py +++ b/pycheribuild/projects/cmake_project.py @@ -198,7 +198,7 @@ def setup_late(self): CMAKE_CXX_COMPILER=self.CXX, CMAKE_ASM_COMPILER=self.CC, # Compile assembly files with the default compiler ) - if not self.compiling_for_host(): + if not self.compiling_for_host() or self.compiling_for_host_hybrid(): # Add compiler/linker flags (for cross-compilation these are defined in the toolchain file). # Note: All of these should be commandlines not CMake lists. self.add_cmake_options( diff --git a/pycheribuild/projects/simple_project.py b/pycheribuild/projects/simple_project.py index 4c7fa7b99..883afc07d 100644 --- a/pycheribuild/projects/simple_project.py +++ b/pycheribuild/projects/simple_project.py @@ -664,6 +664,9 @@ def compiling_for_cheri_hybrid(self, valid_cpu_archs: "Optional[list[CPUArchitec def compiling_for_host(self) -> bool: return self.crosscompile_target.is_native() + def compiling_for_host_hybrid(self) -> bool: + return self.crosscompile_target.is_native_hybrid() + def compiling_for_riscv(self, include_purecap: bool) -> bool: return self.crosscompile_target.is_riscv(include_purecap=include_purecap)