Skip to content

swift: add script for on-device build#4895

Merged
1 commit merged intotermux:masterfrom
finagolfin:swift
Feb 17, 2020
Merged

swift: add script for on-device build#4895
1 commit merged intotermux:masterfrom
finagolfin:swift

Conversation

@finagolfin
Copy link
Copy Markdown
Member

@finagolfin finagolfin commented Feb 10, 2020

This is for anyone who wants to try building the Swift 5.1.4 toolchain on an Android AArch64 device using the scripts in this repository. The following commands should do, you will need 5 GBs of free space and I estimate about an hour and a half with a Snapdragon 855:

pkg install clang binutils-gold file patch python cmake ninja python2 perl rsync libandroid-spawn libcurl libicu libsqlite libuuid libxml2 llbuild pkg-config
TERMUX_MAKE_PROCESSES=7 ./build-package.sh swift

Maybe one of the maintainers can build it and add the package to bintray.com. Getting all this cross-compiling from linux x86_64 like all the other Termux packages will require more work, since the Swift build scripts don't fully support building all this, other than cross-compiling the compiler and stdlib.

Most of these patches have been upstreamed and will be part of the upcoming 5.2 release next month. Only around 10 tests fail from the Swift compiler test suite of 10,000+ tests, with a couple more testing-related patches backported to this release. Where I used somebody else's patches from upstream, I included the full git commit info.

Once built, you can test it out by downloading a Swift package that has support for the Swift package manager and running swift build. I have tried it on a couple Swift packages and it worked well, as long as the package didn't import a bunch of C headers, which can sometimes vary for Bionic, or you didn't need to --enable-test-discovery when running swift test, which requires IndexStore added now.

Install the resulting deb package with dpkg -i debs/swift_5.1.4_aarch64.deb to make uninstalling the compiler with pkg uninstall swift easy later. I have not tried building with this pull on Android 7 or 8, let me know if you try it and that has any problems.

@ghost ghost merged commit 2a7dfda into termux:master Feb 17, 2020
ghost pushed a commit that referenced this pull request Feb 17, 2020
Currently it supports only on-device builds.
#4895

How to build:

 cp -a ./disabled-packages/swift ./packages/
 pkg install clang binutils-gold file patch python cmake ninja python2 perl rsync libandroid-spawn libcurl libicu libsqlite libuuid libxml2 llbuild pkg-config
 TERMUX_MAKE_PROCESSES=7 ./build-package.sh swift
@ghost
Copy link
Copy Markdown

ghost commented Feb 17, 2020

Moved to disabled-packages as can be built only on device.

@finagolfin
Copy link
Copy Markdown
Member Author

Thanks, I'll look into getting the compiler and stdlib cross-compiled next.

This pull request was closed.
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.

1 participant