<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 10 May 2016, at 04:11, Karl Wagner &lt;<a href="mailto:razielim@gmail.com" class="">razielim@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I’ve managed to cross-compile the swift tools for the Raspberry Pi from OSX.<div class=""><br class=""></div><div class="">I thought I’d share my changes. Branch is here: <a href="https://github.com/karwa/swift" class="">https://github.com/karwa/swift</a>. I’ll work on merging it soon.</div><div class=""><br class=""></div><div class="">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”.</div><div class=""><br class=""></div><div class="">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?</div><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">Invoke with:</div><div class=""><br class=""></div><div class=""><div class="">../swift/utils/build-script -R \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--llbuild \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--ios \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--installable-package=“${out_files}/swift-3.0" \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--install-destdir=“${out_files}/output" \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--install-symroot=“${out_files}/debug-output" \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>-- \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--llvm-install-components="clang;clang-headers;libclang;libclang-headers" \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--swift-install-components="compiler;stdlib;sdk-overlay;clang-builtin-headers;editor-integration;sourcekit-xpc-service" \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--darwin-toolchain-name="swift-3.0" \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--darwin_toolchain_display_name="local.swift.3" \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--darwin_toolchain_bundle_identifier="local.swift.3" \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--toolchain_prefix="swift3.xctoolchain" \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--darwin_toolchain_alias="local" \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--install-swift="1" \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--install-llbuild="1" \</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>--install-prefix="/usr" \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--cross-compile-tools-deployment-targets=linux-armv7 \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--cross-compile-sysroot="${sysroot}" \</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>--cross-compile-toolchain-bin="${toolchain}” \</div></div><div class=""><br class=""></div><div class="">where ${out_files} is going to end up like this:</div><div class=""><br class=""></div><div class="">— swift-3.0-macosx-x86_64.tar</div><div class="">— swift-3.0-linux-armv7.tar</div><div class="">— output/</div><div class="">&nbsp; &nbsp;| — macosx-x86_64/</div><div class="">&nbsp; &nbsp; &nbsp; | — swift3.xctoolchain/</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| — Info.plist</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| — usr/ (etc)</div><div class=""><div class="">&nbsp; &nbsp;| — linux-armv7/</div><div class="">&nbsp; &nbsp; &nbsp; | — usr/ (etc)</div></div><div class=""><br class=""></div><div class=""><div class="">${toolchain}:</div><div class=""><br class=""></div><div class="">Built from:&nbsp;<a href="https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major" class="">https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major</a></div><div class="">Edit install_toolchain.sh and add “--enable-gold” to the binutils flags</div><div class="">Also in install_common.sh, charged TARGET to "arm-linux-eabi”, but not sure that’s necessary.</div><div class="">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"</div><div class=""><br class=""></div><div class="">${sysroot}:</div><div class=""><br class=""></div><div class="">Created using this script. Requires dpkg-deb (can be installed with brew):&nbsp;<a href="https://gist.github.com/karwa/c73f9fd2768c96f6871be4aae152b264" class="">https://gist.github.com/karwa/c73f9fd2768c96f6871be4aae152b264</a></div><div class=""><div class=""><br class=""></div><div class="">./make_sysroot.py --distro debian --version jessie --arch armhf --install sysroot.armhf.debian.jessie</div><div class=""><br class=""></div><div class="">Let me know how it goes.</div><div class=""><br class=""></div><div class="">Karl</div><div class=""><br class=""></div></div></div></div></div></blockquote></div><br class=""><div class="">My apologies, the correct binutils target for the RPi is “arm-linux-gnueabihf”, not “arm-linux-eabi”, and you do have to change it before building the toolchain.</div><div class=""><br class=""></div><div class="">Karl</div></body></html>