Skip to content

Commit

Permalink
Fix ReuseOtherProjectDefaultTargetRepository architecture
Browse files Browse the repository at this point in the history
We were choosing the first supported architecture instead of the default
even if a default was explicitly set. This resulted in an error when
building e.g. `libunwind-with-host-compiler` since it tried to set up
LLVM for RISCV64 and therefore checked for a RISCV64 sysroot.
  • Loading branch information
arichardson committed Feb 8, 2024
1 parent 2d4d5d0 commit 2501b35
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions pycheribuild/projects/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class BuildCMake(AutotoolsProject):
repository = GitRepository("https://github.com/Kitware/CMake", # a lot faster than "https://cmake.org/cmake.git"
# track the stable release branch
default_branch="release")
default_architecture = CompilationTargets.NATIVE
native_install_dir = DefaultInstallDir.BOOTSTRAP_TOOLS
make_kind = MakeCommandKind.Ninja
add_host_target_build_config_options = False
Expand Down
6 changes: 5 additions & 1 deletion pycheribuild/projects/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,15 @@ def update(self, current_project: "Project", *, src_dir: Path, **kwargs):

class ReuseOtherProjectDefaultTargetRepository(ReuseOtherProjectRepository):
def __init__(self, source_project: "type[Project]", *, subdirectory=".", do_update=False):
xtarget = source_project.default_architecture
if xtarget is None and len(source_project.supported_architectures) == 1:
xtarget = source_project.supported_architectures[0]
assert xtarget is not None
super().__init__(
source_project,
subdirectory=subdirectory,
do_update=do_update,
repo_for_target=source_project.supported_architectures[0],
repo_for_target=xtarget,
)


Expand Down
4 changes: 2 additions & 2 deletions tests/test_argument_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,8 +1157,8 @@ def test_source_dir_option_when_reusing_git_repo():
)
assert str(_get_target_instance("llvm-native", config).source_dir) == "/custom/llvm/dir3"
assert str(_get_target_instance("compiler-rt-native", config).source_dir) == "/custom/compiler-rt/dir3"
# compiler-rt-riscv64 uses the default path, since we only changed llvm-native and compiler-rt-native:
assert str(_get_target_instance("compiler-rt-riscv64", config).source_dir) == "/foo/llvm-project/compiler-rt"
# compiler-rt-riscv64 uses the default path (llvm-native source), since we only changed compiler-rt-native:
assert str(_get_target_instance("compiler-rt-riscv64", config).source_dir) == "/custom/llvm/dir3/compiler-rt"

# Check that cheribsd-mfs-root-kernel reused the cheribsd source dir
assert str(_get_target_instance("cheribsd-mfs-root-kernel-riscv64-purecap", config).source_dir) == "/foo/cheribsd"
Expand Down

0 comments on commit 2501b35

Please sign in to comment.