From aa9abc6a92a46c84268084930fc61ee46232ed78 Mon Sep 17 00:00:00 2001 From: Konrad Witaszczyk Date: Wed, 24 Jan 2024 12:51:54 +0000 Subject: [PATCH] Pass compiler/linker flags to CMake for -native-hybrid 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 6e0e8510b..7ae1bf29a 100644 --- a/pycheribuild/config/target_info.py +++ b/pycheribuild/config/target_info.py @@ -860,6 +860,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 37d8cd78b..552a63abe 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 328eb90a7..d679b440f 100644 --- a/pycheribuild/projects/simple_project.py +++ b/pycheribuild/projects/simple_project.py @@ -658,6 +658,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)