未加星标

Swift 3.0.2 For Raspberry Pi Zero/1/2/3

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二04 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

I’ve finally got around to building the latest Swift release (3.0.2, distributed with XCode8.2.1) for all the Raspberry Pi boards.

The ARMv6 version that runs on the original RaspberryPi (A,B,A+,B+) and the Zero, requires the latest Raspbian released on November 2016. This version does not have a working Swift Package Manager at the moment, so for now you’ll have to do without it. Get it here .

The ARMv7 version that runs on both the RaspberryPi 2 and 3 requires Ubuntu 16.04 and you can get it here .

A Few Notes On Compiling For The Original Raspberry (ARMv6)

Currently Swift requires a few patches to compile on ARM boards that are collected and kept up to date in the repositories of swift-arm by William Dillon .

Building for the original Raspberry Pi and the Zero requires an additional small patch and a few manual steps.

I’ve created a repository that contains the scripts I’ve used to clone, patch and build Swift (derived from package-swift ) for those who want to replicate what I did.

Building on the original Raspberry using the release of Raspbian from November will require a slightly different set of packages:

sudo apt-get install git cmake ninja-build clang-3.7 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 libkqueue-dev

Luckily Clang 3.7 is now available from the official Raspbian repository and the only additional package we need is libkqueue-dev .

Since SPM does not work at the moment, we don’t need to build that project, so its build option can be omitted from the build command:

./swift/utils/build-script --build-subdir mybuild_linux -R --lldb --llbuild --xctest --foundation --libdispatch -- --install-libdispatch --install-foundation --install-swift --install-lldb --install-llbuild --install-xctest --install-prefix=/usr '--swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;dev' --build-swift-static-stdlib --build-swift-static-sdk-overlay --install-destdir=${INSTALL_DIR} --installable-package=${PACKAGE} --verbose-build

Once we have cloned the main repository and all the repositories for the subprojects, that command will start the build.

The build will fail near the end of the compilation of the swift-linux-armv6 directory with this error:

FAILED: cd /home/pi/buildswift/build/mybuild_linux/swift-linux-armv6/stdlib/public/Platform && /usr/lo cal/bin/cmake -E make_directory /home/pi/buildswift/build/mybuild_linux/swift-linux-armv6/stdlib/public/Pl atform/linux/armv6 && /usr/local/bin/cmake -E make_directory /home/pi/buildswift/build/mybuild_linux/swift -linux-armv6/./lib/swift/linux/armv6 && /home/pi/buildswift/swift/utils/line-directive /home/pi/buildswift/ swift/stdlib/public/Platform/Glibc.swift /home/pi/buildswift/swift/stdlib/public/Platform/Platform.swift /h ome/pi/buildswift/swift/stdlib/public/Platform/TiocConstants.swift /home/pi/buildswift/build/mybuild_linux /swift-linux-armv6/stdlib/public/Platform/4/tgmath.swift -- /home/pi/buildswift/build/mybuild_linux/swift- linux-armv6/./bin/swiftc -c -sdk / -target armv6-unknown-linux-gnueabihf -resource-dir /home/pi/buildswift/ build/mybuild_linux/swift-linux-armv6/./lib/swift -O -D INTERNAL_CHECKS_ENABLED -I /home/pi/buildswift/bui ld/mybuild_linux/swift-linux-armv6/./lib/swift/linux/armv6 -module-cache-path /home/pi/buildswift/build/bu ildbot_linux/swift-linux-armv6/./module-cache -no-link-objc-runtime -autolink-force-load -module-link-name swiftGlibc -force-single-frontend-invocation -parse-as-library -emit-module -emit-module-path /home/pi/buil dswift/build/mybuild_linux/swift-linux-armv6/./lib/swift/linux/armv6/Glibc.swiftmodule -o /home/pi/buildsw ift/build/mybuild_linux/swift-linux-armv6/stdlib/public/Platform/linux/armv6/Glibc.o /home/pi/buildswift/s wift/stdlib/public/Platform/Glibc.swift /home/pi/buildswift/swift/stdlib/public/Platform/Platform.swift /ho me/pi/buildswift/swift/stdlib/public/Platform/TiocConstants.swift /home/pi/buildswift/build/mybuild_linux/ swift-linux-armv6/stdlib/public/Platform/4/tgmath.swift /home/pi/buildswift/swift/stdlib/public/Platform/Glibc.swift:13:19: error: no such module 'SwiftGlibc' @_exported import SwiftGlibc // Clang module ^ ninja: build stopped: subcommand failed.

To get past this point, go to build/mybuild_linux/swift-linux-armv6 and complete manually the creation of the SwiftGlibc module using:

ninja swiftGlibc-linux-armv6-static

Once this is done, you can go back to the root and launch again the build command. Nothing else was needed for 3.0.2, future releases will likely need further adjustments.

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: SwiftRaspberry PiUbuntu
分页:12
转载请注明
本文标题:Swift 3.0.2 For Raspberry Pi Zero/1/2/3
本站链接:http://www.codesec.net/view/520209.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(19)