diff --git a/pycheribuild/projects/cross/libcxx.py b/pycheribuild/projects/cross/libcxx.py index 935197eb3..1515d4a80 100644 --- a/pycheribuild/projects/cross/libcxx.py +++ b/pycheribuild/projects/cross/libcxx.py @@ -401,6 +401,11 @@ def setup(self): if external_cxxabi is not None: self.add_cmake_options(LIBCXX_CXX_ABI=external_cxxabi) + if not self.compiling_for_host(): + self.add_cmake_options( + LIBCXX_CXX_ABI_INCLUDE_PATHS=self.sdk_sysroot / "usr/include/c++/v1/", + LIBCXX_CXX_ABI_LIBRARY_PATH=self.sdk_sysroot / "usr" / self.target_info.default_libdir, + ) # LIBCXX_ENABLE_ABI_LINKER_SCRIPT is needed if we use libcxxrt/system libc++abi in the tests self.add_cmake_options(LIBCXX_ENABLE_STATIC_ABI_LIBRARY=False, LIBCXX_ENABLE_ABI_LINKER_SCRIPT=True) else: @@ -428,15 +433,28 @@ def setup(self): self.add_cmake_options(UNIX=1) self.COMMON_FLAGS.append("-D_GNU_SOURCE=1") # strtoll_l is guarded by __GNU_VISIBLE - if self.test_localhost_via_ssh: + test_executor = None + if not self.compiling_for_host(): + if self._have_compile_only_executor(): + # The compile_only executor does not exist for upstream (yet) + test_executor = self.commandline_to_str([self.source_dir / "../libcxx/utils/compile_only.py"]) + elif self.test_localhost_via_ssh: ssh_host = self.config.get_user_name() + "@" + platform.node() - self.add_cmake_options(LIBCXX_EXECUTOR=self.commandline_to_str( - [self.source_dir / "../libcxx/utils/ssh.py", "--host", ssh_host])) - + test_executor = self.commandline_to_str([self.source_dir / "../libcxx/utils/ssh.py", "--host", ssh_host]) + if test_executor: + self.set_cmake_flag_for_each_runtime(EXECUTOR=test_executor) # The cheribuild default RPATH settings break the linker script (but should also be unnecessary without it). self.add_cmake_options(CMAKE_INSTALL_RPATH_USE_LINK_PATH=False, CMAKE_BUILD_RPATH_USE_ORIGIN=False, CMAKE_INSTALL_RPATH="", _replace=True) + def _have_compile_only_executor(self): + # The compile_only executor does not exist upstream (yet). + return self.llvm_project is BuildCheriLLVM + + def set_cmake_flag_for_each_runtime(self, **kwargs): + flags = {f"{x.upper()}_{k}": v for x in self.get_enabled_runtimes() for k, v in kwargs.items()} + self.add_cmake_options(**flags) + @classmethod def setup_config_options(cls, **kwargs): super().setup_config_options(**kwargs) @@ -445,18 +463,38 @@ def setup_config_options(cls, **kwargs): "it works correctly)") def run_tests(self): - if self.compiling_for_host() or self.target_info.is_baremetal(): - # Without setting LC_ALL lit attempts to encode some things as ASCII and fails. - # This only happens on FreeBSD, but we might as well set it everywhere + # Without setting LC_ALL lit attempts to encode some things as ASCII and fails. + # This only happens on FreeBSD, but we might as well set it everywhere + if self.compiling_for_host() or self._have_compile_only_executor(): with self.set_env(LC_ALL="en_US.UTF-8", FILECHECK_DUMP_INPUT_ON_FAILURE=1): self.run_cmd("cmake", "--build", self.build_dir, "--target", "check-runtimes") - return - elif self.can_run_binaries_on_remote_morello_board(): - executor = [self.source_dir / "utils/ssh.py", "--host", self.config.remote_morello_board] - # The Morello board has 4 CPUs, so run 4 tests in parallel. - self.run_cmd([sys.executable, self.build_dir / "bin/llvm-lit", "-j4", "-vv", - f"--xunit-xml-output={self.build_dir / 'test-results.xml'}", - "-Dexecutor=" + self.commandline_to_str(executor), "test"], cwd=self.build_dir) + + if self.target_info.is_cheribsd() and not self.compiling_for_host(): + if self.can_run_binaries_on_remote_morello_board(): + executor = [self.source_dir / "utils/ssh.py", "--host", self.config.remote_morello_board] + # The Morello board has 4 CPUs, so run 4 tests in parallel. + self.run_cmd( + [ + sys.executable, + self.build_dir / "bin/llvm-lit", + "-j4", + "-vv", + f"--xunit-xml-output={self.build_dir / 'test-results.xml'}", + "-Dexecutor=" + self.commandline_to_str(executor), + "--param", + "executor=" + self.commandline_to_str(executor), + *[f"runtimes/{d}" for d in self.get_enabled_runtimes()], + ], + cwd=self.build_dir, + ) + if "libunwind" in self.get_enabled_runtimes(): + self.target_info.run_cheribsd_test_script( + "run_libunwind_tests.py", + "--lit-debug-output", + "--ssh-executor-script", + self.source_dir / "../libcxx/utils/ssh.py", + mount_sysroot=True, + ) class BuildLlvmLibs(_BuildLlvmRuntimes): @@ -476,18 +514,6 @@ class BuildLibunwind(_BuildLlvmRuntimes): default_build_type = BuildType.DEBUG _enabled_runtimes: "typing.ClassVar[tuple[str, ...]]" = ("libunwind",) - def run_tests(self) -> None: - if self.target_info.is_cheribsd() and not self.compiling_for_host(): - self.target_info.run_cheribsd_test_script( - "run_libunwind_tests.py", - "--lit-debug-output", - "--ssh-executor-script", - self.source_dir / "../libcxx/utils/ssh.py", - mount_sysroot=True, - ) - else: - super().run_tests() - class BuildUpstreamLlvmLibs(_BuildLlvmRuntimes): target = "upstream-llvm-libs"