-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add buildbot profile for cross-compiling for linux-armv7 using external sysroot #75367
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
Add buildbot profile for cross-compiling for linux-armv7 using external sysroot #75367
Conversation
@swift-ci test |
@swift-ci build toolchain |
Looks like the tests failed trying to run the new buildbot preset:
To fix this is it sufficient to just add a sysroot value to PRESET_DEFAULTS = {
'darwin_toolchain_alias': 'Alias',
'darwin_toolchain_bundle_identifier': 'BundleIdentifier',
'darwin_toolchain_display_name': 'DisplayName',
'darwin_toolchain_display_name_short': 'DisplayNameShort',
'darwin_toolchain_version': '1.0',
'darwin_toolchain_xctoolchain_name': 'default',
'extra_swift_args': '',
'install_destdir': '/tmp/install',
'install_symroot': '/tmp/install/symroot',
'install_all': False,
'install_toolchain_dir': '/tmp/install/toolchain',
'install_prefix': '/usr',
'installable_package': '/tmp/install/pkg',
'swift_install_destdir': '/tmp/install/swift',
'symbols_package': '/path/to/symbols/package',
'ndk_path': '/path/to/ndk',
'arm_dir': '/path/to/arm',
'toolchain_path': '/tmp/toolchain',
} |
Good to see you got all this working, however, it appears this is overly long because you're not that familiar with the fairly complex
Some of these flags are redundant or are better set in the Again, I can work with you to adjust this pull, let me know if you prefer chatting on matrix.org to do that. |
@@ -373,7 +373,7 @@ def get_linux_target_components(self, arch): | |||
def get_linux_sysroot(self, platform, arch): | |||
if not self.is_cross_compile_target('{}-{}'.format(platform, arch)): | |||
return None | |||
sysroot_arch, abi = self.get_linux_target_components(arch) | |||
sysroot_arch, _, abi = self.get_linux_target_components(arch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your change seems correct, but it might break the Alpine usecase it was added for in #61376 last year? @MaxDesiatov, wdyt?
@finagolfin thanks for the review. The reason why this isn't in trunk is that I'm unable to cross compile on main- so the hope here is that it could be included in 6.0 now, then moved over to main once we figure out what the issue is with cross compiling. I'd love to figure out a way to pare this down to not require the extra LLVM build step. It's been annoying but I haven't figured out how to get it to NOT require the I'd love to find the best way to do this, if you have some time to help me out and maybe try a few things- perhaps a better discussion on matrix.org to try a few things, then come back and update the pull request once something else is working. |
Sounds good, I'm available at this username on there: feel free to ping me when you want to discuss. |
@MaxDesiatov I have some further improvements for this buildbot but I wanted to ask if it's even worth trying to get this into Swift 6.0 at this late stage. I think I may have found what was causing @finagolfin helped me significantly but it seems like we'll be stuck with passing all the flags (target, sysroot) to the buildbot without changing the build scripts themselves (which is more changes in more files), and maybe there's a better opportunity to get this working in |
@xtremekforever would you be able to clarify the exact issues you're having on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like @MaxDesiatov said, this should go to main
first to ensure that it doesn't break anything, or if it does, it won't be on a time-sensitive branch.
The naming of the llvm
preset is a bit confusing to me.
Seeing buildbot_linux_crosscompile_armv7,llvm
followed by skip-build-llvm
sends mixed messages about what it's actually building. I like the idea of splitting the runtime and compiler builds, but that isn't what's happening here.
If I'm understanding this correctly, this is to prebuild tablegen and generate the intrinsics and clang resource headers? What is the error if you don't pre-build these?
@etcwilde, that's no longer needed, I showed him how to skip the llvm step. We're looking at main now, will submit a pull there next. |
@MaxDesiatov makes sense, so guess we'll have to do that. For one, I noticed that some incorrect flags were being passed to clang++ when compiling some objects. Here is what I saw in the failed clang++ calls: @etcwilde yeah we figured out how to disable the LLVM build step, I did not realize that there was a way to skip that entirely by setting |
I'll close this since we need to go back to |
Explanation:
Added new buildbot profiles that allow cross-compiling Swift 6.0 for linux-armv7. This provides 2 different build steps that must be performed to cross compile:
buildbot_linux_crosscompile_armv7,llvm
buildbot_linux_crosscompile_armv7,stdlib,corelibs
The first step is required to get some sort of llvm-linux-x86_64 directory created in the buildbot_linux_armv7 directory, which is required for the rest of the build.
This does require an external sysroot to be provided, but creating it is simple when using Docker. This is how I created the sysroot for Debian 12 Bookworm for armv7:
Then to build these profiles, the following commands can be used (assuming that the Swift 6.0 toolchain is installed):
Scope:
This mostly adds the new buildbot profiles, but also fixes an issue that prevented cross compilation starting in Swift 5.10, as well as tweaking the hardcoded
--gcc-toolchain
that prevented an external sysroot from being used to compile CXX interop modules.I also had to patch the
COMMON_SWIFT_FLAGS
that are passed to-DCMAKE_Swift_FLAGS
since it was including extra quotes that made any usage ofcommon-swift-flags=
in the build-presets.ini file crash and burn when building libdispatch, foundation, etc.Issues:
Original PRs:
Risk:
As far as I can tell these changes should NOT negatively impact other builds, but we need to run the CIs against it.
Testing:
All the existing CIs should be run against this to make sure that nothing was broken, especially with the CXX interop patch.
I tested all of this on a Raspberry Pi 3B+ running Raspberry Pi OS 12 (32-bit) and it works. I did not try building these profiles on a macOS host- just on Ubuntu and Debian hosts with the correct dependencies installed.
Reviewers: