(Cross-)Compiling Swift for Raspberry PI

前端 未结 2 586
猫巷女王i
猫巷女王i 2021-01-31 19:25

Swift is now Open Source. Did anyone tried compiling Swift for a Raspberry PI? I started to do, but my 8 GB SD card seems to be too small for it ;) Is it possible to cross compi

2条回答
  •  灰色年华
    2021-01-31 19:59

    The Swift Package Manager got custom toolchain support via PR-1098 end of April 2017.

    I wrote up detailed instructions on how to build a RaspberryPi toolchain over here: macOS -> RasPi Cross Compilation Toolchain and even the reverse (build macOS binaries on a RaspberryPi) for the fun of it. The same would work for Intel-Linux to ARM-Linux w/ minimal modifications. The SwiftPM repo contains an example script on how to do this for Intel-macOS to Intel-Ubuntu.

    You can find a 2017-05-01 update on Swift-on-ARM over here: An Update on Swift 3.1.1 For Raspberry Pi Zero/1/2/3.

    As a small summary, so that this answer isn't just links ;-), ARM status 2017-05-16:

    • you can compile Swift 3.1/3.1.1 on RaspberryPi Ubuntu
      • don't forget to setup swap, some minimal patches are required for 3.1.1. 8GB disk may be a bit to little.
    • compilation on Raspbian doesn't seem to work yet (last known version is 3.0.2)
    • you can cross-compile Swift using a custom toolchain, which is reasonably easy to setup
      • you need to grab a SwiftPM snapshot (Swift 4) for this (but the toolchain itself can be 3.1 or even 3.0.2 w/ minor changes)
    • you can also run (and compile) Swift via Docker, e.g. in HypriotOS.
    • there is a Slack group for Swift ARM: swift-arm

提交回复
热议问题