Skip to content

Commit

Permalink
Merge pull request #9 from colemancda/feature/5.10
Browse files Browse the repository at this point in the history
Update to Swift 5.10
  • Loading branch information
colemancda authored Apr 5, 2024
2 parents 2558c03 + 58f2df9 commit a9586bf
Show file tree
Hide file tree
Showing 29 changed files with 298 additions and 472 deletions.
115 changes: 1 addition & 114 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:bullseye
FROM swift:5.10-jammy

# Install zsh
ARG INSTALL_ZSH="true"
Expand All @@ -14,116 +14,3 @@ COPY library-scripts/common-debian.sh /tmp/library-scripts/
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/library-scripts

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="lts/*"
ENV NVM_DIR=/usr/local/share/nvm
ENV NVM_SYMLINK_CURRENT=true \
PATH=${NVM_DIR}/current/bin:${PATH}
COPY library-scripts/node-debian.sh /tmp/library-scripts/
RUN bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}" \
&& rm -rf /var/lib/apt/lists/* /tmp/library-scripts

# Install dependencies
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true && \
dpkg --add-architecture armhf && \
apt-get -q update && \
apt-get -q install -y \
qemu-user-static \
ninja-build \
wget \
curl \
build-essential \
bash \
bc \
binutils \
bzip2 \
cpio \
g++ \
gcc \
git \
gzip \
libncurses5-dev \
make \
mercurial \
whois \
patch \
perl \
python3 \
rsync \
sed \
tar \
unzip \
cmake \
gnupg \
gnupg2 \
libc6-dev \
libcurl4-openssl-dev \
libedit2 \
libgcc-9-dev \
libpython3.9 \
libsqlite3-0 \
libstdc++-9-dev \
libxml2-dev \
libz3-dev \
pkg-config \
tzdata \
zlib1g-dev \
libc6:armhf \
libatomic1:armhf \
libedit2:armhf \
libgcc-9-dev-armhf-cross \
libpython3.9:armhf \
libsqlite3-0:armhf \
libstdc++6-armhf-cross \
libxml2:armhf \
zlib1g:armhf \
&& rm -r /var/lib/apt/lists/*

ARG SWIFT_SIGNING_KEY=A62AE125BBBFBB96A6E042EC925CC1CCED3D1561
ARG SWIFT_PLATFORM=ubuntu20.04
ARG SWIFT_BRANCH=swift-5.7.1-release
ARG SWIFT_VERSION=swift-5.7.1-RELEASE
ARG SWIFT_WEBROOT=https://download.swift.org

ENV SWIFT_SIGNING_KEY=$SWIFT_SIGNING_KEY \
SWIFT_PLATFORM=$SWIFT_PLATFORM \
SWIFT_BRANCH=$SWIFT_BRANCH \
SWIFT_VERSION=$SWIFT_VERSION \
SWIFT_WEBROOT=$SWIFT_WEBROOT

RUN set -e; \
ARCH_NAME="$(dpkg --print-architecture)"; \
url=; \
case "${ARCH_NAME##*-}" in \
'amd64') \
OS_ARCH_SUFFIX=''; \
;; \
'arm64') \
OS_ARCH_SUFFIX='-aarch64'; \
;; \
*) echo >&2 "error: unsupported architecture: '$ARCH_NAME'"; exit 1 ;; \
esac; \
SWIFT_WEBDIR="$SWIFT_WEBROOT/$SWIFT_BRANCH/$(echo $SWIFT_PLATFORM | tr -d .)$OS_ARCH_SUFFIX" \
&& SWIFT_BIN_URL="$SWIFT_WEBDIR/$SWIFT_VERSION/$SWIFT_VERSION-$SWIFT_PLATFORM$OS_ARCH_SUFFIX.tar.gz" \
&& SWIFT_SIG_URL="$SWIFT_BIN_URL.sig" \
# - Download the GPG keys, Swift toolchain, and toolchain signature, and verify.
&& export GNUPGHOME="$(mktemp -d)" \
&& curl -fsSL "$SWIFT_BIN_URL" -o swift.tar.gz "$SWIFT_SIG_URL" -o swift.tar.gz.sig \
&& gpg --batch --quiet --keyserver keyserver.ubuntu.com --recv-keys "$SWIFT_SIGNING_KEY" \
&& gpg --batch --verify swift.tar.gz.sig swift.tar.gz \
# - Unpack the toolchain, set libs permissions, and clean up.
&& tar -xzf swift.tar.gz --directory / --strip-components=1 \
&& chmod -R o+r /usr/lib/swift \
&& rm -rf "$GNUPGHOME" swift.tar.gz.sig swift.tar.gz

# Print Installed Swift Version
RUN swift --version

# Set environment
WORKDIR /workspaces/swift-armv7
ENV SRC_ROOT=/workspaces/swift-armv7

# Create symbolic links
RUN ln -s /workspaces/swift-armv7/build/swift-linux-armv7/bin/swift-def-to-yaml-converter /usr/bin/swift-def-to-yaml-converter && \
ln -s /workspaces/swift-armv7/build/swift-linux-armv7/bin/swift-serialize-diagnostics /usr/bin/swift-serialize-diagnostics
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dockerfile": "Dockerfile",
"args": {
// Update the VARIANT arg to pick a Swift version
"VARIANT": "5.7.1-jammy",
"VARIANT": "5.10-jammy",
// Options
"NODE_VERSION": "lts/*",
"UPGRADE_PACKAGES": "true"
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/library-scripts/common-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then
sed -i "s/deb-src http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main contrib non-free/" /etc/apt/sources.list
sed -i "s/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main contrib non-free/" /etc/apt/sources.list
sed -i "s/deb-src http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main contrib non-free/" /etc/apt/sources.list
# Handle bullseye location for security https://www.debian.org/releases/bullseye/amd64/release-notes/ch-information.en.html
# Handle bookworm location for security https://www.debian.org/releases/bookworm/amd64/release-notes/ch-information.en.html
sed -i "s/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main contrib non-free/" /etc/apt/sources.list
sed -i "s/deb-src http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main contrib non-free/" /etc/apt/sources.list
echo "Running apt-get update..."
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ jobs:
- name: Build
run: |
export SRC_ROOT=$GITHUB_WORKSPACE
rm -rf /usr/bin/swift-def-to-yaml-converter
ln -s $SRC_ROOT/build/swift-linux-armv7/bin/swift-def-to-yaml-converter /usr/bin/swift-def-to-yaml-converter
rm -rf /usr/bin/swift-serialize-diagnostics
ln -s $SRC_ROOT/build/swift-linux-armv7/bin/swift-serialize-diagnostics /usr/bin/swift-serialize-diagnostics
./build.sh
- name: Archive Swift Build artifacts
uses: actions/upload-artifact@v3
Expand Down
15 changes: 1 addition & 14 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: |
export SRC_ROOT=$GITHUB_WORKSPACE
export DOWNLOAD_FILE=$SRC_ROOT/build/swift-armv7.tar.gz
export TAR_URL=https://github.com/colemancda/swift-armv7/releases/download/0.5.1/swift-armv7.tar.gz
export TAR_URL=https://github.com/colemancda/swift-armv7/releases/download/0.6.0/swift-armv7.tar.gz
mkdir -p $SRC_ROOT/build
wget -q $TAR_URL -O $DOWNLOAD_FILE
- name: Build Docker image
Expand Down Expand Up @@ -115,16 +115,3 @@ jobs:
run: |
chmod +x /tmp/swift-hello
/tmp/swift-hello
build-armv7:
name: Build on Linux Armv7
runs-on: [self-hosted, Linux, ARM]
container: colemancda/swift-armv7:latest-runtime
needs: push_runtime
steps:
- name: Check out GitHub repo
uses: actions/checkout@v2
- name: Build and run
run: |
cd swift-hello
swift run
14 changes: 1 addition & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: |
export SRC_ROOT=$GITHUB_WORKSPACE
export DOWNLOAD_FILE=$SRC_ROOT/build/swift-armv7.tar.gz
export TAR_URL=https://github.com/colemancda/swift-armv7/releases/download/0.5.1/swift-armv7.tar.gz
export TAR_URL=https://github.com/colemancda/swift-armv7/releases/download/0.6.0/swift-armv7.tar.gz
mkdir -p $SRC_ROOT/build
mkdir -p $SRC_ROOT/build/swift-linux-armv7-install
wget -q $TAR_URL -O $DOWNLOAD_FILE
Expand Down Expand Up @@ -73,15 +73,3 @@ jobs:
run: |
chmod +x /tmp/swift-hello
/tmp/swift-hello
build-armv7:
name: Build on Linux Armv7
runs-on: [self-hosted, Linux, ARM]
container: colemancda/swift-armv7:latest-runtime
steps:
- name: Check out GitHub repo
uses: actions/checkout@v2
- name: Build and run
run: |
cd swift-hello
swift run
18 changes: 0 additions & 18 deletions .gitlab-ci.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM swift:5.7.1-jammy
FROM swift:5.10-jammy

# Install needed packages and setup non-root user.
ARG USERNAME=vscode
Expand Down Expand Up @@ -72,7 +72,7 @@ ENV SRC_ROOT=/usr/src/swift-armv7
RUN cd $SRC_ROOT && \
$SRC_ROOT/generate-swiftpm-toolchain.sh

# Fetch Debian 11 armhf sysroot and Swift runtime
# Fetch Debian 12 armhf sysroot and Swift runtime
RUN cd $SRC_ROOT && \
export DOWNLOAD_SWIFT_RUNTIME=1 && \
$SRC_ROOT/fetch-binaries.sh && \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export SWIFT_PACKAGE_SRCDIR=/home/user/Developer/MySwiftPackage
```
./generate-xcode-toolchain.sh
export SWIFT_PACKAGE_SRCDIR=/home/user/Developer/MySwiftPackage
export SWIFT_NATIVE_PATH=/tmp/cross-toolchain/debian-bullseye.sdk
export SWIFT_NATIVE_PATH=/tmp/cross-toolchain/debian-bookworm.sdk
./build-swift-package.sh
```

Expand Down
36 changes: 36 additions & 0 deletions build-dispatch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
set -e
source swift-define

echo "Create Dispatch build folder ${SWIFT_BUILDDIR}"
mkdir -p $LIBDISPATCH_BUILDDIR
mkdir -p $LIBDISPATCH_INSTALL_PREFIX

echo "Configure Dispatch"
rm -rf $LIBDISPATCH_BUILDDIR/CMakeCache.txt
LIBS="-latomic" cmake -S $LIBDISPATCH_SRCDIR -B $LIBDISPATCH_BUILDDIR -G Ninja \
-DCMAKE_INSTALL_PREFIX=${LIBDISPATCH_INSTALL_PREFIX} \
-DBUILD_TESTING=OFF \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=${SWIFT_BUILD_CONFIGURATION} \
-DCMAKE_C_COMPILER=${SWIFT_NATIVE_PATH}/clang \
-DCMAKE_CXX_COMPILER=${SWIFT_NATIVE_PATH}/clang++ \
-DCMAKE_C_FLAGS="${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" \
-DCMAKE_CXX_FLAGS="${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" \
-DCMAKE_C_LINK_FLAGS="${LINK_FLAGS}" \
-DCMAKE_CXX_LINK_FLAGS="${LINK_FLAGS}" \
-DENABLE_SWIFT=YES \
-DCMAKE_Swift_FLAGS="${SWIFTC_FLAGS}" \
-DCMAKE_Swift_FLAGS_DEBUG="" \
-DCMAKE_Swift_FLAGS_RELEASE="" \
-DCMAKE_Swift_FLAGS_RELWITHDEBINFO="" \

echo "Build Dispatch"
(cd $LIBDISPATCH_BUILDDIR && ninja)

echo "Install Dispatch"
(cd $LIBDISPATCH_BUILDDIR && ninja install)

echo "Install to Debian sysroot"
mv ${LIBDISPATCH_INSTALL_PREFIX}/lib/swift/linux/"$(uname -m)" ${LIBDISPATCH_INSTALL_PREFIX}/lib/swift/linux/armv7
cp -rf ${LIBDISPATCH_INSTALL_PREFIX}/* ${STAGING_DIR}/usr/
51 changes: 51 additions & 0 deletions build-foundation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
set -e
source swift-define

echo "Create Foundation build folder ${FOUNDATION_BUILDDIR}"
mkdir -p $FOUNDATION_BUILDDIR
mkdir -p $FOUNDATION_INSTALL_PREFIX

# Workaround Dispatch defined with cmake and module
rm -rf ${STAGING_DIR}/usr/lib/swift/dispatch

echo "Configure Foundation"
rm -rf $FOUNDATION_BUILDDIR/CMakeCache.txt
LIBS="-latomic" cmake -S $FOUNDATION_SRCDIR -B $FOUNDATION_BUILDDIR -G Ninja \
-DCMAKE_INSTALL_PREFIX=${FOUNDATION_INSTALL_PREFIX} \
-DBUILD_TESTING=OFF \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=${SWIFT_BUILD_CONFIGURATION} \
-DCMAKE_C_COMPILER=${SWIFT_NATIVE_PATH}/clang \
-DCMAKE_CXX_COMPILER=${SWIFT_NATIVE_PATH}/clang++ \
-DCMAKE_C_FLAGS="${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" \
-DCMAKE_CXX_FLAGS="${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" \
-DCMAKE_C_LINK_FLAGS="${LINK_FLAGS}" \
-DCMAKE_CXX_LINK_FLAGS="${LINK_FLAGS}" \
-DCMAKE_ASM_FLAGS="${ASM_FLAGS}" \
-DCF_DEPLOYMENT_SWIFT=ON \
-Ddispatch_DIR="${LIBDISPATCH_BUILDDIR}/cmake/modules" \
-DLIBXML2_LIBRARY=${STAGING_DIR}/usr/lib/arm-linux-gnueabihf/libxml2.so \
-DLIBXML2_INCLUDE_DIR=${STAGING_DIR}/usr/include/libxml2 \
-DCURL_LIBRARY_RELEASE=${STAGING_DIR}/usr/lib/arm-linux-gnueabihf/libcurl.so \
-DCURL_INCLUDE_DIR="${STAGING_DIR}/usr/include" \
-DICU_I18N_LIBRARY_RELEASE=${STAGING_DIR}/usr/lib/arm-linux-gnueabihf/libicui18n.so \
-DICU_UC_LIBRARY_RELEASE=${STAGING_DIR}/usr/lib/arm-linux-gnueabihf/libicuuc.so \
-DICU_INCLUDE_DIR="${STAGING_DIR}/usr/include" \
-DCMAKE_Swift_FLAGS="${SWIFTC_FLAGS}" \
-DCMAKE_Swift_FLAGS_DEBUG="" \
-DCMAKE_Swift_FLAGS_RELEASE="" \
-DCMAKE_Swift_FLAGS_RELWITHDEBINFO="" \

echo "Build Foundation"
(cd $FOUNDATION_BUILDDIR && ninja)

echo "Install Foundation"
(cd $FOUNDATION_BUILDDIR && ninja install)

# Restore Dispatch headers
cp -rf ${LIBDISPATCH_INSTALL_PREFIX}/* ${STAGING_DIR}/usr/

echo "Install to Debian sysroot"
mv ${FOUNDATION_INSTALL_PREFIX}/lib/swift/linux/"$(uname -m)" ${FOUNDATION_INSTALL_PREFIX}/lib/swift/linux/armv7
cp -rf ${FOUNDATION_INSTALL_PREFIX}/* ${STAGING_DIR}/usr/
28 changes: 13 additions & 15 deletions build-llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@ source swift-define

echo "Create LLVM build folder ${LLVM_BUILDDIR}"
mkdir -p $LLVM_BUILDDIR
mkdir -p $LLVM_INSTALL_PREFIX

echo "Configure LLVM"
cd $LLVM_BUILDDIR
cmake -S $LLVM_SRCDIR/llvm -B $LLVM_BUILDDIR -G Ninja \
-DCMAKE_INSTALL_PREFIX=${LLVM_INSTALL_PREFIX} \
-DCMAKE_C_COMPILER=$SWIFT_NATIVE_PATH/clang \
-DCMAKE_CXX_COMPILER=$SWIFT_NATIVE_PATH/clang++ \
-DLLVM_ENABLE_PROJECTS="llvm" \
-DCMAKE_BUILD_TYPE=Release

echo "Build LLVM"
cd $SWIFT_SRCDIR
export SKIP_XCODE_VERSION_CHECK=1
export SWIFT_NATIVE_SWIFT_TOOLS_PATH=$SWIFT_NATIVE_PATH
export SWIFT_NATIVE_CLANG_TOOLS_PATH=$SWIFT_NATIVE_PATH
export CC=$SWIFT_NATIVE_PATH/clang
export CFLAGS="-fPIC"
(cd $LLVM_BUILDDIR && ninja)

./utils/build-script -RA --build-swift-tools=0 \
--skip-early-swift-driver --skip-build-llvm --skip-build-cmark \
--native-swift-tools-path=$SWIFT_NATIVE_PATH \
--native-clang-tools-path=$SWIFT_NATIVE_PATH \
--swift-install-components='clang-resource-dir-symlink;license;stdlib;sdk-overlay' \
--install-swift \
--cross-compile-append-host-target-to-destdir=False --build-swift-dynamic-stdlib \
--build-dir=$SRC_ROOT/build \
--workspace=$SRC_ROOT/downloads \
echo "Install LLVM"
(cd $LLVM_BUILDDIR && ninja install)
Loading

0 comments on commit a9586bf

Please sign in to comment.