-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Unable to cross-compile for a Linux platform with the buildbot scripts #78960
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
Labels
armv7
Architecture: ARMv7
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
build-script
Area → utils: The build script
cross-compilation
Area → utils: Cross-compilation of project sources
Comments
xtremekforever
added a commit
to xtremekforever/swift
that referenced
this issue
Jan 28, 2025
Example build script for minimal stdlib + core libraries: ./swift/utils/build-script \
--cross-compile-hosts=linux-armv7 --cross-compile-sysroots=/path/to/sysroot \
# these are taken from the stdlib_base_standalone preset from build-presets.ini
--build-llvm=0 --skip-build-cmark --skip-build-benchmarks \
--skip-test-cmark --build-swift-tools=0 --build-swift-libexec=0 \
--skip-early-swift-driver --skip-early-swiftsyntax --build-embedded-stdlib=0 \
--native-swift-tools-path=$SWIFT_NATIVE_PATH --native-llvm-tools-path=$SWIFT_NATIVE_PATH --native-clang-tools-path=$SWIFT_NATIVE_PATH \
# we want to install swift, libdispatch, foundation, and xctest
--install-swift --libdispatch --install-libdispatch --foundation --install-foundation --xctest --install-xctest \
# everything gets install to the destdir of course
--install-destdir=swift-armv7-install |
xtremekforever
added a commit
to xtremekforever/swift
that referenced
this issue
Jan 31, 2025
…om:xtremekforever/swift into swiftlang#78960-swift-stdlib-cross-compile
xtremekforever
added a commit
to xtremekforever/swift
that referenced
this issue
Feb 2, 2025
As I explained in your linked pull, the issue is not as much the current build-script, but that you were using it wrong in your original simple command above. The much longer command in your last comment has much more of a chance of working, once you figure out how you want to pass in an external C sysroot. |
xtremekforever
added a commit
to xtremekforever/swift
that referenced
this issue
Feb 15, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
armv7
Architecture: ARMv7
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
build-script
Area → utils: The build script
cross-compilation
Area → utils: Cross-compilation of project sources
Uh oh!
There was an error while loading. Please reload this page.
Description
In order to build Swift for platforms such as armv6, armv7, or even less-powerful arm64 architectures, the ideal way to build is to cross-compile instead of trying to build the Swift toolchain directly on the target, which is very slow.
However, currently the build scripts in the swiftlang/swift repo do not properly support cross compilation for Linux architectures. For example, when trying to build for armv7 and an external sysroot, the first build steps completely fail to build for the desired architecture. As an example, here is the failure from cmark:
Reproduction
To reproduce the first issue with cmark, run the following command in Linux/Ubuntu:
Otherwise, run it without --build-llvm=0 to see other crashes that occur after LLVM is built for the host:
Basically, every step of compilation will fail without being patched.
Expected behavior
I would expect the above commands to succeed as long as the armv7 (armhf) libraries are installed in the host using something like:
Cross compilation should also work if using an external sysroot, like this:
Environment
Swift version 6.0.3 (swift-6.0.3-RELEASE)
Target: x86_64-unknown-linux-gnu
Additional information
I intend to look at updating the scripts to properly cross compile to linux- hosts. If this is not the proper path, please let me know, but this seems to be the most logical thing to use since --cross-compile-hosts can already cross-compile to other Apple platforms.
Here are the short terms goals of being able to cross compile using the build-script. Let's get the build scripts updated to make it possible to cross compile the following components to linux-armv7:
This is the "minimal installation" that is needed for something like a cross-compilation Swift SDK (swift-sdk-generator).
The text was updated successfully, but these errors were encountered: