Skip to content

Commit 7834af2

Browse files
committed
jenkins installdir hack: Don't append /opt/<arch> to rootfs targets
This ensures that we end up with the same rootfs directory for -purecap and -hybrid-for-purecap-rootfs targets. Fixes running: ``` env WORKSPACE=/tmp CHERIBUILD_ENABLE_HYBRID_FOR_PURECAP_ROOTFS_TARGETS=1 /usr/local/google/home/alexrichardson/cheri/cheribuild/tests/../jenkins-cheri-build.py --allow-more-than-one-target --build --test --cpu=default -p __run_everything__ ```
1 parent 9d41727 commit 7834af2

File tree

7 files changed

+15
-11
lines changed

7 files changed

+15
-11
lines changed

pycheribuild/config/target_info.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class AbstractProject(FileSystemUtils):
163163
_xtarget: "ClassVar[Optional[CrossCompileTarget]]" = None
164164
default_architecture: "ClassVar[Optional[CrossCompileTarget]]"
165165
needs_sysroot: "ClassVar[bool]"
166+
is_rootfs_target: typing.ClassVar[bool] = False # Whether this project installation directory is a rootfs dir
166167

167168
auto_var_init: AutoVarInit # Needed for essential_compiler_flags
168169
config: CheriConfig

pycheribuild/jenkins_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ def expected_install_root(tgt: Target) -> Path:
7979

8080
def expected_install_prefix(tgt: Target) -> Path:
8181
if install_prefix_arg is None:
82+
if tgt.project_class.is_rootfs_target:
83+
return Path("/")
8284
return default_install_prefix(tgt.xtarget, cheri_config)
8385
else:
8486
return install_prefix_arg

pycheribuild/projects/cross/cheribsd.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ class BuildFreeBSD(BuildFreeBSDBase):
632632
target: str = "freebsd"
633633
repository: GitRepository = GitRepository("https://github.com/freebsd/freebsd.git")
634634
needs_sysroot: bool = False # We are building the full OS so we don't need a sysroot
635+
is_rootfs_target: typing.ClassVar[bool] = True # All derived classes are also rootfs targets
635636
# We still allow building FreeBSD for MIPS64. While the main branch no longer has support, this allows building
636637
# the stable/13 branch using cheribuild. However, MIPS is no longer included in ALL_SUPPORTED_FREEBSD_TARGETS.
637638
supported_architectures: "typing.ClassVar[tuple[CrossCompileTarget, ...]]" = (

pycheribuild/projects/cross/newlib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class BuildNewlib(CrossCompileAutotoolsProject):
4242
target = "newlib"
4343
make_kind = MakeCommandKind.GnuMake
4444
is_sdk_target = True
45+
is_rootfs_target = True
4546
needs_sysroot = False # We are building newlib so we don't need a sysroot
4647
add_host_target_build_config_options = False
4748
_configure_supports_libdir = False

pycheribuild/projects/cross/picolibc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class BuildPicoLibc(CrossCompileMesonProject):
3939
# Installing the native headers and libraries to <output>/local breaks other native project builds.
4040
native_install_dir = DefaultInstallDir.DO_NOT_INSTALL
4141
needs_sysroot = False
42+
is_rootfs_target = True
4243
include_os_in_target_suffix = False # Avoid adding -picolibc- as we are building picolibc here
4344
# ld.lld: error: -r and --gdb-index may not be used together
4445
add_gdb_index = False

pycheribuild/projects/project.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,9 @@ def add_lto_build_options(self, ccinfo: CompilerInfo) -> bool:
11831183
def rootfs_dir(self) -> Path:
11841184
xtarget = self.crosscompile_target.get_rootfs_target()
11851185
# noinspection PyProtectedMember
1186-
return self.target_info._get_rootfs_class(xtarget).get_install_dir(self, xtarget)
1186+
rootfs_cls: "type[AbstractProject]" = self.target_info._get_rootfs_class(xtarget)
1187+
assert rootfs_cls.is_rootfs_target
1188+
return rootfs_cls.get_install_dir(self, xtarget)
11871189

11881190
@property
11891191
def _no_overwrite_allowed(self) -> "Sequence[str]":

tests/test_argument_parsing.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,29 +1493,25 @@ def test_jenkins_hack_hybrid_for_purecap_rootfs_prefix_none(monkeypatch):
14931493
cheribsd_morello_purecap = _get_target_instance("cheribsd-morello-purecap", config, BuildCHERIBSD)
14941494
# FIXME: we implicitly add /opt/morello-purecap for the rootfs dir here which does not make any sense
14951495
assert cheribsd_morello_purecap.target_info.install_prefix_dirname == "morello-purecap"
1496-
assert cheribsd_morello_purecap.install_dir == Path("/tmp/tarball/opt/morello-purecap")
1497-
assert cheribsd_morello_purecap.rootfs_dir == Path("/tmp/tarball/opt/morello-purecap")
1498-
# FIXME: assert cheribsd_morello_purecap.install_dir == Path("/tmp/tarball")
1499-
# FIXME: assert cheribsd_morello_purecap.rootfs_dir == Path("/tmp/tarball")
1496+
assert cheribsd_morello_purecap.install_dir == Path("/tmp/tarball")
1497+
assert cheribsd_morello_purecap.rootfs_dir == Path("/tmp/tarball")
15001498
# When building against the rootfs we do want the prefix though:
15011499
gmp_morello_purecap = _get_target_instance("gmp-morello-purecap", config, Project)
15021500
assert gmp_morello_purecap.crosscompile_target.is_cheri_purecap()
15031501
assert gmp_morello_purecap.target_info.install_prefix_dirname == "morello-purecap"
15041502
assert gmp_morello_purecap.install_dir == Path("/tmp/tarball/opt/morello-purecap")
1505-
assert gmp_morello_purecap.rootfs_dir == Path("/tmp/tarball/opt/morello-purecap")
1506-
# FIXME: gmp_morello_purecap.rootfs_dir == Path("/tmp/tarball")
1503+
assert gmp_morello_purecap.rootfs_dir == Path("/tmp/tarball")
15071504
assert gmp_morello_purecap.rootfs_dir == cheribsd_morello_purecap.install_dir
15081505

15091506
# The -hybrid-for-purecap-rootfs should install to the same rootfs but a different prefix:
15101507
gmp_morello_hybrid_for_purecap = _get_target_instance("gmp-morello-hybrid-for-purecap-rootfs", config, Project)
15111508
assert gmp_morello_hybrid_for_purecap.crosscompile_target.is_cheri_hybrid()
15121509
assert gmp_morello_hybrid_for_purecap.target_info.install_prefix_dirname == "morello-hybrid"
15131510
assert gmp_morello_hybrid_for_purecap.install_dir == Path("/tmp/tarball/opt/morello-hybrid")
1511+
# The rootfs should be the same as the gmp-purecap one:
1512+
assert gmp_morello_hybrid_for_purecap.rootfs_dir == gmp_morello_purecap.rootfs_dir
15141513
assert gmp_morello_hybrid_for_purecap.rootfs_dir == cheribsd_morello_purecap.install_dir
1515-
# FIXME: rootfs should be the same as the gmp-purecap
1516-
# FIXME: assert gmp_morello_hybrid_for_purecap.rootfs_dir == gmp_morello_purecap.rootfs_dir
1517-
# FIXME: gmp_morello_hybrid_for_purecap.rootfs_dir == Path("/tmp/tarball")
1518-
assert gmp_morello_hybrid_for_purecap.rootfs_dir == Path("/tmp/tarball/opt/morello-purecap")
1514+
assert gmp_morello_hybrid_for_purecap.rootfs_dir == Path("/tmp/tarball")
15191515

15201516

15211517
# Another regression test, explicitly overriding the installation directory triggered an assertion

0 commit comments

Comments
 (0)