-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[build] Add a new --cross-compile-build-swift-tools
flag to disable cross-compiling the compiler
#38441
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
Conversation
utils/build-script-impl
Outdated
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.
This changes the way --build-swift-tools
works, where before it would control building both native and cross-compiled host tools, but now it only affects the native ones. Since very few people were likely using this flag, I think it's better to split the functionality up like this for cross-compiling the host tools, rather than keeping --build-swift-tools
controlling both even after --cross-compile-build-swift-tools
is added.
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.
I will have to re-read and play around with the posix_spawn
problems to understand them. In general, I would say that things should work with vanilla Android, without special libraries or headers.
For the time being, let's see if this works in macOS and Linux and we are not going to break another platform by mistake.
@swift-ci please test |
Build failed |
Build failed |
The problem is that swiftlang/swift-corelibs-foundation#2928 added a dependency on some
A single failing test because I added a new path variable to the Android preset, didn't know I had to do something else for that, will fix it. |
90f4c15
to
40ef38d
Compare
I added a line to fix the single failing test on the CI and fixed the preset arch issue we discussed above. @drodriguez, I think this is ready for you to try on your local version of the Android CI. I think the only remaining issue will be adding library dependencies that the corelibs depend on to the Android CI, which will require the Termux packages I mentioned above for the Android corelibs and perhaps the native Ubuntu packages to build the native linux corelibs, if those Ubuntu packages like libcurl aren't already installed on the Android CI. |
40ef38d
to
26f0200
Compare
I remember that code 😀. I don't think anyone will object if we switch (again) all the direct usages of |
@swift-ci please test |
Alright, I will look into implementing that CF polyfill on top of that |
Build failed |
Build failed |
26f0200
to
fd79ea8
Compare
Gah, playing whack-a-mole with the non-Android CI: I had missed that preset variables need that |
@swift-ci please test |
… cross-compiling the compiler This is useful when building cross-compilation toolchains where you want the stdlib and corelibs cross-compiled but don't want the Swift compiler cross-compiled too with '--cross-compile-hosts'.
fd79ea8
to
5b1bff8
Compare
@swift-ci smoke test |
I've stripped this down to just adding the single build flag, with no changes to any of the Android presets, so the Foundation considerations no longer apply. @drodriguez, if you have any feedback on this final version, let me know. |
@swift-ci smoke test macos |
--cross-compile-build-swift-tools
flag to disable cross-compiling the compiler
Merging since this won't break anything, just wondered if Daniel had any input, still listening if he comes up with anything later. |
… cross-compiling the compiler (#38441) This is useful when building cross-compilation toolchains where you want the stdlib and corelibs cross-compiled but don't want the Swift compiler cross-compiled too with `--cross-compile-hosts`.
* Run the compiler validation suite for Android * Add --build-compiler option * Add --cross-compile-build-swift-tools=0 from swiftlang/swift#38441 * Build with --build-llvm=0 * Check out Yams for Swift 6.1.1 build * Add --llvm-ninja-targets-for-cross-compile-hosts=help * Install pre-requisites * Install build prerequisites * Only setup local toolchain if build-compiler is not 0 * Fix Yams version checkout * Quote arguments to build scripts * Permit empty host-toolchain argument in build.sh * Fix check for BUILD_COMPILER * Re-order Docker PATH to system clang is used before Swift toolchain clang * Use --host-test to skip attempt to test on connected device/emulator * Install clang in Dockerfile * Add --skip-test-linux flag to build * Remove more folders to free up space * Update patches * Add docker-specific CI variants that run the compiler validation tests * meaningless edit * Update pull_request.yml to stop the 6.1 release builds * Update pull_request.yml to really only build the full docker compiler with tests * Update README.md with meaningless edit to bump build * Update build.sh to skip testing XCTest for linux, as a handful of the linux tests fail for some reason * Update build.sh to disable building libTesting and for 16K memory pages, as both don't work yet * Update build.sh to skip testing Foundation for linux, which requires building SwiftPM from source first * Update build.sh to not build each arch in a separate build directory * Update Dockerfile to use clang 19 instead * Add self-hosted runner CI variant * Fix CI workflow syntax * Update CI runner config * Update CI runner config * Fix name of self-hosted CI runner * Re-order arch run sequence * Update CI for self-hosted runner * Build for self-hosted runner * Add swift-6.2-branch to self-hosted run matrix * Update build.sh to disable aarch64 temporarily, as we know it built fine * Update pull_request.yml to disable non-compiler builds, as they all work, and comment out self-hosted till we know armv7 works * Run compiler validation on self-hosted with increased timeout * Update build-docker to only build for armv7 * Update pull_request.yml to disable self-hosted builds temporarily * Update pull_request.yml to build the full compiler in github runners with the armv7 stdlib and tests * Update build-docker to build for aarch64 first * Update toolchain-vars.sh to use older trunk snapahot toolchain that didn't crash * Update toolchain-vars.sh to only download the latest release compiler if building the Swift compiler from source * Update build-docker to only build for armv7 again * Update toolchain-vars.sh to fix setting branch variable * Update build-docker to build for all three supported arches * Update pull_request.yml to try self-hosted runs again * Update build.sh to only install SDK components and remove linux stdlib * Tolerate missing linux folder when attempting to clean up unnecessary build artifacts * Fix extraCLIOptions in swift-toolset.json * gcpdw * Fix patch application * Update apply-patches.sh to remove unused changes * Update swift-android-testing-except-release.patch to add Testing fix * Update swift-android.patch to remove unneeded patches * Update build.sh to try and fix Testing and clean up the bundle more * Fix README.md --------- Co-authored-by: finagolfin <[email protected]>
…83422) This new flag makes it easy to build Swift cross-compilation toolchains, by disabling cross-compilation of all host tools, like the Swift compiler and various macros, building on prior pulls #38441 and #82163. Native compilation has more fine-grained flags like `--build-swift-tools`, `--build-llvm`, and `--swift-testing-macros`, but those will disable building them for _all_ platforms (with the exception of `--build-swift-tools`, which I modified to only apply for the host, since the initial introduction of this `--cross-compile-build-swift-tools` flag a couple months ago), so they're not suited for building a cross-compilation toolchain, where you want all host tools built for the native host but not for any cross-compilation SDKs.
* Add Android workflow * Build Android image (#1) * Build Android image * Checkout without ssh * Retry build if it fails * Swift 6.1 Release Dockerfiles (#456) * Change binutils-gold package dependency on Debian 12 to binutils (#457) * Update installed packages after nightly platform expansion (#458) * update nightly-6.1 dependencies * update nightly-main dependencies * fix ubuntu images * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Fedora 41 Dockerfile (#464) * Build Android image * Build Android image * Swift 6.1 Release Dockerfiles (#456) * Change binutils-gold package dependency on Debian 12 to binutils (#457) * Build Android image * Build Android image * Build Android image * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Android SDK build * Swift Androd build * Swift Androd build * Swift Androd build * Swift Androd build * Swift Androd build * Swift Androd build * Swift Androd build * Swift Androd build * Swift Androd build * Swift Androd build * Swift Androd build * Swift Androd build * Swift Androd build * Swift Androd build * Swift Androd build * Swift Androd build * Swift Androd build * Swift Android build * Swift Android build * Swift Android build * Swift Android build --------- Co-authored-by: Mishal Shah <[email protected]> Co-authored-by: Chris McGee <[email protected]> Co-authored-by: Justice Adams <[email protected]> Co-authored-by: Andrew Sukach <[email protected]> * Swift Android build 6.2 (#2) * Swift Android build 6.2 * Swift Android build 6.2 * Swift Android build 6.2 * Start splitting NDK out from the rest of the SDK * Start splitting NDK out from the rest of the SDK * Swift Android build 6.2 * Swift Android build 6.2 * Swift Android build 6.2 * Swift Android build 6.2 * Swift Android build 6.2 * Swift Android build 6.2 * Swift Android build 6.2 * Swift Android build 6.2 * Swift Android build 6.2 * Swift Android build 6.2 * Swift Android build 6.2 * Swift Android build 6.2 * Swift Android build 6.2 * Swift Android build 6.2 * Swift Android build 6.2 * Swift Android build 6.2 (#3) * Swift Android build 6.2 * Swift Android build 6.2 * Add post-install script to SDK bundle * Add post-install script to SDK bundle * Add post-install script to SDK bundle * Add post-install script to SDK bundle * Build SDK in Docker container (#4) * Add static libraries to post-install script * Add post-install script to SDK bundle * Add post-install script to SDK bundle * Update submodules * Checkout patches repo instead of using a git submodule * Update libcurl to 8.13.0 * Remove resources that we no longer use * Update libcurl to 8.13.0 * Update libxml2 to 2.14.2 * Build libxml2, libcurl, and boringssl with support for Android 16kb page sizes * Add build-script --extra-cmake-options=-DCMAKE_EXTRA_LINK_FLAGS=-Wl,-z,max-page-size=16384 * Add 16KB page size linker flags to linker flags in swift-toolset.json * Add 16KB page size linker flags to linker flags in swift-toolset.json * Build with ndk-r28b * Revert to building with ndk-r27c * Use official endpoints for discovering latest Swift release/devel/trunk tags * Typo fix in version script * Cleanup for PR * Change BUILD_VERSION to BUILD_SCHEME and have it match release, swift-*-branch, or development * Update Android README * Update how patches are applied * Fix source directory for patch target * Harmonize timestamps in artifactbundle with the swift source tag date for build reproducibility * Simplify toolchain-vars.sh * Run the compiler validation suite for Android (#8) * Run the compiler validation suite for Android * Add --build-compiler option * Add --cross-compile-build-swift-tools=0 from swiftlang/swift#38441 * Build with --build-llvm=0 * Check out Yams for Swift 6.1.1 build * Add --llvm-ninja-targets-for-cross-compile-hosts=help * Install pre-requisites * Install build prerequisites * Only setup local toolchain if build-compiler is not 0 * Fix Yams version checkout * Quote arguments to build scripts * Permit empty host-toolchain argument in build.sh * Fix check for BUILD_COMPILER * Re-order Docker PATH to system clang is used before Swift toolchain clang * Use --host-test to skip attempt to test on connected device/emulator * Install clang in Dockerfile * Add --skip-test-linux flag to build * Remove more folders to free up space * Update patches * Add docker-specific CI variants that run the compiler validation tests * meaningless edit * Update pull_request.yml to stop the 6.1 release builds * Update pull_request.yml to really only build the full docker compiler with tests * Update README.md with meaningless edit to bump build * Update build.sh to skip testing XCTest for linux, as a handful of the linux tests fail for some reason * Update build.sh to disable building libTesting and for 16K memory pages, as both don't work yet * Update build.sh to skip testing Foundation for linux, which requires building SwiftPM from source first * Update build.sh to not build each arch in a separate build directory * Update Dockerfile to use clang 19 instead * Add self-hosted runner CI variant * Fix CI workflow syntax * Update CI runner config * Update CI runner config * Fix name of self-hosted CI runner * Re-order arch run sequence * Update CI for self-hosted runner * Build for self-hosted runner * Add swift-6.2-branch to self-hosted run matrix * Update build.sh to disable aarch64 temporarily, as we know it built fine * Update pull_request.yml to disable non-compiler builds, as they all work, and comment out self-hosted till we know armv7 works * Run compiler validation on self-hosted with increased timeout * Update build-docker to only build for armv7 * Update pull_request.yml to disable self-hosted builds temporarily * Update pull_request.yml to build the full compiler in github runners with the armv7 stdlib and tests * Update build-docker to build for aarch64 first * Update toolchain-vars.sh to use older trunk snapahot toolchain that didn't crash * Update toolchain-vars.sh to only download the latest release compiler if building the Swift compiler from source * Update build-docker to only build for armv7 again * Update toolchain-vars.sh to fix setting branch variable * Update build-docker to build for all three supported arches * Update pull_request.yml to try self-hosted runs again * Update build.sh to only install SDK components and remove linux stdlib * Tolerate missing linux folder when attempting to clean up unnecessary build artifacts * Fix extraCLIOptions in swift-toolset.json * gcpdw * Fix patch application * Update apply-patches.sh to remove unused changes * Update swift-android-testing-except-release.patch to add Testing fix * Update swift-android.patch to remove unneeded patches * Update build.sh to try and fix Testing and clean up the bundle more * Fix README.md --------- Co-authored-by: finagolfin <[email protected]> * Build compiler-validated bundles from latest branch commits, not older tags Also update patches, particularly to disable failing tests from the compiler validation suite * gcpd 'Update patches' * Update patches and build matrix * Disable compiler validated builds on self-hosted * Centralize cmake variable for 6.2 in patches, as done for trunk upstream * Update disabled tests * Try running Docker build on macOS host * Remove separate checks of libxml2, curl, and yams * Remove upstreamed 6.2 branch patches * Use command-line flags to work around CMake 3.30+ linker flag bug, rather than patching files * Create an Android CMake toolchain file instead to cross-compile Testing and add 16 KB page linker flag to 6.2 branch * Install the native host LLVM tools for full compiler builds * Extend `--cross-compile-build-swift-tools=False` to disable building and installing LLVM and the Testing macros for cross-compiled hosts, then enable building and using the Testing macros for the native host. * Don't copy any libraries from the NDK: link the NDK's clang resource directory in the post-install script instead * Wildcard the clang version link in the post-install script in order to accomodate NDK 27 and 28 * Switch generated shell header to use #!/usr/bin/env bash * SBOM and nits (#14) * Address nits * Eliminate unnecessaryt pushds and use run cmake install instead of ninja * Generate SBOM with SDK dependencies * Add example of command for building locally * Remove upstreamed patches and turn the last modifications into perl substitutions instead. * Remove self-hosted build on github CI * Remove android_build job from pull_request workflow * Add license headers to Android build scripts * Remove unnecessary .gitignore * Add license header to Dockerfile * Switch over to using explicit tags and branches when invoking build-docker/local Also, force the full Swift compiler to be built from source when building from a branch, since there are no existing toolchain builds of arbitrary commits that we can download. --------- Co-authored-by: Mishal Shah <[email protected]> Co-authored-by: Chris McGee <[email protected]> Co-authored-by: Justice Adams <[email protected]> Co-authored-by: Andrew Sukach <[email protected]> Co-authored-by: finagolfin <[email protected]>
This is useful when building cross-compilation toolchains where you want the stdlib and corelibs cross-compiled but don't want the Swift compiler cross-compiled too with
--cross-compile-hosts
. This pull demonstrates using the new flag for the Android build presets.I'm submitting this after discussing cross-compiling the corelibs on the Android CI with @drodriguez, as the easiest way to do so after #33724 is by using
--cross-compile-hosts
but we don't want to cross-compile the Swift compiler too.To build this, I first had to unpack three Termux packages for Android,
libandroid-spawn
,libcurl
, andlibxml2
(I also unpackedlibicu
but the Android CI does that differently) as detailed here, because those libraries are dependencies ofswift-corelibs-foundation
.I then passed that
swift-android-aarch64-24-sdk
path into thisbuild-script
invocation with the July 9 trunk source snapshot to build an Android cross-compilation toolchain that includes the corelibs:swift-corelibs-foundation
recently added a dependency on someposix_spawn
functions on Android, which as discussed on the forum isn't officially supported before Android API 28, so I linked against Termux's backported library with these additional patches:Alternatively, since the build only fails when linking
plutil
againstlibFoundation.a
and we can't run the tests for the cross-compiled corelibs, we could hack out building a staticplutil
or revert the small pull adding that dependency, as done in vgorloff/swift-everywhere-toolchain#116.@drodriguez, let me know what you think.