Skip to content

Commit

Permalink
jenkins installdir hack: Don't append /opt/<arch> to rootfs targets
Browse files Browse the repository at this point in the history
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__
```
  • Loading branch information
arichardson committed Dec 30, 2024
1 parent 9d41727 commit 7834af2
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions pycheribuild/config/target_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class AbstractProject(FileSystemUtils):
_xtarget: "ClassVar[Optional[CrossCompileTarget]]" = None
default_architecture: "ClassVar[Optional[CrossCompileTarget]]"
needs_sysroot: "ClassVar[bool]"
is_rootfs_target: typing.ClassVar[bool] = False # Whether this project installation directory is a rootfs dir

auto_var_init: AutoVarInit # Needed for essential_compiler_flags
config: CheriConfig
Expand Down
2 changes: 2 additions & 0 deletions pycheribuild/jenkins_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def expected_install_root(tgt: Target) -> Path:

def expected_install_prefix(tgt: Target) -> Path:
if install_prefix_arg is None:
if tgt.project_class.is_rootfs_target:
return Path("/")
return default_install_prefix(tgt.xtarget, cheri_config)
else:
return install_prefix_arg
Expand Down
1 change: 1 addition & 0 deletions pycheribuild/projects/cross/cheribsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ class BuildFreeBSD(BuildFreeBSDBase):
target: str = "freebsd"
repository: GitRepository = GitRepository("https://github.com/freebsd/freebsd.git")
needs_sysroot: bool = False # We are building the full OS so we don't need a sysroot
is_rootfs_target: typing.ClassVar[bool] = True # All derived classes are also rootfs targets
# We still allow building FreeBSD for MIPS64. While the main branch no longer has support, this allows building
# the stable/13 branch using cheribuild. However, MIPS is no longer included in ALL_SUPPORTED_FREEBSD_TARGETS.
supported_architectures: "typing.ClassVar[tuple[CrossCompileTarget, ...]]" = (
Expand Down
1 change: 1 addition & 0 deletions pycheribuild/projects/cross/newlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class BuildNewlib(CrossCompileAutotoolsProject):
target = "newlib"
make_kind = MakeCommandKind.GnuMake
is_sdk_target = True
is_rootfs_target = True
needs_sysroot = False # We are building newlib so we don't need a sysroot
add_host_target_build_config_options = False
_configure_supports_libdir = False
Expand Down
1 change: 1 addition & 0 deletions pycheribuild/projects/cross/picolibc.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class BuildPicoLibc(CrossCompileMesonProject):
# Installing the native headers and libraries to <output>/local breaks other native project builds.
native_install_dir = DefaultInstallDir.DO_NOT_INSTALL
needs_sysroot = False
is_rootfs_target = True
include_os_in_target_suffix = False # Avoid adding -picolibc- as we are building picolibc here
# ld.lld: error: -r and --gdb-index may not be used together
add_gdb_index = False
Expand Down
4 changes: 3 additions & 1 deletion pycheribuild/projects/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,9 @@ def add_lto_build_options(self, ccinfo: CompilerInfo) -> bool:
def rootfs_dir(self) -> Path:
xtarget = self.crosscompile_target.get_rootfs_target()
# noinspection PyProtectedMember
return self.target_info._get_rootfs_class(xtarget).get_install_dir(self, xtarget)
rootfs_cls: "type[AbstractProject]" = self.target_info._get_rootfs_class(xtarget)
assert rootfs_cls.is_rootfs_target
return rootfs_cls.get_install_dir(self, xtarget)

@property
def _no_overwrite_allowed(self) -> "Sequence[str]":
Expand Down
16 changes: 6 additions & 10 deletions tests/test_argument_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1493,29 +1493,25 @@ def test_jenkins_hack_hybrid_for_purecap_rootfs_prefix_none(monkeypatch):
cheribsd_morello_purecap = _get_target_instance("cheribsd-morello-purecap", config, BuildCHERIBSD)
# FIXME: we implicitly add /opt/morello-purecap for the rootfs dir here which does not make any sense
assert cheribsd_morello_purecap.target_info.install_prefix_dirname == "morello-purecap"
assert cheribsd_morello_purecap.install_dir == Path("/tmp/tarball/opt/morello-purecap")
assert cheribsd_morello_purecap.rootfs_dir == Path("/tmp/tarball/opt/morello-purecap")
# FIXME: assert cheribsd_morello_purecap.install_dir == Path("/tmp/tarball")
# FIXME: assert cheribsd_morello_purecap.rootfs_dir == Path("/tmp/tarball")
assert cheribsd_morello_purecap.install_dir == Path("/tmp/tarball")
assert cheribsd_morello_purecap.rootfs_dir == Path("/tmp/tarball")
# When building against the rootfs we do want the prefix though:
gmp_morello_purecap = _get_target_instance("gmp-morello-purecap", config, Project)
assert gmp_morello_purecap.crosscompile_target.is_cheri_purecap()
assert gmp_morello_purecap.target_info.install_prefix_dirname == "morello-purecap"
assert gmp_morello_purecap.install_dir == Path("/tmp/tarball/opt/morello-purecap")
assert gmp_morello_purecap.rootfs_dir == Path("/tmp/tarball/opt/morello-purecap")
# FIXME: gmp_morello_purecap.rootfs_dir == Path("/tmp/tarball")
assert gmp_morello_purecap.rootfs_dir == Path("/tmp/tarball")
assert gmp_morello_purecap.rootfs_dir == cheribsd_morello_purecap.install_dir

# The -hybrid-for-purecap-rootfs should install to the same rootfs but a different prefix:
gmp_morello_hybrid_for_purecap = _get_target_instance("gmp-morello-hybrid-for-purecap-rootfs", config, Project)
assert gmp_morello_hybrid_for_purecap.crosscompile_target.is_cheri_hybrid()
assert gmp_morello_hybrid_for_purecap.target_info.install_prefix_dirname == "morello-hybrid"
assert gmp_morello_hybrid_for_purecap.install_dir == Path("/tmp/tarball/opt/morello-hybrid")
# The rootfs should be the same as the gmp-purecap one:
assert gmp_morello_hybrid_for_purecap.rootfs_dir == gmp_morello_purecap.rootfs_dir
assert gmp_morello_hybrid_for_purecap.rootfs_dir == cheribsd_morello_purecap.install_dir
# FIXME: rootfs should be the same as the gmp-purecap
# FIXME: assert gmp_morello_hybrid_for_purecap.rootfs_dir == gmp_morello_purecap.rootfs_dir
# FIXME: gmp_morello_hybrid_for_purecap.rootfs_dir == Path("/tmp/tarball")
assert gmp_morello_hybrid_for_purecap.rootfs_dir == Path("/tmp/tarball/opt/morello-purecap")
assert gmp_morello_hybrid_for_purecap.rootfs_dir == Path("/tmp/tarball")


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

0 comments on commit 7834af2

Please sign in to comment.