-
Notifications
You must be signed in to change notification settings - Fork 59
Targets for the portable stand-alone variant of the CheriBSD test suite #479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
577ade6
09bc465
a1d99b7
11fb945
43eb7d4
e2ab89e
6ba5dc1
89a2454
bbca37f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| # | ||
| # Copyright (c) 2025-2026 Paul Metzger | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions | ||
| # are met: | ||
| # 1. Redistributions of source code must retain the above copyright | ||
| # notice, this list of conditions and the following disclaimer. | ||
| # 2. Redistributions in binary form must reproduce the above copyright | ||
| # notice, this list of conditions and the following disclaimer in the | ||
| # documentation and/or other materials provided with the distribution. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| # SUCH DAMAGE. | ||
| # | ||
|
|
||
| import os | ||
| import typing | ||
|
|
||
| from .crosscompileproject import CrossCompileMakefileProject, DefaultInstallDir, GitRepository, MakeCommandKind | ||
| from ...config.compilation_targets import CompilationTargets, LinuxTargetInfoBase | ||
| from ...utils import classproperty | ||
|
|
||
|
|
||
| class BuildPortableOSTests(CrossCompileMakefileProject): | ||
| _always_add_suffixed_targets = True | ||
| _needs_sysroot = True | ||
| _supported_architectures = ( | ||
| CompilationTargets.CHERI_LINUX_RISCV64_PURECAP_093, | ||
| CompilationTargets.CHERI_LINUX_MORELLO_PURECAP, | ||
| CompilationTargets.MORELLO_LINUX_MORELLO_PURECAP, | ||
| ) | ||
| _default_architecture = CompilationTargets.CHERI_LINUX_RISCV64_PURECAP_093 | ||
| target = "cheri-portable-os-tests" | ||
| build_in_source_dir = False | ||
| make_kind = MakeCommandKind.BsdMake | ||
| repository = GitRepository("https://github.com/CTSRD-CHERI/portable-cheribsd-test-suite.git") | ||
|
|
||
| @classproperty | ||
| def default_install_dir(self): | ||
| return DefaultInstallDir.ROOTFS_LOCALBASE | ||
|
|
||
| @classmethod | ||
| def dependencies(cls, config) -> "tuple[str, ...]": | ||
| ti = typing.cast(typing.Type[LinuxTargetInfoBase], cls.get_crosscompile_target().target_info_cls) | ||
| return ti.musl_target, "libxo", "libbsd" | ||
|
|
||
| def setup(self) -> None: | ||
| # Don't depend on libgcc_s | ||
| self.COMMON_LDFLAGS.append("--unwindlib=none") | ||
|
|
||
| if self.get_crosscompile_target().is_aarch64(include_purecap=True): | ||
| self.set_env_make_args(machine_cpuarch="aarch64c", machine_abi="purecap", machine_arch="aarch64c") | ||
| elif self.get_crosscompile_target().is_experimental_cheri093_std(self.config): | ||
| self.set_env_make_args( | ||
| machine_cpuarch="rv64imafdc_zcherihybrid_zcherilevels", | ||
| machine_abi="purecap", | ||
| machine_arch="rv64imafdc_zcherihybrid_zcherilevels", | ||
| ) | ||
| else: | ||
| target = self.target_info.target | ||
| raise NotImplementedError(f"Unsupported architecture: {target.cpu_architecture} {target._cheri_isa}") | ||
|
|
||
| return super().setup() | ||
|
|
||
| def compile(self, **kwargs): | ||
| # The binaries will be put into /opt/cheri-api-tests | ||
| # This ensures Pyrefly that destdir won't be None | ||
| assert self.destdir is not None | ||
| self.destdir = self.destdir / "rootfs" / "opt" / "cheri-portable-os-tests" | ||
| self.makedirs(self.destdir) | ||
|
|
||
| self.make_args.set_env( | ||
| # Put the binary into root's home directory | ||
| DESTDIR=str(self.destdir), | ||
| BINOWN=os.getuid(), | ||
| BINGRP=os.getgid(), | ||
| BINMODE=755, | ||
| # Suppress a warning related to absent exception handlers. | ||
| LD_FATAL_WARNINGS="no", | ||
| # This is not supported by Morello LLVM, | ||
| MAKESYSPATH=str(self.source_dir / "mk"), | ||
| MAKEOBJDIRPREFIX=str(self.build_dir), | ||
| # This property was added to _ClangBasedTargetInfo to support this specific use case. | ||
| OBJCOPY=self.target_info.objcopy, | ||
| **self.env_make_args, | ||
| ) | ||
|
|
||
| self.run_make(cwd=self.source_dir / "cheribsdtest") | ||
|
|
||
| def set_env_make_args(self, machine_cpuarch: str, machine_abi: str, machine_arch: str): | ||
| self.env_make_args = { | ||
| "MACHINE_CPUARCH": machine_cpuarch, | ||
| "MACHINE_ABI": machine_abi, | ||
| "MACHINE_ARCH": machine_arch, | ||
| } | ||
|
|
||
| def install(self, **kwargs): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that needed? if it's just
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This tells cheribuild that the makefile is not in the root directory of the repository but in |
||
| self.run_make_install(cwd=self.source_dir / "cheribsdtest") | ||
|
|
||
| def process(self): | ||
| self.check_required_system_tool("bmake", homebrew="bmake", cheribuild_target="bmake") | ||
| super().process() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # | ||
| # Copyright (c) 2025-2026 Paul Metzger | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions | ||
| # are met: | ||
| # 1. Redistributions of source code must retain the above copyright | ||
| # notice, this list of conditions and the following disclaimer. | ||
| # 2. Redistributions in binary form must reproduce the above copyright | ||
| # notice, this list of conditions and the following disclaimer in the | ||
| # documentation and/or other materials provided with the distribution. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| # SUCH DAMAGE. | ||
| # | ||
|
|
||
| import typing | ||
|
|
||
| from .crosscompileproject import CrossCompileAutotoolsProject, DefaultInstallDir, GitRepository, MakeCommandKind | ||
| from ...config.compilation_targets import CompilationTargets, LinuxTargetInfoBase | ||
| from ...utils import classproperty | ||
|
|
||
|
|
||
| class BuildLibbsd(CrossCompileAutotoolsProject): | ||
| _always_add_suffixed_targets = True | ||
| _can_use_autogen_sh = True | ||
| _supported_architectures = ( | ||
| CompilationTargets.CHERI_LINUX_RISCV64_PURECAP_093, | ||
| CompilationTargets.CHERI_LINUX_MORELLO_PURECAP, | ||
| CompilationTargets.MORELLO_LINUX_MORELLO_PURECAP, | ||
| ) | ||
| _default_architecture = CompilationTargets.CHERI_LINUX_RISCV64_PURECAP_093 | ||
| make_kind = MakeCommandKind.GnuMake | ||
| repository = GitRepository( | ||
| "https://gitlab.freedesktop.org/libbsd/libbsd.git", | ||
| temporary_url_override="https://gitlab.freedesktop.org/paul-metzger/libbsd-private-fork-pmetzger.git", | ||
| default_branch="0_12_2_with_alignment_macro_fix", | ||
| force_branch=True, | ||
| ) | ||
|
|
||
| @classproperty | ||
| def default_install_dir(self): | ||
| return DefaultInstallDir.ROOTFS_LOCALBASE | ||
|
|
||
| @classmethod | ||
| def dependencies(cls, config) -> "tuple[str, ...]": | ||
| ti = typing.cast(typing.Type[LinuxTargetInfoBase], cls.get_crosscompile_target().target_info_cls) | ||
| return ti.musl_target, "libmd" | ||
|
|
||
| def setup(self) -> None: | ||
| super().setup() | ||
| # Remove dependency on libgcc_eh | ||
| self.COMMON_LDFLAGS.append("--unwindlib=none") | ||
| # Remove dependcy on libgcc_s | ||
| self.COMMON_LDFLAGS.append("-Wc,--unwindlib=none") | ||
|
|
||
| def configure(self, **kwargs): | ||
| if not self.configure_command.exists(): | ||
| self.run_cmd(self.source_dir / "autogen", cwd=self.source_dir) | ||
| super().configure(**kwargs) | ||
|
|
||
| def compile(self, **kwargs): | ||
| self.run_make() | ||
| super().compile() | ||
|
|
||
| def install(self, **kwargs): | ||
| self.run_make_install() | ||
| super().install(**kwargs) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # | ||
| # Copyright (c) 2025-2026 Paul Metzger | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions | ||
| # are met: | ||
| # 1. Redistributions of source code must retain the above copyright | ||
| # notice, this list of conditions and the following disclaimer. | ||
| # 2. Redistributions in binary form must reproduce the above copyright | ||
| # notice, this list of conditions and the following disclaimer in the | ||
| # documentation and/or other materials provided with the distribution. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| # SUCH DAMAGE. | ||
| # | ||
|
|
||
| import typing | ||
|
|
||
| from .crosscompileproject import CrossCompileAutotoolsProject, DefaultInstallDir, GitRepository, MakeCommandKind | ||
| from ...config.compilation_targets import CompilationTargets, LinuxTargetInfoBase | ||
| from ...utils import classproperty | ||
|
|
||
|
|
||
| class BuildLibmd(CrossCompileAutotoolsProject): | ||
| _always_add_suffixed_targets = True | ||
| _can_use_autogen_sh = True | ||
| _supported_architectures = ( | ||
| CompilationTargets.CHERI_LINUX_RISCV64_PURECAP_093, | ||
| CompilationTargets.CHERI_LINUX_MORELLO_PURECAP, | ||
| CompilationTargets.MORELLO_LINUX_MORELLO_PURECAP, | ||
| ) | ||
| _default_architecture = CompilationTargets.CHERI_LINUX_RISCV64_PURECAP_093 | ||
| make_kind = MakeCommandKind.GnuMake | ||
| is_sdk_target = False | ||
| repository = GitRepository("https://git.hadrons.org/git/libmd.git") | ||
|
|
||
| @classproperty | ||
| def default_install_dir(self): | ||
| return DefaultInstallDir.ROOTFS_LOCALBASE | ||
|
|
||
| @classmethod | ||
| def dependencies(cls, config) -> "tuple[str, ...]": | ||
| ti = typing.cast(typing.Type[LinuxTargetInfoBase], cls.get_crosscompile_target().target_info_cls) | ||
| return (ti.musl_target,) | ||
|
|
||
| def setup(self) -> None: | ||
| super().setup() | ||
| # Remove dependency on libgcc_eh | ||
| self.COMMON_LDFLAGS.append("--unwindlib=none") | ||
| # Remove dependcy on libgcc_s | ||
| self.COMMON_LDFLAGS.append("-Wc,--unwindlib=none") | ||
|
|
||
| def configure(self, **kwargs): | ||
| if not self.configure_command.exists(): | ||
| self.run_cmd(self.source_dir / "autogen", cwd=self.source_dir) | ||
| super().configure(**kwargs) | ||
|
|
||
| def compile(self, **kwargs): | ||
| self.run_make() | ||
| super().compile(**kwargs) | ||
|
|
||
| def install(self, **kwargs): | ||
| self.run_make_install() | ||
| super().install(**kwargs) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # | ||
| # Copyright (c) 2025-2026 Paul Metzger | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions | ||
| # are met: | ||
| # 1. Redistributions of source code must retain the above copyright | ||
| # notice, this list of conditions and the following disclaimer. | ||
| # 2. Redistributions in binary form must reproduce the above copyright | ||
| # notice, this list of conditions and the following disclaimer in the | ||
| # documentation and/or other materials provided with the distribution. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| # SUCH DAMAGE. | ||
| # | ||
|
|
||
| import typing | ||
|
|
||
| from .crosscompileproject import CrossCompileAutotoolsProject, DefaultInstallDir, GitRepository, MakeCommandKind | ||
| from ...config.compilation_targets import CompilationTargets, LinuxTargetInfoBase | ||
| from ...utils import classproperty | ||
|
|
||
|
|
||
| class BuildLibxo(CrossCompileAutotoolsProject): | ||
| _always_add_suffixed_targets = True | ||
| _can_use_autogen_sh = True | ||
| _supported_architectures = ( | ||
| CompilationTargets.CHERI_LINUX_RISCV64_PURECAP_093, | ||
| CompilationTargets.CHERI_LINUX_MORELLO_PURECAP, | ||
| CompilationTargets.MORELLO_LINUX_MORELLO_PURECAP, | ||
| ) | ||
| _default_architecture = CompilationTargets.CHERI_LINUX_RISCV64_PURECAP_093 | ||
| make_kind = MakeCommandKind.GnuMake | ||
| repository = GitRepository("https://github.com/Juniper/libxo.git") | ||
|
|
||
| @classproperty | ||
| def default_install_dir(self): | ||
| return DefaultInstallDir.ROOTFS_LOCALBASE | ||
|
|
||
| @classmethod | ||
| def dependencies(cls, config) -> "tuple[str, ...]": | ||
| ti = typing.cast(typing.Type[LinuxTargetInfoBase], cls.get_crosscompile_target().target_info_cls) | ||
| return ti.musl_target, "libbsd", "libmd" | ||
|
|
||
| def _patch_to_use_libbsd(self, path): | ||
| self.run_cmd("sed", "-i", "s|<sys/queue.h>|<bsd/sys/queue.h>|g", path, cwd=self.source_dir) | ||
|
|
||
| def _patch_includes(self) -> None: | ||
| self._patch_to_use_libbsd("libxo/xo_encoder.c") | ||
| self._patch_to_use_libbsd("xopo/xopo.c") | ||
|
|
||
| def _patch_configure_ac(self) -> None: | ||
| self.run_cmd("sed", "-i", "s|AC_FUNC_REALLOC|#AC_FUNC_REALLOC|g", "configure.ac", cwd=self.source_dir) | ||
| self.run_cmd("sed", "-i", "s|AC_FUNC_MALLOC|#AC_FUNC_MALLOC|g", "configure.ac", cwd=self.source_dir) | ||
|
|
||
| def configure(self, **kwargs): | ||
| # Don't depend on libgcc_s. If this isn't set then clang wants to link | ||
| # with libgcc_s, which is not available on Morello Linux. | ||
| self.LDFLAGS.append("--unwindlib=none") | ||
| # This prompts libtool to pass '--unwindlib=none' to clang during | ||
| # linking. Libtool ignores "--unwindlib=none" and needs | ||
| # "-Wc,--unwindlib=none" instead. "-Wc,--unwindlib=none" is turned | ||
| # into "--unwindlib=none" by libtool when it invokes clang. | ||
| self.CFLAGS.append("-Wc,--unwindlib=none") | ||
|
|
||
| self._patch_configure_ac() | ||
| self._patch_includes() | ||
| self.run_shell_script("sh bin/setup.sh", shell="sh", cwd=self.source_dir) | ||
|
|
||
| super().configure(**kwargs) | ||
|
|
||
| def compile(self, **kwargs): | ||
| self.run_make() | ||
| super().compile(**kwargs) | ||
|
|
||
| def install(self, **kwargs): | ||
| self.run_make_install() | ||
| super().install(**kwargs) |
Uh oh!
There was an error while loading. Please reload this page.