Support building the SDK for arm64 #3678
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Support building the SDK for arm64
Catalyst 4 adds support for building with QEMU, so I initially leveraged this, but it turned out to be very much slower than emulating the amd64 SDK on arm64, where an arm64 build could then be mostly run without emulation. I have kept the code for the slower approach anyway since it is small and may be useful to somebody.
There were several places where we assumed that amd64 was native and arm64 required emulation via QEMU. The scripts are now more architecture-agnostic, paving the way for riscv support later.
We no longer set
QEMU_LD_PREFIXbecause it prevents the SDK itself from being emulated. It also assumes there is only one non-native target, which may not always be the case. bubblewrap does a better job of running binaries under QEMU. I've put a lot of work into catching all the instances where we were implicitly relying on QEMU when building packages. The new upstream sysroot.eclass has addressed some of the more stubborn cases.Note that this doesn't address the issue of how we actually publish a supported arm64 SDK on an ongoing basis as that requires more work. It would make sense to have a multi-arch image, but that might require building them in tandem. We wouldn't want a build of one to break the other. The naming of the SDK is also ambiguous in places.
How to use
--exclude dev-lang/perlto the list of excludes in build_library/catalyst.sh. This is a workaround for Gentoo's stage3 being unstable. Maybe we could add this permanently.At this point, my amd64-sdk container had seemingly corrupted itself because it refused to execute amd64 binaries. I don't recall this happening on my earlier attempts, but recreating the container works. The next step is done outside the container anyway.
I tried also building an amd64 image, and it almost worked, but there a couple of small issues to deal with.
Testing done
This two-phase SDK build in Jenkins was entirely successful. I noted one additional empty /usr/bin/qemu-aarch64 file in the arm64 image, but I've since added a line to clean that up at the end.
I have also built an arm64 SDK as above and used it to build an arm64 image.
changelog/directory (user-facing change, bug fix, security fix, update) -- N/A/bootand/usrsize, packages, list files for any missing binaries, kernel modules, config files, kernel modules, etc.