[swift-dev] Cross-compiling (nearly) everything for RPi from OSX
Karl Wagner
razielim at gmail.com
Mon May 9 21:11:40 CDT 2016
I’ve managed to cross-compile the swift tools for the Raspberry Pi from OSX.
I thought I’d share my changes. Branch is here: https://github.com/karwa/swift <https://github.com/karwa/swift>. I’ll work on merging it soon.
The only real change we need is a bit more structure to the install locations. I want to install to a deployment-target specific subdirectory within INSTALL_DESTDIR. We need that if we have multiple sets of tools to install and packages to build. Installable-package also gets appended with the deployment target and “.tar”.
Does anybody (or any bots) install directly from the build script? Would it be a lot of trouble to give install-destdir and install-symroot a bit of structure?
clang, swift, stdlib, the GlibC overlay all work (although I still need to add a step which regenerates glibc.modulemap - right now you’ll have to find/replace to take your sysroot out of it). LLBuild works. Foundation doesn’t cross-compile just yet, but I built it natively with the resulting swift compiler and clang. The problem seems to be fixable by tweaking the clang headers inside of lib/swift, so I’m not sure if maybe my system headers are a bit wonky. Swiftpm depends on Foundation, and LLDB was having some trouble finding libraries for python.
Invoke with:
../swift/utils/build-script -R \
--llbuild \
--ios \
--installable-package=“${out_files}/swift-3.0" \
--install-destdir=“${out_files}/output" \
--install-symroot=“${out_files}/debug-output" \
-- \
--llvm-install-components="clang;clang-headers;libclang;libclang-headers" \
--swift-install-components="compiler;stdlib;sdk-overlay;clang-builtin-headers;editor-integration;sourcekit-xpc-service" \
--darwin-toolchain-name="swift-3.0" \
--darwin_toolchain_display_name="local.swift.3" \
--darwin_toolchain_bundle_identifier="local.swift.3" \
--toolchain_prefix="swift3.xctoolchain" \
--darwin_toolchain_alias="local" \
--install-swift="1" \
--install-llbuild="1" \
--install-prefix="/usr" \
--cross-compile-tools-deployment-targets=linux-armv7 \
--cross-compile-sysroot="${sysroot}" \
--cross-compile-toolchain-bin="${toolchain}” \
where ${out_files} is going to end up like this:
— swift-3.0-macosx-x86_64.tar
— swift-3.0-linux-armv7.tar
— output/
| — macosx-x86_64/
| — swift3.xctoolchain/
| — Info.plist
| — usr/ (etc)
| — linux-armv7/
| — usr/ (etc)
${toolchain}:
Built from: https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major <https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major>
Edit install_toolchain.sh and add “--enable-gold” to the binutils flags
Also in install_common.sh, charged TARGET to "arm-linux-eabi”, but not sure that’s necessary.
Give the path to the unprefixed versions of the tools, e.g: “/cc-toolchain/gcc-arm-none-eabi-5_2-2015q4/install-native/arm-linux-eabi/bin"
${sysroot}:
Created using this script. Requires dpkg-deb (can be installed with brew): https://gist.github.com/karwa/c73f9fd2768c96f6871be4aae152b264 <https://gist.github.com/karwa/c73f9fd2768c96f6871be4aae152b264>
./make_sysroot.py --distro debian --version jessie --arch armhf --install sysroot.armhf.debian.jessie
Let me know how it goes.
Karl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160510/58bd64a2/attachment.html>
More information about the swift-dev
mailing list