Skip to content

[build] extend support for building with a prebuilt toolchain to the corelibs and llbuild #32922

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

Merged
merged 1 commit into from
Jul 23, 2020

Conversation

finagolfin
Copy link
Member

The flags --native-{swift,clang,llvm}-tools-path, for building the Swift stdlib with a prebuilt Swift and clang compiler, have been around since the beginning, so might as well use them to quickly build other Swift repos too. This is useful when iterating on the Swift corelibs, so you don't have to build the most recent compilers from scratch each time.

The following commands will set up, build, and run the tests for libdispatch for the most recent trunk snapshot for which there's an official prebuilt compiler, with this pull merged:

wget https://swift.org/builds/development/ubuntu2004/swift-DEVELOPMENT-SNAPSHOT-2020-07-15-a/swift-DEVELOPMENT-SNAPSHOT-2020-07-15-a-ubuntu20.04.tar.gz
tar xf swift-DEVELOPMENT-SNAPSHOT-2020-07-15-a-ubuntu20.04.tar.gz
mv swift-DEVELOPMENT-SNAPSHOT-2020-07-15-a-ubuntu20.04 swift-715
rm /home/butta/swift-715/usr/lib/swift/dispatch/module.modulemap

cd swift
git checkout swift-DEVELOPMENT-SNAPSHOT-2020-07-15-a
cd ../swift-corelibs-dispatch
git checkout swift-DEVELOPMENT-SNAPSHOT-2020-07-15-a
cd ..

./swift/utils/build-script -R --no-assertions --native-swift-tools-path=/home/butta/swift-715/usr/bin/ --native-clang-tools-path=/home/butta/swift-715/usr/bin/ --skip-build-cmark --skip-build-llvm --skip-build-swift --libdispatch -T -j9

This is obviously much quicker than rebuilding the Swift and clang compilers every time you checkout a trunk snapshot. Replacing --libdispatch with --xctest -b in that last command, I was able to build and test all the corelibs and llbuild on linux, though I had to remove the CoreFoundation module.map too (rm /home/butta/swift-715/usr/lib/swift/CoreFoundation/module.map), as those module maps that come with the prebuilt toolchain conflict with the freshly built ones (the tests already pass LD_LIBRARY_PATH where necessary to link and test the freshly built corelibs), and XCTest and llbuild needed my recent pull #32860 for testing to work (otherwise, lit and some other testing utilities couldn't be found).

@shahmishal, this could also be used on the CI to greatly reduce testing times for these corelibs, by caching the build of the latest merged commit in this compiler repo and reusing it for the CI for the corelibs and other repos. A few projects like libdispatch couldn't be run this way, as it's a dependency of SourceKit and is built as part of this repo too, but the rest of these Swift repos' CI could be run a lot faster, saving a lot of wasted builds.

This pull is based on my patch to cross-compile the corelibs and SPM for Android AArch64, which is used to distribute a Swift toolchain that runs on Android AArch64 devices.

cmake_options=(
${cmake_options[@]}
-DCMAKE_Swift_COMPILER:PATH="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this pull for two swiftc invocations that I had missed: lldb above and removing this one that's unused, as cmake_options isn't invoked by the test commands. Since this flag was never used, just remove it.

-DCMAKE_Swift_COMPILER:PATH="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
-DCMAKE_C_COMPILER:PATH="${CLANG_BIN}/clang"
-DCMAKE_CXX_COMPILER:PATH="${CLANG_BIN}/clang++"
-DCMAKE_Swift_COMPILER:PATH=${SWIFTC_BIN}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was set this way before but I notice that @benlangmuir changed it, a mistake? Would be good if you could review this pull.

@finagolfin
Copy link
Member Author

@davezarzycki, since you appear familiar with these native tools options to employ a prebuilt toolchain, let me know if you have any input on this pull.

@davezarzycki
Copy link
Contributor

Hi @buttaface – I actually just recently discovered that pre-built binaries could be used so I'm not familiar with the feature. I also don't use the build-script to build Swift. This all being said, the patch looks reasonable but maybe I'm missing something.

@finagolfin
Copy link
Member Author

OK, good to know.

@atrick
Copy link
Contributor

atrick commented Jul 21, 2020

Seems like an obvious thing to do. I'm not the best person to decide if this is the right way to do it, but it looks like good work to me.

@finagolfin
Copy link
Member Author

Alright, thanks.

@shahmishal
Copy link
Member

cc: @edymtt

@shahmishal shahmishal requested a review from edymtt July 21, 2020 06:53
@shahmishal
Copy link
Member

@swift-ci build toolchain

@shahmishal
Copy link
Member

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 32d341e

@swift-ci
Copy link
Contributor

Linux Toolchain (Ubuntu 16.04)
Download Toolchain
Git Sha - 32d341e

Install command
tar zxf swift-PR-32922-400-ubuntu16.04.tar.gz
More info

@swift-ci
Copy link
Contributor

macOS Toolchain
Download Toolchain
Git Sha - 32d341e

Install command
tar -zxf swift-PR-32922-575-osx.tar.gz --directory ~/

@finagolfin
Copy link
Member Author

@gottesmm, this extends the prebuilt toolchain support- that you added a preset for to build a standalone Swift stdlib, 5f15385- to the corelibs and llbuild, mind reviewing?

@shahmishal
Copy link
Member

LGTM! Thanks for the PR!

@shahmishal shahmishal merged commit 3dc8b38 into swiftlang:master Jul 23, 2020
@finagolfin
Copy link
Member Author

Thanks for reviewing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants