{"id":13496698,"url":"https://github.com/uraimo/buildSwiftOnARM","last_synced_at":"2025-03-28T19:30:48.866Z","repository":{"id":139512668,"uuid":"76746207","full_name":"uraimo/buildSwiftOnARM","owner":"uraimo","description":"All you need to build Swift on a RaspberryPi or other ARM boards, updated to Swift 5.1.5","archived":false,"fork":false,"pushed_at":"2021-12-08T11:14:03.000Z","size":437,"stargazers_count":490,"open_issues_count":8,"forks_count":36,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-03-21T11:47:28.133Z","etag":null,"topics":["arm","debian","raspberrypi","raspbian","swift","ubuntu"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uraimo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-12-17T20:52:10.000Z","updated_at":"2025-02-24T11:32:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"acc0131d-51d3-426d-ac20-9db8f0faa2d6","html_url":"https://github.com/uraimo/buildSwiftOnARM","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uraimo%2FbuildSwiftOnARM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uraimo%2FbuildSwiftOnARM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uraimo%2FbuildSwiftOnARM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uraimo%2FbuildSwiftOnARM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uraimo","download_url":"https://codeload.github.com/uraimo/buildSwiftOnARM/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246088383,"owners_count":20721675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arm","debian","raspberrypi","raspbian","swift","ubuntu"],"created_at":"2024-07-31T19:01:57.271Z","updated_at":"2025-03-28T19:30:48.606Z","avatar_url":"https://github.com/uraimo.png","language":"Shell","readme":"\u003cp align=\"center\" style=\"margin-bottom:30px;\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/uraimo/buildSwiftOnARM/master/logo.svg?sanitize=true\"/\u003e\n\u003ci\u003eScripts to clone, configure, patch and build Swift 5.4 on Linux ARM devices.\u003c/i\u003e \n\u003c/p\u003e\n\n\n\nFor precompiled Swift 5.4 binaries see the *[Prebuilt binaries](#prebuilt-binaries)* section, if you want to build Swift on your own instead, check out the *[Building on ARM](#building-on-arm)* section and the step-by-step instructions.\n\n### Summary\n\n- [Supported Architectures](#supported-architectures)\n- [Prebuilt binaries](#prebuilt-binaries)\n- [Usage](#usage)\n    - [Dependencies](#dependencies) \n- [Building on ARM](#building-on-arm)\n    - [Step by step instructions](#step-by-step-instructions)\n    - [Setup your own build infrastructure](#setup-your-own-build-infrastructure)\n- [GitHub CI on ARM](#github-ci-on-arm)\n- [REPL Issues](#repl-issues)\n- [Acknowledgments](#acknowledgments) \n- [Previous Releases](#previous-releases)\n\n\n## Supported Architectures\n\n* ✅  ARMv6 32bit: _Original RaspberryPi, Pi Zero, etc..._\n* ✅  ARMv7/8 32bit: _All versions of RaspberryPi 2/3, OrangePi, ODroid, CHIP, etc..._\n* ✅  aarch64: _RaspberryPis or other ARMv8 boards with a 64 bit OS, Pine64, etc..._\n\n\n## Prebuilt binaries\n\n| OS | Architecture | Boards | Download |                                                                          \n| -- | ------------ | ------ | -------- |\n| Raspbian Buster | ARMv6 | All RaspberryPis: Classic, Zero, 2, 3, 4 | [5.4](https://github.com/uraimo/buildSwiftOnARM/releases/download/5.4/swift-5.4-armv6-RPi01234-RaspbianBuster.tgz) |\n| Raspbian Bullseye | ARMv6 | All RaspberryPis: Classic, Zero, 2, 3, 4 | [5.4]() |\n| Debian Buster | ARMv7 | Every ARMv7 board, RaspberryPis 2/3/4 included | [5.4]() |\n| Debian Bullseye | ARMv7 | Every ARMv7 board, RaspberryPis 2/3/4 included | [5.4]() |\n| Ubuntu 18.04 | ARMv7 | All versions of RaspberryPi 2/3/4, other ARMv7 boards | [5.4]() |\n| Ubuntu 20.04 | ARMv7 | All versions of RaspberryPi 2/3/4, other ARMv7 boards | [5.4]() |\n| Ubuntu 16.04/18.04 | aarch64 | All versions of RaspberryPi 3/4, other ARMv7 boards | 5.4.1: [swift-arm64](https://github.com/futurejones/swift-arm64/releases/tag/v5.4.1-RELEASE) |\n \nFor binaries of older releases, check out the [releases page](https://github.com/uraimo/buildSwiftOnARM/releases).\n\nFor alternative ways to install these Swift binaries on your ARM board, check out [Swift on Balena](https://github.com/wlisac/swift-on-balena/) by Will Lisac, Helge Heß's [dockSwiftOnARM](https://github.com/helje5/dockSwiftOnARM), both based on Docker, and the [Swift Deb Repository](https://swift-arm.com/install-swift/) maintained by Neil Jones.\n\nTo quickly cross-compile your Swift applications for ARM on a Mac (a time saver) check out the [Swift Cross Compilation Toolchains](https://github.com/CSCIX65G/SwiftCrossCompilers) project built by Van Simmons.\n\n## Usage\n\nWhen using the Swift Package Manager on one of these boards, that usually have limited memory/cpu, you'll need to use the new `-j` option to reduce the number of threads spawned by the tool and be able to compile.\nFor example, when building an SPM project most of the times we'll limit the number of jobs to one:\n\n```\n    pi@raspberrypi:\u003e swift build -j 1 \n```\n\n### Dependencies \n\nIn order to use the provided prebuilt binaries you'll need to install the following dependencies:\n\n**Raspbian Buster, Ubuntu 18.04 and newer**\n\n    sudo apt install clang libicu-dev libcurl4-nss-dev curl\n\nDecompress the archive on the RaspberryPi, you'll find the Swift binaries in `usr/bin/` relative to where you decompressed the archive.\n\n    tar -xzf \u003carchivename.tgz\u003e\n\nEnsure that the path you decompressed to is in your `PATH` environment variable: `echo $PATH`. If it's not then add it to your path for your shell.\n\n    PATH=\"$HOME/usr/bin:$PATH\"\n\nTo permanently add this to your `PATH` variable, you can add the following block of code to the end of your `~/.profile` file:\n\n    if [ -d \"$HOME/usr/bin\" ] ; then\n        PATH=\"$HOME/usr/bin:$PATH\"\n    fi\n\nVerify the swift version is setup: \n\n    $ swift --version\n    \n    Swift version 5.4 (swift-5.4-RELEASE)\n    Target: armv7-unknown-linux-gnueabihf\n\n\n\n## Building on ARM\n\nFor the latest updates on Swift on ARM, check out my blog [here](https://www.uraimo.com/category/raspberry/).\n\nCheck out Helge Heß's project [dockSwiftOnARM](https://github.com/helje5/dockSwiftOnARM) to build Swift in a Docker container or to [build a cross-compiling toolchain](https://github.com/AlwaysRightInstitute/swift-mac2arm-x-compile-toolchain) that will allow you to build arm binaries directly from your Mac using a precompiled swiftc for ARM.\n\nThe scripts that buildSwiftOnARM provides:\n\n- clone.sh - Install dependencies and clones the main Swift repository and all the related projects\n\n- checkoutRelease.sh - Resets all repos, updates them, checks out a specific tag (5.4 at the moment) and apply the patches.\n\n- build.sh - Builds Swift producing a tgz archive with the Swift distributions. \n\n- clean.sh - Cleans all build artifacts, only needed when you want to start again from scratch.\n\n\n\n### Step by step instructions\n\nFirst of all, use a suitably sized sd-card, at least 32Gb in size, but I recommend to use an external USB drive to clone the project and build Swift.\n\nConfigure a swap file of at least 2Gb, on Ubuntu:\n\n    sudo fallocate -l 2G swapfile\n    sudo chmod 600 swapfile\n    sudo mkswap swapfile\n    sudo swapon swapfile\n    \nYou'll need to manually enable the swap file with `swapon` *each time you reboot* the RaspberryPi (or the system will just run without swap).\n\nOn Raspbian, since the swapfile is already configured, open `/etc/dphys-swapfile` and edit `CONF_SWAPSIZE` to increase the size:\n\n    CONF_SWAPSIZE=2048\n    \nSave the file and:\n\n    sudo /etc/init.d/dphys-swapfile stop\n    sudo /etc/init.d/dphys-swapfile start\n    \nNow, call the included scripts as follows:\n\n1. Launch `clone.sh` that will install the required dependencies (_git cmake ninja-build clang-3.8 python uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config libblocksruntime-dev libcurl4-openssl-dev autoconf libtool systemtap-sdt-dev libcurl4-openssl-dev libz-dev_), fix clang links and clone apple/swift with all its dependecies.\n\n2. Run `checkoutRelease.sh` that will select the current release (5.4) and apply the needed patches.\n\n3. Once done, start the build with `build.sh`.\n\n4. Once the build completes a few hours later, you'll have a `swift-5.4-armv7.tgz` archive containing the whole Swift compiler distribution. Once decompressed you'll find the Swift binaries under `usr/bin`.\n\nI recommend to perform all these operations in a permanent background `tmux` or `screen` session (`CTRL+B d` to detach from the session and `tmux a` to reattach to it when you ssh again into the RaspberryPi).\n\nAdditional steps could be required in some cases [check the latest ARM posts on my blog for additional info](https://www.uraimo.com/category/raspberry/).\n\nTo build a different release than the one currently configured in the script, open `checkoutRelease.sh` and `build.sh` and modify the variables on top, with the branch name for the release and the release name for the tgz respectively.\n\n### Setup your own build infrastructure\n\nIf you need to replicate a setup like the one I use to build all the Swift binaries you can find above, using only a single Raspberry Pi 4 or a similar board ARMv7 board as build machine, check out [buildSwiftOnARMInfra](https://github.com/uraimo/buildSwiftOnARMInfra) with its docker containers.\n\n## GitHub CI on ARM\n\nARM projects can be tested in an environment simulated through QEMU on GitHub using the [Run-On-Architecture](https://github.com/uraimo/run-on-arch-action) action.\nWhile you will not be able to use hardware interfaces available on real ARM boards, this environment should be more than enough to perform some basic testing or even build your projects and deploy them directly to your target ARM board (with considerable time savings).\n\n## REPL Issues\n\nSince the first releases of Swift on ARM32, the REPL has never been available on this platform, but that doesn't impact the compiler itself. Considering this, as you would expect, launching `swift` without parameters will result in an error instead of the REPL prompt.\n\n## Acknowledgments \n\nWe wouldn't have Swift on ARM and most of the patches included on buildSwiftOnARM without the work done by these developers:\n\n * [@KittyMac](https://github.com/KittyMac)\n * [@buttaface](https://github.com/buttaface)\n * [@Kaiede](https://github.com/Kaiede)\n * [@chnmrc](https://github.com/chnmrc)\n * [@futurejones](https://github.com/futurejones)\n * [@jasonm128](https://github.com/jasonm128)\n * [@hpux735](https://twitter.com/hpux735)\n * [@iachievedit](https://twitter.com/iachievedit)\n \nThe community can be reached at the [swift-arm](https://launchpass.com/swift-arm) Slack channel.\n\n## Previous Releases\n\nYou can compile old releases checking out the specific tag:\n\n* [Swift 5.1.5](https://github.com/uraimo/buildSwiftOnARM/tree/5.1.5)\n* [Swift 5.1.3](https://github.com/uraimo/buildSwiftOnARM/tree/5.1.3)\n* [Swift 5.1.2](https://github.com/uraimo/buildSwiftOnARM/tree/5.1.2)\n* [Swift 5.1.1](https://github.com/uraimo/buildSwiftOnARM/tree/5.1.1)\n* [Swift 5.1](https://github.com/uraimo/buildSwiftOnARM/tree/5.1)\n* [Swift 5.0.3](https://github.com/uraimo/buildSwiftOnARM/tree/5.0.3)\n* [Swift 5.0.2](https://github.com/uraimo/buildSwiftOnARM/tree/5.0.2)\n* [Swift 5.0.1](https://github.com/uraimo/buildSwiftOnARM/tree/5.0.1)\n* [Swift 5.0](https://github.com/uraimo/buildSwiftOnARM/tree/5.0)\n* [Swift 4.2.3](https://github.com/uraimo/buildSwiftOnARM/tree/4.2.3)\n* [Swift 4.2.2](https://github.com/uraimo/buildSwiftOnARM/tree/4.2.2)\n* [Swift 4.2.1](https://github.com/uraimo/buildSwiftOnARM/tree/4.2.1)\n* [Swift 4.1.3](https://github.com/uraimo/buildSwiftOnARM/tree/4.1.3)\n* [Swift 3.1.1](https://github.com/uraimo/buildSwiftOnARM/tree/3.1.1)\n* [Swift 3.1](https://github.com/uraimo/buildSwiftOnARM/tree/3.1)\n* [Swift 3.0.2](https://github.com/uraimo/buildSwiftOnARM/tree/3.0.2)\n\n","funding_links":[],"categories":["Shell","Resources","Single Board Computers"],"sub_categories":["Swift programming"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furaimo%2FbuildSwiftOnARM","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furaimo%2FbuildSwiftOnARM","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furaimo%2FbuildSwiftOnARM/lists"}