From 941d30fdca79ad57e5ac1ebf5a12f5fbce967008 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Tue, 24 Dec 2024 15:19:08 -0500 Subject: [PATCH 01/27] Add support for building armv6 - Apprently the same sysroot is used for building for armv6? --- build-dispatch.sh | 2 +- build-foundation.sh | 6 +++--- build-in-container.sh | 1 + build-linux-cross-sdk.sh | 4 ++-- build-swift-testing.sh | 4 ++-- build-xctest.sh | 2 +- swift-define | 18 +++++++++++++++--- 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/build-dispatch.sh b/build-dispatch.sh index aa9f58a..dd497f6 100755 --- a/build-dispatch.sh +++ b/build-dispatch.sh @@ -33,5 +33,5 @@ echo "Install Dispatch" (cd $LIBDISPATCH_BUILDDIR && ninja install) echo "Install Dispatch to sysroot" -mv ${LIBDISPATCH_INSTALL_PREFIX}/lib/swift/linux/"$(uname -m)"/ ${LIBDISPATCH_INSTALL_PREFIX}/lib/swift/linux/armv7/ +mv ${LIBDISPATCH_INSTALL_PREFIX}/lib/swift/linux/"$(uname -m)"/ ${LIBDISPATCH_INSTALL_PREFIX}/lib/swift/linux/${SWIFT_TARGET_ARCH}/ cp -rf ${LIBDISPATCH_INSTALL_PREFIX}/* ${STAGING_DIR}/usr/ diff --git a/build-foundation.sh b/build-foundation.sh index 114c892..7b5da00 100755 --- a/build-foundation.sh +++ b/build-foundation.sh @@ -49,8 +49,8 @@ echo "Install Foundation" (cd $FOUNDATION_BUILDDIR && ninja install) echo "Fix-up archs" -find ${FOUNDATION_INSTALL_PREFIX}/lib/swift/linux -name "x86_64*.swiftmodule" -execdir mv {} armv7-unknown-linux-gnueabihf.swiftmodule \; -find ${FOUNDATION_INSTALL_PREFIX}/lib/swift/linux -name "x86_64*.swiftdoc" -execdir mv {} armv7-unknown-linux-gnueabihf.swiftdoc \; +find ${FOUNDATION_INSTALL_PREFIX}/lib/swift/linux -name "x86_64*.swiftmodule" -execdir mv {} ${SWIFT_TARGET_ARCH}-unknown-linux-gnueabihf.swiftmodule \; +find ${FOUNDATION_INSTALL_PREFIX}/lib/swift/linux -name "x86_64*.swiftdoc" -execdir mv {} ${SWIFT_TARGET_ARCH}-unknown-linux-gnueabihf.swiftdoc \; # Restore Dispatch headers cp -rf ${LIBDISPATCH_INSTALL_PREFIX}/* ${STAGING_DIR}/usr/ @@ -58,6 +58,6 @@ cp -rf ${LIBDISPATCH_INSTALL_PREFIX}/* ${STAGING_DIR}/usr/ echo "Install Foundation into sysroot" FOUNDATION_MODULES_DIR=${FOUNDATION_INSTALL_PREFIX}/lib/swift/linux/"$(uname -m)" if [ -d $FOUNDATION_MODULES_DIR ]; then - mv ${FOUNDATION_MODULES_DIR} ${FOUNDATION_INSTALL_PREFIX}/lib/swift/linux/armv7 + mv ${FOUNDATION_MODULES_DIR} ${FOUNDATION_INSTALL_PREFIX}/lib/swift/linux/${SWIFT_TARGET_ARCH} fi cp -rf ${FOUNDATION_INSTALL_PREFIX}/* ${STAGING_DIR}/usr/ diff --git a/build-in-container.sh b/build-in-container.sh index 29238ff..ab7aa61 100755 --- a/build-in-container.sh +++ b/build-in-container.sh @@ -16,5 +16,6 @@ docker run \ -e SWIFT_VERSION=${SWIFT_TAG} \ -e STAGING_DIR=${STAGING_DIR} \ -e INSTALL_TAR=${INSTALL_TAG} \ + -e SWIFT_TARGET_ARCH=${SWIFT_TARGET_ARCH} \ ${DOCKER_TAG} \ ./build.sh diff --git a/build-linux-cross-sdk.sh b/build-linux-cross-sdk.sh index 81761bb..a274c0c 100755 --- a/build-linux-cross-sdk.sh +++ b/build-linux-cross-sdk.sh @@ -4,8 +4,8 @@ set -e SRC_ROOT=$(pwd) ARTIFACTS_DIR=$SRC_ROOT/artifacts -TARGET_TRIPLE=armv7-unknown-linux-gnueabihf -TARGET_ARCH=armv7 +TARGET_ARCH=${TARGET_ARCH:=armv7} +TARGET_TRIPLE=${TARGET_ARCH}-unknown-linux-gnueabihf function print_usage() { echo "$0 " diff --git a/build-swift-testing.sh b/build-swift-testing.sh index 07e329b..c30e52c 100755 --- a/build-swift-testing.sh +++ b/build-swift-testing.sh @@ -34,8 +34,8 @@ echo "Install swift-testing" (cd $SWIFT_TESTING_BUILDDIR && ninja install) echo "Fix-up archs" -find ${SWIFT_TESTING_INSTALL_PREFIX}/lib/swift/linux -name "x86_64*.swiftmodule" -execdir mv {} armv7-unknown-linux-gnueabihf.swiftmodule \; -find ${SWIFT_TESTING_INSTALL_PREFIX}/lib/swift/linux -name "x86_64*.swiftdoc" -execdir mv {} armv7-unknown-linux-gnueabihf.swiftdoc \; +find ${SWIFT_TESTING_INSTALL_PREFIX}/lib/swift/linux -name "x86_64*.swiftmodule" -execdir mv {} ${SWIFT_TARGET_ARCH}-unknown-linux-gnueabihf.swiftmodule \; +find ${SWIFT_TESTING_INSTALL_PREFIX}/lib/swift/linux -name "x86_64*.swiftdoc" -execdir mv {} ${SWIFT_TARGET_ARCH}-unknown-linux-gnueabihf.swiftdoc \; echo "Install swift-testing to sysroot" cp -rf ${SWIFT_TESTING_INSTALL_PREFIX}/* ${STAGING_DIR}/usr/ diff --git a/build-xctest.sh b/build-xctest.sh index 2b814e3..ca35ff1 100755 --- a/build-xctest.sh +++ b/build-xctest.sh @@ -41,5 +41,5 @@ echo "Install XCTest" cp -rf ${LIBDISPATCH_INSTALL_PREFIX}/* ${STAGING_DIR}/usr/ echo "Install XCTest to sysroot" -mv ${XCTEST_INSTALL_PREFIX}/lib/swift/linux/"$(uname -m)" ${XCTEST_INSTALL_PREFIX}/lib/swift/linux/armv7 +mv ${XCTEST_INSTALL_PREFIX}/lib/swift/linux/"$(uname -m)" ${XCTEST_INSTALL_PREFIX}/lib/swift/linux/${SWIFT_TARGET_ARCH} cp -rf ${XCTEST_INSTALL_PREFIX}/* ${STAGING_DIR}/usr/ diff --git a/swift-define b/swift-define index 9ae5478..6ebdd4d 100644 --- a/swift-define +++ b/swift-define @@ -1,7 +1,20 @@ # Version SWIFT_VERSION=${SWIFT_VERSION:=swift-6.0.3-RELEASE} -SWIFT_TARGET_ARCH=armv7 -SWIFT_TARGET_NAME=armv7-unknown-linux-gnueabihf +SWIFT_TARGET_ARCH=${SWIFT_TARGET_ARCH:=armv7} + +case ${SWIFT_TARGET_ARCH} in + armv6) + EXTRA_FLAGS="" + ;; + armv7) + EXTRA_FLAGS="-mfloat-abi=hard" + ;; + *) + echo "Unsupported architecture $SWIFT_TARGET_ARCH!" + exit -1 + ;; +esac +SWIFT_TARGET_NAME=${SWIFT_TARGET_ARCH}-unknown-linux-gnueabihf # Configurable SRC_ROOT="${SRC_ROOT:=$(pwd)}" @@ -44,7 +57,6 @@ INSTALL_TAR=${INSTALL_TAR:=$SRC_ROOT/build/swift-$SWIFT_TARGET_ARCH-$SWIFT_VERSI PREBUILT_XCTOOLCHAIN=$SRC_ROOT/downloads/${SWIFT_VERSION}-osx.pkg # Compilation flags -EXTRA_FLAGS="-march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard" RUNTIME_FLAGS="-w -fuse-ld=lld --sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME}" LINK_FLAGS="--sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME} ${EXTRA_FLAGS} -latomic" ASM_FLAGS="--sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME}" From 31e34465221c15762b3809c8b5b7555a66385548 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Fri, 27 Dec 2024 07:15:03 -0500 Subject: [PATCH 02/27] Use armhf for building sysroot --- build-sysroot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-sysroot.sh b/build-sysroot.sh index 5951478..e7b396e 100755 --- a/build-sysroot.sh +++ b/build-sysroot.sh @@ -95,7 +95,7 @@ docker run --privileged --rm tonistiigi/binfmt --install all echo "Building $DISTRIUBTION distribution for sysroot" docker rm --force $CONTAINER_NAME docker run \ - --platform linux/arm/v7 \ + --platform linux/armhf \ --name $CONTAINER_NAME \ $DISTRIUBTION \ /bin/bash -c "$INSTALL_DEPS_CMD" From a8c4e7e2bfc1803d68c8d35a35e1c33972d0e566 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Fri, 27 Dec 2024 09:44:23 -0500 Subject: [PATCH 03/27] Add more flags for armv6 --- swift-define | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swift-define b/swift-define index 6ebdd4d..3ca8f26 100644 --- a/swift-define +++ b/swift-define @@ -4,7 +4,7 @@ SWIFT_TARGET_ARCH=${SWIFT_TARGET_ARCH:=armv7} case ${SWIFT_TARGET_ARCH} in armv6) - EXTRA_FLAGS="" + EXTRA_FLAGS="-mfpu=vfpv2 -mfloat-abi=hard" ;; armv7) EXTRA_FLAGS="-mfloat-abi=hard" @@ -57,7 +57,7 @@ INSTALL_TAR=${INSTALL_TAR:=$SRC_ROOT/build/swift-$SWIFT_TARGET_ARCH-$SWIFT_VERSI PREBUILT_XCTOOLCHAIN=$SRC_ROOT/downloads/${SWIFT_VERSION}-osx.pkg # Compilation flags -RUNTIME_FLAGS="-w -fuse-ld=lld --sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME}" +RUNTIME_FLAGS="-w -fuse-ld=lld --sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME} ${EXTRA_FLAGS}" LINK_FLAGS="--sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME} ${EXTRA_FLAGS} -latomic" ASM_FLAGS="--sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME}" From cc3148cf6d5015c3257e21653c3768556b079bf2 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Fri, 27 Dec 2024 13:22:14 -0500 Subject: [PATCH 04/27] Initial working support for building Swift for armv6 using the raspi OS image --- build-sysroot.sh | 137 +++++++++++++++++++++++++++++++++-------------- swift-define | 5 +- 2 files changed, 99 insertions(+), 43 deletions(-) diff --git a/build-sysroot.sh b/build-sysroot.sh index e7b396e..3f23f46 100755 --- a/build-sysroot.sh +++ b/build-sysroot.sh @@ -5,15 +5,19 @@ set -e SRC_ROOT=$(pwd) CONTAINER_NAME=swift-armv7-sysroot -DISTRIUBTION=$1 -SYSROOT=$2 +DISTRIBUTION_NAME=$1 +DISTRIUBTION_VERSION=$2 +SYSROOT=$3 if [ -z $SYSROOT ]; then - SYSROOT=sysroot-$(echo "$DISTRIUBTION" | tr : -) + SYSROOT=sysroot-$DISTRIBUTION_NAME-$DISTRIUBTION_VERSION fi +SYSROOT=$(pwd)/$SYSROOT -case $DISTRIUBTION in - ubuntu:focal) +DISTRIBUTION="$DISTRIBUTION_NAME:$DISTRIUBTION_VERSION" + +case $DISTRIUBTION_VERSION in + "focal") INSTALL_DEPS_CMD=" \ apt-get update && \ apt-get install -y \ @@ -29,7 +33,9 @@ case $DISTRIUBTION in libsystemd-dev \ " ;; - "debian:bullseye") + "bullseye") + RASPIOS_VERSION="2024-10-22" + RASPIOS_URL=https://downloads.raspberrypi.com/raspios_oldstable_lite_armhf/images/raspios_oldstable_lite_armhf-2024-10-28 INSTALL_DEPS_CMD=" \ apt-get update && \ apt-get install -y \ @@ -45,7 +51,9 @@ case $DISTRIUBTION in libsystemd-dev \ " ;; - "ubuntu:jammy" | "debian:bookworm") + "jammy" | "bookworm") + RASPIOS_VERSION="2024-11-19" + RASPIOS_URL=https://downloads.raspberrypi.com/raspios_lite_armhf/images/raspios_lite_armhf-$RASPIOS_VERSION INSTALL_DEPS_CMD=" \ apt-get update && \ apt-get install -y \ @@ -61,7 +69,7 @@ case $DISTRIUBTION in libsystemd-dev \ " ;; - "ubuntu:mantic" | "ubuntu:noble") + "mantic" | "noble") INSTALL_DEPS_CMD=" \ apt-get update && \ apt-get install -y \ @@ -86,38 +94,85 @@ esac if [ ! -z $EXTRA_PACKAGES ]; then echo "Including extra packages: $EXTRA_PACKAGES" - INSTALL_DEPS_CMD="$INSTALL_DEPS_CMD && apt-get install -y $EXTRA_PACKAGES" + INSTALL_DEPS_CMD="$INSTALL_DEPS_CMD && apt-get install -y $EXTRA_PACKAGES --no-optional" fi -echo "Starting up qemu emulation" -docker run --privileged --rm tonistiigi/binfmt --install all - -echo "Building $DISTRIUBTION distribution for sysroot" -docker rm --force $CONTAINER_NAME -docker run \ - --platform linux/armhf \ - --name $CONTAINER_NAME \ - $DISTRIUBTION \ - /bin/bash -c "$INSTALL_DEPS_CMD" - -echo "Extracting sysroot folders to $SYSROOT" -rm -rf $SYSROOT -mkdir -p $SYSROOT/usr -docker cp $CONTAINER_NAME:/lib $SYSROOT/lib -docker cp $CONTAINER_NAME:/usr/lib $SYSROOT/usr/lib -docker cp $CONTAINER_NAME:/usr/include $SYSROOT/usr/include - -# Find broken links, re-copy -cd $SYSROOT -BROKEN_LINKS=$(find . -xtype l) -while IFS= read -r link; do - # Ignore empty links - if [ -z "${link}" ]; then continue; fi - - echo "Replacing broken symlink: $link" - link=$(echo $link | sed '0,/./ s/.//') - docker cp -L $CONTAINER_NAME:$link $(dirname .$link) -done <<< "$BROKEN_LINKS" - -echo "Cleaning up" -docker rm $CONTAINER_NAME +if [[ $DISTRIBUTION_NAME = "debian" ]]; then + echo "Installing host dependencies..." + sudo apt update && sudo apt install qemu-user-static p7zip xz-utils + + mkdir artifacts && true + cd artifacts + + # Use Raspberry Pi OS to build for debian to support armv6 + echo "Downloading raspios $RASPBIAN_VERSION for $DISTRIUBTION_VERSION..." + IMAGE_FILE=$RASPIOS_VERSION-raspios-$DISTRIUBTION_VERSION-armhf-lite.img + DOWNLOAD_URL=$RASPIOS_URL/$IMAGE_FILE.xz + wget -N $DOWNLOAD_URL + + echo "Uncompressing $IMAGE_FILE.gz and extracting contents..." + xz -dk $IMAGE_FILE.xz && true + 7z e -y $IMAGE_FILE + + echo "Mounting 1.img to install additional dependencies..." + rm -rf sysroot && mkdir sysroot + sudo mount -o loop 1.img sysroot + sudo mount --bind /dev sysroot/dev + sudo mount --bind /dev/pts sysroot/dev/pts + sudo mount --bind /proc sysroot/proc + sudo mount --bind /sys sysroot/sys + + echo "Starting chroot to install dependencies..." + sudo cp /usr/bin/qemu-arm-static sysroot/usr/bin + REMOVE_DEPS_CMD="apt remove -y --purge \ + apparmor \ + linux-image* \ + *firmware* \ + " + sudo chroot sysroot qemu-arm-static /bin/bash -c "$REMOVE_DEPS_CMD && $INSTALL_DEPS_CMD" + + echo "Copying files from sysroot to $SYSROOT..." + rm -rf $SYSROOT + mkdir -p $SYSROOT/usr + cp -r sysroot/lib $SYSROOT/lib + cp -r sysroot/usr/lib $SYSROOT/usr/lib + cp -r sysroot/usr/include $SYSROOT/usr/include + + echo "Umounting and cleaning up..." + sudo umount -R sysroot + rm *.fat + rm *.img +else + echo "Starting up qemu emulation" + docker run --privileged --rm tonistiigi/binfmt --install all + + echo "Building $DISTRIUBTION distribution for sysroot" + docker rm --force $CONTAINER_NAME + docker run \ + --platform linux/armhf \ + --name $CONTAINER_NAME \ + $DISTRIUBTION \ + /bin/bash -c "$INSTALL_DEPS_CMD" + + echo "Extracting sysroot folders to $SYSROOT" + rm -rf $SYSROOT + mkdir -p $SYSROOT/usr + docker cp $CONTAINER_NAME:/lib $SYSROOT/lib + docker cp $CONTAINER_NAME:/usr/lib $SYSROOT/usr/lib + docker cp $CONTAINER_NAME:/usr/include $SYSROOT/usr/include + + # Find broken links, re-copy + cd $SYSROOT + BROKEN_LINKS=$(find . -xtype l) + while IFS= read -r link; do + # Ignore empty links + if [ -z "${link}" ]; then continue; fi + + echo "Replacing broken symlink: $link" + link=$(echo $link | sed '0,/./ s/.//') + docker cp -L $CONTAINER_NAME:$link $(dirname .$link) + done <<< "$BROKEN_LINKS" + + echo "Cleaning up" + docker rm $CONTAINER_NAME +fi \ No newline at end of file diff --git a/swift-define b/swift-define index 3ca8f26..d920fea 100644 --- a/swift-define +++ b/swift-define @@ -4,10 +4,11 @@ SWIFT_TARGET_ARCH=${SWIFT_TARGET_ARCH:=armv7} case ${SWIFT_TARGET_ARCH} in armv6) - EXTRA_FLAGS="-mfpu=vfpv2 -mfloat-abi=hard" + # The only version of armv6 supported is the RPI ARM1176JZF-S, which is only supported by Raspbian + EXTRA_FLAGS="-march=armv6z -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard" ;; armv7) - EXTRA_FLAGS="-mfloat-abi=hard" + EXTRA_FLAGS="-march=armv7-a -mfpu=neon -mfloat-abi=hard" ;; *) echo "Unsupported architecture $SWIFT_TARGET_ARCH!" From 8fc32cb98a4ccbeb3d659d4816a431ccfd59c0df Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Fri, 27 Dec 2024 13:54:31 -0500 Subject: [PATCH 05/27] Support building for armv6 for Swift Latest workflow --- .../actions/build-for-distribution/action.yml | 8 +++++-- .github/actions/build-with-sysroot/action.yml | 21 ++++++++++++------- .github/workflows/build-swift-latest.yml | 6 ++++-- build-sysroot.sh | 9 ++++---- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/.github/actions/build-for-distribution/action.yml b/.github/actions/build-for-distribution/action.yml index 13d1c0e..4dcf4ea 100644 --- a/.github/actions/build-for-distribution/action.yml +++ b/.github/actions/build-for-distribution/action.yml @@ -1,9 +1,12 @@ -name: Build Swift for a given armv7 distribution +name: Build Swift for a given distribution description: This wraps all the functionality of other actions to build Swift for a given distribution inputs: swift-tag: description: The Swift tag version that is being built required: true + swift-target-arch: + description: The target architecture to build Swift for (e.g., armv6 or armv7) + required: true swift-workspace-cache: description: The name of the Swift workspace directory to restore required: true @@ -27,6 +30,7 @@ runs: name: Build Swift + SDK using Sysroot with: swift-tag: ${{ inputs.swift-tag }} - sysroot-name: sysroot-${{ inputs.distribution }}-armv7 + sysroot-name: sysroot-${{ inputs.distribution }} + swift-target-arch: ${{ inputs.swift-target-arch }} distribution: ${{ inputs.distribution }} builder-tag: ${{ inputs.builder-tag }} diff --git a/.github/actions/build-with-sysroot/action.yml b/.github/actions/build-with-sysroot/action.yml index 7bc23a3..936d055 100644 --- a/.github/actions/build-with-sysroot/action.yml +++ b/.github/actions/build-with-sysroot/action.yml @@ -1,4 +1,4 @@ -name: Build Swift with a provided armv7 sysroot for a given sysroot +name: Build Swift with a provided sysroot and for a target architecture description: This contains the functionality to build/restore a sysroot, build Swift, and build an SDK inputs: swift-tag: @@ -7,6 +7,9 @@ inputs: sysroot-name: description: The name of the sysroot to use to build Swift required: true + swift-target-arch: + description: The target architecture to build Swift for (e.g., armv6 or armv7) + required: true distribution: description: The name of the distribution to build for required: true @@ -20,7 +23,7 @@ runs: shell: bash env: DISTRIBUTION: ${{ inputs.distribution }} - run: ./build-sysroot.sh $(echo ${DISTRIBUTION/-/:}) ${{ inputs.sysroot-name }} + run: ./build-sysroot.sh $(echo ${DISTRIBUTION/-/ }) ${{ inputs.sysroot-name }} - name: Compress shell: bash run: tar -czf ${{ inputs.sysroot-name }}.tar.gz ${{ inputs.sysroot-name }} @@ -29,20 +32,22 @@ runs: run: | docker run --rm --user runner --workdir ${{ github.workspace }} -v $HOME:$HOME \ -e SWIFT_VERSION=${{ inputs.swift-tag }} \ - -e INSTALL_TAR=$(pwd)/${{ inputs.swift-tag }}-${{ inputs.distribution }}-armv7-install.tar.gz \ + -e INSTALL_TAR=$(pwd)/${{ inputs.swift-tag }}-${{ inputs.distribution }}-${{ inputs.swift-target-arch }}-install.tar.gz \ -e STAGING_DIR=$(pwd)/${{ inputs.sysroot-name }} \ + -e SWIFT_TARGET_ARCH=${{ inputs.swift-target-arch }} -e SKIP_FETCH_SOURCES=1 \ xtremekforever/swift-builder:${{ inputs.builder-tag }} \ /bin/bash ./build.sh - name: Build SDK for Linux shell: bash run: | - INSTALLABLE_SDK_PACKAGE=$(pwd)/${{ inputs.swift-tag }}-${{ inputs.distribution }}-armv7-sdk.tar.gz SYSROOT=${{ inputs.sysroot-name }} \ + INSTALLABLE_SDK_PACKAGE=$(pwd)/${{ inputs.swift-tag }}-${{ inputs.distribution }}-${{ inputs.swift-target-arch }}-sdk.tar.gz \ + SYSROOT=${{ inputs.sysroot-name }} \ ./build-linux-cross-sdk.sh ${{ inputs.swift-tag }} ${{ inputs.distribution }} - name: Test SDK for Linux shell: bash env: - SDK_NAME: ${{ inputs.swift-tag }}-${{ inputs.distribution }}-armv7 + SDK_NAME: ${{ inputs.swift-tag }}-${{ inputs.distribution }}-${{ inputs.swift-target-arch }} run: | docker run --rm --user runner --workdir ${{ github.workspace }} -v $HOME:$HOME -v ${{ github.workspace }}/artifacts:/opt \ xtremekforever/swift-builder:${{ inputs.builder-tag }} \ @@ -54,8 +59,8 @@ runs: - uses: actions/upload-artifact@v4 name: Publish with: - name: ${{ inputs.swift-tag }}-${{ inputs.distribution }}-armv7 + name: ${{ inputs.swift-tag }}-${{ inputs.distribution }}-${{ inputs.swift-target-arch }} path: | ${{ inputs.sysroot-name }}.tar.gz - ${{ inputs.swift-tag }}*-armv7-install.tar.gz - ${{ inputs.swift-tag }}*-armv7-sdk.tar.gz + ${{ inputs.swift-tag }}*-${{ inputs.swift-target-arch }}-install.tar.gz + ${{ inputs.swift-tag }}*-${{ inputs.swift-target-arch }}-sdk.tar.gz diff --git a/.github/workflows/build-swift-latest.yml b/.github/workflows/build-swift-latest.yml index e9ba708..1d74224 100644 --- a/.github/workflows/build-swift-latest.yml +++ b/.github/workflows/build-swift-latest.yml @@ -2,18 +2,19 @@ name: Build Swift Latest on: push: - branches: [ "main" ] + branches: [ "main", "feature/armv6" ] pull_request: branches: [ "main" ] env: - DISTRIBUTION: debian-bookworm + DISTRIBUTION: raspios-bookworm jobs: build-latest: strategy: matrix: version: ["6.0.3"] + swift-target-arch: ["armv6", "armv7"] env: SWIFT_VERSION: ${{ matrix.version }} SWIFT_TAG: swift-${{ matrix.version }}-RELEASE @@ -35,5 +36,6 @@ jobs: name: Build & Publish Swift with: swift-tag: ${{ env.SWIFT_TAG }} + swift-target-arch: ${{ matrix.swift-target-arch }} distribution: ${{ env.DISTRIBUTION }} builder-tag: ${{ env.SWIFT_VERSION }} diff --git a/build-sysroot.sh b/build-sysroot.sh index 3f23f46..51a198f 100755 --- a/build-sysroot.sh +++ b/build-sysroot.sh @@ -10,9 +10,8 @@ DISTRIUBTION_VERSION=$2 SYSROOT=$3 if [ -z $SYSROOT ]; then - SYSROOT=sysroot-$DISTRIBUTION_NAME-$DISTRIUBTION_VERSION + SYSROOT=$(pwd)/sysroot-$DISTRIBUTION_NAME-$DISTRIUBTION_VERSION fi -SYSROOT=$(pwd)/$SYSROOT DISTRIBUTION="$DISTRIBUTION_NAME:$DISTRIUBTION_VERSION" @@ -97,14 +96,14 @@ if [ ! -z $EXTRA_PACKAGES ]; then INSTALL_DEPS_CMD="$INSTALL_DEPS_CMD && apt-get install -y $EXTRA_PACKAGES --no-optional" fi -if [[ $DISTRIBUTION_NAME = "debian" ]]; then +# This is for supporting armv6 +if [[ $DISTRIBUTION_NAME = "raspios" ]]; then echo "Installing host dependencies..." sudo apt update && sudo apt install qemu-user-static p7zip xz-utils mkdir artifacts && true cd artifacts - # Use Raspberry Pi OS to build for debian to support armv6 echo "Downloading raspios $RASPBIAN_VERSION for $DISTRIUBTION_VERSION..." IMAGE_FILE=$RASPIOS_VERSION-raspios-$DISTRIUBTION_VERSION-armhf-lite.img DOWNLOAD_URL=$RASPIOS_URL/$IMAGE_FILE.xz @@ -175,4 +174,4 @@ else echo "Cleaning up" docker rm $CONTAINER_NAME -fi \ No newline at end of file +fi From 76c5c3d755a011f1a169d00a3792a6edb97418f6 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Fri, 27 Dec 2024 14:16:22 -0500 Subject: [PATCH 06/27] Fix symlinks in raspios sysroot using symlinks utility --- build-sysroot.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/build-sysroot.sh b/build-sysroot.sh index 51a198f..5558d8f 100755 --- a/build-sysroot.sh +++ b/build-sysroot.sh @@ -10,8 +10,9 @@ DISTRIUBTION_VERSION=$2 SYSROOT=$3 if [ -z $SYSROOT ]; then - SYSROOT=$(pwd)/sysroot-$DISTRIBUTION_NAME-$DISTRIUBTION_VERSION + SYSROOT=sysroot-$DISTRIBUTION_NAME-$DISTRIUBTION_VERSION fi +SYSROOT=$(pwd)/$SYSROOT DISTRIBUTION="$DISTRIBUTION_NAME:$DISTRIUBTION_VERSION" @@ -91,9 +92,13 @@ case $DISTRIUBTION_VERSION in ;; esac +if [[ $DISTRIBUTION_NAME = "raspios" ]]; then + INSTALL_DEPS_CMD="$INSTALL_DEPS_CMD symlinks" +fi + if [ ! -z $EXTRA_PACKAGES ]; then echo "Including extra packages: $EXTRA_PACKAGES" - INSTALL_DEPS_CMD="$INSTALL_DEPS_CMD && apt-get install -y $EXTRA_PACKAGES --no-optional" + INSTALL_DEPS_CMD="$INSTALL_DEPS_CMD && apt-get install -y $EXTRA_PACKAGES" fi # This is for supporting armv6 @@ -133,6 +138,7 @@ if [[ $DISTRIBUTION_NAME = "raspios" ]]; then echo "Copying files from sysroot to $SYSROOT..." rm -rf $SYSROOT mkdir -p $SYSROOT/usr + sudo chroot sysroot qemu-arm-static /bin/bash -c "symlinks -cr /usr" cp -r sysroot/lib $SYSROOT/lib cp -r sysroot/usr/lib $SYSROOT/usr/lib cp -r sysroot/usr/include $SYSROOT/usr/include From 555e63ac424115b1c8b49913af8f839c941169c5 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Fri, 27 Dec 2024 14:27:56 -0500 Subject: [PATCH 07/27] Cache sysroot again since we now only cache a single downloads workspace --- .github/actions/build-with-sysroot/action.yml | 18 ++++++++++++++++-- build-sysroot.sh | 4 ++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/actions/build-with-sysroot/action.yml b/.github/actions/build-with-sysroot/action.yml index 936d055..8f7943c 100644 --- a/.github/actions/build-with-sysroot/action.yml +++ b/.github/actions/build-with-sysroot/action.yml @@ -19,7 +19,14 @@ inputs: runs: using: "composite" steps: - - name: Build + - name: Restore Sysroot + id: restore-sysroot + uses: actions/cache/restore@v4 + with: + key: ${{ inputs.sysroot-name }} + path: ${{ inputs.sysroot-name }} + - if: ${{ steps.restore-sysroot.outputs.cache-hit != 'true' }} + name: Build Sysroot shell: bash env: DISTRIBUTION: ${{ inputs.distribution }} @@ -27,6 +34,13 @@ runs: - name: Compress shell: bash run: tar -czf ${{ inputs.sysroot-name }}.tar.gz ${{ inputs.sysroot-name }} + - name: Cache Sysroot + id: cache-sysroot + if: steps.restore-sysroot.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + key: ${{ inputs.sysroot-name }} + path: ${{ inputs.sysroot-name }} - name: Build Swift shell: bash run: | @@ -34,7 +48,7 @@ runs: -e SWIFT_VERSION=${{ inputs.swift-tag }} \ -e INSTALL_TAR=$(pwd)/${{ inputs.swift-tag }}-${{ inputs.distribution }}-${{ inputs.swift-target-arch }}-install.tar.gz \ -e STAGING_DIR=$(pwd)/${{ inputs.sysroot-name }} \ - -e SWIFT_TARGET_ARCH=${{ inputs.swift-target-arch }} + -e SWIFT_TARGET_ARCH=${{ inputs.swift-target-arch }} \ -e SKIP_FETCH_SOURCES=1 \ xtremekforever/swift-builder:${{ inputs.builder-tag }} \ /bin/bash ./build.sh diff --git a/build-sysroot.sh b/build-sysroot.sh index 5558d8f..a27a25a 100755 --- a/build-sysroot.sh +++ b/build-sysroot.sh @@ -112,7 +112,7 @@ if [[ $DISTRIBUTION_NAME = "raspios" ]]; then echo "Downloading raspios $RASPBIAN_VERSION for $DISTRIUBTION_VERSION..." IMAGE_FILE=$RASPIOS_VERSION-raspios-$DISTRIUBTION_VERSION-armhf-lite.img DOWNLOAD_URL=$RASPIOS_URL/$IMAGE_FILE.xz - wget -N $DOWNLOAD_URL + wget -q -N $DOWNLOAD_URL echo "Uncompressing $IMAGE_FILE.gz and extracting contents..." xz -dk $IMAGE_FILE.xz && true @@ -138,7 +138,7 @@ if [[ $DISTRIBUTION_NAME = "raspios" ]]; then echo "Copying files from sysroot to $SYSROOT..." rm -rf $SYSROOT mkdir -p $SYSROOT/usr - sudo chroot sysroot qemu-arm-static /bin/bash -c "symlinks -cr /usr" + sudo chroot sysroot qemu-arm-static /bin/bash -c "symlinks -cr /usr/lib" cp -r sysroot/lib $SYSROOT/lib cp -r sysroot/usr/lib $SYSROOT/usr/lib cp -r sysroot/usr/include $SYSROOT/usr/include From 18b960d42e1fcef65f854c8ba6976b26db22b99a Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Fri, 27 Dec 2024 14:58:59 -0500 Subject: [PATCH 08/27] Fix building cross SDK for armv6, streamline raspios sysroot --- .github/actions/build-with-sysroot/action.yml | 1 + build-sysroot.sh | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/actions/build-with-sysroot/action.yml b/.github/actions/build-with-sysroot/action.yml index 8f7943c..df6e475 100644 --- a/.github/actions/build-with-sysroot/action.yml +++ b/.github/actions/build-with-sysroot/action.yml @@ -57,6 +57,7 @@ runs: run: | INSTALLABLE_SDK_PACKAGE=$(pwd)/${{ inputs.swift-tag }}-${{ inputs.distribution }}-${{ inputs.swift-target-arch }}-sdk.tar.gz \ SYSROOT=${{ inputs.sysroot-name }} \ + TARGET_ARCH=${{ inputs.swift-target-arch }} \ ./build-linux-cross-sdk.sh ${{ inputs.swift-tag }} ${{ inputs.distribution }} - name: Test SDK for Linux shell: bash diff --git a/build-sysroot.sh b/build-sysroot.sh index a27a25a..854aaca 100755 --- a/build-sysroot.sh +++ b/build-sysroot.sh @@ -109,7 +109,7 @@ if [[ $DISTRIBUTION_NAME = "raspios" ]]; then mkdir artifacts && true cd artifacts - echo "Downloading raspios $RASPBIAN_VERSION for $DISTRIUBTION_VERSION..." + echo "Downloading raspios $RASPIOS_VERSION for $DISTRIUBTION_VERSION..." IMAGE_FILE=$RASPIOS_VERSION-raspios-$DISTRIUBTION_VERSION-armhf-lite.img DOWNLOAD_URL=$RASPIOS_URL/$IMAGE_FILE.xz wget -q -N $DOWNLOAD_URL @@ -118,7 +118,7 @@ if [[ $DISTRIBUTION_NAME = "raspios" ]]; then xz -dk $IMAGE_FILE.xz && true 7z e -y $IMAGE_FILE - echo "Mounting 1.img to install additional dependencies..." + echo "Mounting 1.img and needed passthroughs..." rm -rf sysroot && mkdir sysroot sudo mount -o loop 1.img sysroot sudo mount --bind /dev sysroot/dev @@ -128,20 +128,26 @@ if [[ $DISTRIBUTION_NAME = "raspios" ]]; then echo "Starting chroot to install dependencies..." sudo cp /usr/bin/qemu-arm-static sysroot/usr/bin - REMOVE_DEPS_CMD="apt remove -y --purge \ + REMOVE_DEPS_CMD="apt-get remove -y --purge \ apparmor \ + bluez \ + network-manager \ linux-image* \ *firmware* \ + raspi* \ + && apt-get autoremove -y \ " sudo chroot sysroot qemu-arm-static /bin/bash -c "$REMOVE_DEPS_CMD && $INSTALL_DEPS_CMD" echo "Copying files from sysroot to $SYSROOT..." rm -rf $SYSROOT - mkdir -p $SYSROOT/usr + mkdir -p $SYSROOT/usr/lib sudo chroot sysroot qemu-arm-static /bin/bash -c "symlinks -cr /usr/lib" cp -r sysroot/lib $SYSROOT/lib - cp -r sysroot/usr/lib $SYSROOT/usr/lib cp -r sysroot/usr/include $SYSROOT/usr/include + cp -r sysroot/usr/lib/arm-linux-gnueabihf $SYSROOT/usr/lib/ + cp -r sysroot/usr/lib/gcc $SYSROOT/usr/lib/ + cp -r sysroot/usr/lib/ld-linux-armhf.so.3 $SYSROOT/usr/lib/ echo "Umounting and cleaning up..." sudo umount -R sysroot From 207bbeb63e8a1edb3eed00eea0245fdc721491a9 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Fri, 27 Dec 2024 15:11:55 -0500 Subject: [PATCH 09/27] Restore copying whole usr/lib directory, needed for compiling Swift --- build-sysroot.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/build-sysroot.sh b/build-sysroot.sh index 854aaca..56dfd37 100755 --- a/build-sysroot.sh +++ b/build-sysroot.sh @@ -135,19 +135,18 @@ if [[ $DISTRIBUTION_NAME = "raspios" ]]; then linux-image* \ *firmware* \ raspi* \ + rpi* \ && apt-get autoremove -y \ " sudo chroot sysroot qemu-arm-static /bin/bash -c "$REMOVE_DEPS_CMD && $INSTALL_DEPS_CMD" echo "Copying files from sysroot to $SYSROOT..." rm -rf $SYSROOT - mkdir -p $SYSROOT/usr/lib + mkdir -p $SYSROOT/usr sudo chroot sysroot qemu-arm-static /bin/bash -c "symlinks -cr /usr/lib" cp -r sysroot/lib $SYSROOT/lib cp -r sysroot/usr/include $SYSROOT/usr/include - cp -r sysroot/usr/lib/arm-linux-gnueabihf $SYSROOT/usr/lib/ - cp -r sysroot/usr/lib/gcc $SYSROOT/usr/lib/ - cp -r sysroot/usr/lib/ld-linux-armhf.so.3 $SYSROOT/usr/lib/ + cp -r sysroot/usr/lib $SYSROOT/usr/lib echo "Umounting and cleaning up..." sudo umount -R sysroot From a44ddd54847ca5fb52e37d520eae5d25923571cb Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Fri, 27 Dec 2024 15:59:01 -0500 Subject: [PATCH 10/27] Add support for building release for Raspi OS versions, armv6 and armv7 --- .github/workflows/build-swift-nightly.yml | 1 + .github/workflows/build-swift-release.yml | 44 +++++++++++++++++++++-- README.md | 4 +++ 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-swift-nightly.yml b/.github/workflows/build-swift-nightly.yml index 00ebb5a..f000fb0 100644 --- a/.github/workflows/build-swift-nightly.yml +++ b/.github/workflows/build-swift-nightly.yml @@ -43,5 +43,6 @@ jobs: name: Build & Publish Swift with: swift-tag: ${{ env.SWIFT_TAG }} + swift-target-arch: armv7 distribution: ${{ env.DISTRIBUTION }} builder-tag: ${{ env.SWIFT_VERSION }} diff --git a/.github/workflows/build-swift-release.yml b/.github/workflows/build-swift-release.yml index bc791ce..2a036ea 100644 --- a/.github/workflows/build-swift-release.yml +++ b/.github/workflows/build-swift-release.yml @@ -1,12 +1,14 @@ name: Build Swift Release on: + push: + branches: [ "feature/**" ] release: types: [published] env: - SWIFT_VERSION: ${{ github.event.release.tag_name }} - SWIFT_TAG: swift-${{ github.event.release.tag_name }}-RELEASE + SWIFT_VERSION: 6.0.3 + SWIFT_TAG: swift-6.0.3-RELEASE SWIFT_WORKSPACE_CACHE: swift-workspace jobs: @@ -46,6 +48,7 @@ jobs: with: swift-tag: ${{ env.SWIFT_TAG }} swift-workspace-cache: ${{ env.SWIFT_WORKSPACE_CACHE }} + swift-target-arch: armv7 distribution: ${{ matrix.distribution }} builder-tag: ${{ env.SWIFT_VERSION }} - name: Update Release ${{ env.SWIFT_VERSION }} @@ -58,3 +61,40 @@ jobs: artifactErrorsFailBuild: true artifacts: "*.tar.gz" body: "See the [README](https://github.com/xtremekforever/swift-armv7#continuous-integration) for more information on build artifacts." + + build-for-raspios: + strategy: + matrix: + distribution: [ + "raspios-bullseye", + "raspios-bookworm" + ] + swift-target-arch: ["armv6", "armv7"] + name: Build for RaspiOS + runs-on: ubuntu-latest + needs: [fetch-sources] + steps: + - uses: actions/checkout@v4 + - name: Generate Builder Container + shell: bash + run: | + source ./swift-builder/swift-builder-common + ./swift-builder/build-container.sh + - uses: ./.github/actions/build-for-distribution + name: "Build & Publish Swift ${{ env.SWIFT_VERSION }}" + with: + swift-tag: ${{ env.SWIFT_TAG }} + swift-workspace-cache: ${{ env.SWIFT_WORKSPACE_CACHE }} + swift-target-arch: ${{ matrix.swift-target-arch }} + distribution: ${{ matrix.distribution }} + builder-tag: ${{ env.SWIFT_VERSION }} + - name: Update Release ${{ env.SWIFT_VERSION }} + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + name: Swift ${{ env.SWIFT_VERSION }} for armv6/armv7 + tag: ${{ env.SWIFT_VERSION }} + commit: ${{ github.sha }} + artifactErrorsFailBuild: true + artifacts: "*.tar.gz" + body: "See the [README](https://github.com/xtremekforever/swift-armv7#continuous-integration) for more information on build artifacts." diff --git a/README.md b/README.md index ee66d96..4eff208 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ Some main goals: - Provide SDKs that can be downloaded and used to cross-compile user applications and libraries to armv7. - Maintain a CI that can build snapshots/nightly versions of Swift to find and fix issues. +NOTE: Building for armv6 is also now supported, although it is limited to working with the `raspios` +distribution since that is the only version of Debian that supports the ARMv6 architecture. However, +this makes this project also compatible with older Raspberry Pi models such as the RPI 1, Zero, and so on. + ## Compilation There are various options for compiling Swift for armv7 with these scripts. From 0fd60fccb70b97d56e0256ed6fb36e53e31841cc Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Fri, 27 Dec 2024 16:09:52 -0500 Subject: [PATCH 11/27] Fix typo in build-sysroot.sh, fix name of job --- .github/workflows/build-swift-release.yml | 2 +- build-sysroot.sh | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-swift-release.yml b/.github/workflows/build-swift-release.yml index 2a036ea..dcf269a 100644 --- a/.github/workflows/build-swift-release.yml +++ b/.github/workflows/build-swift-release.yml @@ -70,7 +70,7 @@ jobs: "raspios-bookworm" ] swift-target-arch: ["armv6", "armv7"] - name: Build for RaspiOS + name: Build Swift runs-on: ubuntu-latest needs: [fetch-sources] steps: diff --git a/build-sysroot.sh b/build-sysroot.sh index 56dfd37..ed95d0a 100755 --- a/build-sysroot.sh +++ b/build-sysroot.sh @@ -4,7 +4,6 @@ set -e SRC_ROOT=$(pwd) -CONTAINER_NAME=swift-armv7-sysroot DISTRIBUTION_NAME=$1 DISTRIUBTION_VERSION=$2 SYSROOT=$3 @@ -156,12 +155,14 @@ else echo "Starting up qemu emulation" docker run --privileged --rm tonistiigi/binfmt --install all - echo "Building $DISTRIUBTION distribution for sysroot" + CONTAINER_NAME=swift-armhf-sysroot + + echo "Building $DISTRIBUTION distribution for sysroot" docker rm --force $CONTAINER_NAME docker run \ --platform linux/armhf \ --name $CONTAINER_NAME \ - $DISTRIUBTION \ + $DISTRIBUTION \ /bin/bash -c "$INSTALL_DEPS_CMD" echo "Extracting sysroot folders to $SYSROOT" From cd8858d9c384ccb19f36683fc43f38333cd1eef6 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Fri, 27 Dec 2024 17:58:10 -0500 Subject: [PATCH 12/27] Update names of release jobs, ignore artifacts upload error --- .github/workflows/build-swift-latest.yml | 2 +- .github/workflows/build-swift-release.yml | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-swift-latest.yml b/.github/workflows/build-swift-latest.yml index 1d74224..4256237 100644 --- a/.github/workflows/build-swift-latest.yml +++ b/.github/workflows/build-swift-latest.yml @@ -2,7 +2,7 @@ name: Build Swift Latest on: push: - branches: [ "main", "feature/armv6" ] + branches: [ "main" ] pull_request: branches: [ "main" ] diff --git a/.github/workflows/build-swift-release.yml b/.github/workflows/build-swift-release.yml index dcf269a..337b274 100644 --- a/.github/workflows/build-swift-release.yml +++ b/.github/workflows/build-swift-release.yml @@ -33,7 +33,7 @@ jobs: "ubuntu-jammy", "ubuntu-noble" ] - name: Build Swift + name: Build for armv7 runs-on: ubuntu-latest needs: [fetch-sources] steps: @@ -65,12 +65,12 @@ jobs: build-for-raspios: strategy: matrix: - distribution: [ - "raspios-bullseye", - "raspios-bookworm" + distribution-version: [ + "bullseye", + "bookworm" ] swift-target-arch: ["armv6", "armv7"] - name: Build Swift + name: Build for RaspiOS runs-on: ubuntu-latest needs: [fetch-sources] steps: @@ -86,7 +86,7 @@ jobs: swift-tag: ${{ env.SWIFT_TAG }} swift-workspace-cache: ${{ env.SWIFT_WORKSPACE_CACHE }} swift-target-arch: ${{ matrix.swift-target-arch }} - distribution: ${{ matrix.distribution }} + distribution: raspios-${{ matrix.distribution-version }} builder-tag: ${{ env.SWIFT_VERSION }} - name: Update Release ${{ env.SWIFT_VERSION }} uses: ncipollo/release-action@v1 @@ -95,6 +95,6 @@ jobs: name: Swift ${{ env.SWIFT_VERSION }} for armv6/armv7 tag: ${{ env.SWIFT_VERSION }} commit: ${{ github.sha }} - artifactErrorsFailBuild: true + artifactErrorsFailBuild: false artifacts: "*.tar.gz" body: "See the [README](https://github.com/xtremekforever/swift-armv7#continuous-integration) for more information on build artifacts." From 134fb668e82b09f6582ecf9eebcf0e2a635d1717 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Fri, 27 Dec 2024 19:20:48 -0500 Subject: [PATCH 13/27] Try to reduce size of raspios sysroot a bit more - Not sure what else can be removed easily --- .github/workflows/build-swift-release.yml | 4 ++-- build-sysroot.sh | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-swift-release.yml b/.github/workflows/build-swift-release.yml index 337b274..4521ab0 100644 --- a/.github/workflows/build-swift-release.yml +++ b/.github/workflows/build-swift-release.yml @@ -55,7 +55,7 @@ jobs: uses: ncipollo/release-action@v1 with: allowUpdates: true - name: Swift ${{ env.SWIFT_VERSION }} for armv7 + name: Swift ${{ env.SWIFT_VERSION }} for armhf tag: ${{ env.SWIFT_VERSION }} commit: ${{ github.sha }} artifactErrorsFailBuild: true @@ -92,7 +92,7 @@ jobs: uses: ncipollo/release-action@v1 with: allowUpdates: true - name: Swift ${{ env.SWIFT_VERSION }} for armv6/armv7 + name: Swift ${{ env.SWIFT_VERSION }} for armhf tag: ${{ env.SWIFT_VERSION }} commit: ${{ github.sha }} artifactErrorsFailBuild: false diff --git a/build-sysroot.sh b/build-sysroot.sh index ed95d0a..5827f28 100755 --- a/build-sysroot.sh +++ b/build-sysroot.sh @@ -118,6 +118,7 @@ if [[ $DISTRIBUTION_NAME = "raspios" ]]; then 7z e -y $IMAGE_FILE echo "Mounting 1.img and needed passthroughs..." + sudo umount -R sysroot && true rm -rf sysroot && mkdir sysroot sudo mount -o loop 1.img sysroot sudo mount --bind /dev sysroot/dev @@ -133,19 +134,25 @@ if [[ $DISTRIBUTION_NAME = "raspios" ]]; then network-manager \ linux-image* \ *firmware* \ + openssh* \ + p7zip* \ + perl \ + perl-modules* \ raspi* \ rpi* \ - && apt-get autoremove -y \ " - sudo chroot sysroot qemu-arm-static /bin/bash -c "$REMOVE_DEPS_CMD && $INSTALL_DEPS_CMD" + sudo chroot sysroot qemu-arm-static /bin/bash -c "$REMOVE_DEPS_CMD && $INSTALL_DEPS_CMD && apt-get autoremove -y" echo "Copying files from sysroot to $SYSROOT..." rm -rf $SYSROOT - mkdir -p $SYSROOT/usr + mkdir -p $SYSROOT/usr/lib sudo chroot sysroot qemu-arm-static /bin/bash -c "symlinks -cr /usr/lib" cp -r sysroot/lib $SYSROOT/lib cp -r sysroot/usr/include $SYSROOT/usr/include - cp -r sysroot/usr/lib $SYSROOT/usr/lib + cp -r sysroot/usr/lib/*.so* $SYSROOT/usr/lib/ + cp -r sysroot/usr/lib/arm-linux-gnueabihf $SYSROOT/usr/lib/ + cp -r sysroot/usr/lib/linux $SYSROOT/usr/lib/ + cp -r sysroot/usr/lib/gcc $SYSROOT/usr/lib/ echo "Umounting and cleaning up..." sudo umount -R sysroot From c5e1ae8ccdcfcc8c7640906604a88d35876b572b Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Fri, 27 Dec 2024 19:48:16 -0500 Subject: [PATCH 14/27] Never mind, the bullseye sysroot doesn't contain usr/lib/linux --- build-sysroot.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/build-sysroot.sh b/build-sysroot.sh index 5827f28..082b9b8 100755 --- a/build-sysroot.sh +++ b/build-sysroot.sh @@ -145,14 +145,11 @@ if [[ $DISTRIBUTION_NAME = "raspios" ]]; then echo "Copying files from sysroot to $SYSROOT..." rm -rf $SYSROOT - mkdir -p $SYSROOT/usr/lib + mkdir -p $SYSROOT/usr sudo chroot sysroot qemu-arm-static /bin/bash -c "symlinks -cr /usr/lib" cp -r sysroot/lib $SYSROOT/lib cp -r sysroot/usr/include $SYSROOT/usr/include - cp -r sysroot/usr/lib/*.so* $SYSROOT/usr/lib/ - cp -r sysroot/usr/lib/arm-linux-gnueabihf $SYSROOT/usr/lib/ - cp -r sysroot/usr/lib/linux $SYSROOT/usr/lib/ - cp -r sysroot/usr/lib/gcc $SYSROOT/usr/lib/ + cp -r sysroot/usr/lib $SYSROOT/usr/lib echo "Umounting and cleaning up..." sudo umount -R sysroot From 66277153170bef25dc20b99e742c38b4f43a91c9 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Fri, 27 Dec 2024 19:52:34 -0500 Subject: [PATCH 15/27] Update Swift release to build on branch instead of release created - This will be less ridiculous and the branch can be modified manually using find and replace. --- .github/workflows/build-swift-release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build-swift-release.yml b/.github/workflows/build-swift-release.yml index 4521ab0..00c2769 100644 --- a/.github/workflows/build-swift-release.yml +++ b/.github/workflows/build-swift-release.yml @@ -2,9 +2,7 @@ name: Build Swift Release on: push: - branches: [ "feature/**" ] - release: - types: [published] + branches: [ "release/6.0.3" ] env: SWIFT_VERSION: 6.0.3 From 48271868ecdd299ac87ae31ff4f284db03d7eccd Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Fri, 27 Dec 2024 20:19:59 -0500 Subject: [PATCH 16/27] Use debian-bookworm for latest workflow, disable armv6 build --- .github/workflows/build-swift-latest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-swift-latest.yml b/.github/workflows/build-swift-latest.yml index 4256237..76fc36f 100644 --- a/.github/workflows/build-swift-latest.yml +++ b/.github/workflows/build-swift-latest.yml @@ -7,14 +7,14 @@ on: branches: [ "main" ] env: - DISTRIBUTION: raspios-bookworm + DISTRIBUTION: debian-bookworm jobs: build-latest: strategy: matrix: version: ["6.0.3"] - swift-target-arch: ["armv6", "armv7"] + swift-target-arch: ["armv7"] env: SWIFT_VERSION: ${{ matrix.version }} SWIFT_TAG: swift-${{ matrix.version }}-RELEASE From 93224fce42cc11849ce35ed419acc9bf287929cc Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Sun, 29 Dec 2024 16:08:02 -0500 Subject: [PATCH 17/27] Generate cleaner raspios sysroot with much less usr/lib directories --- build-in-container.sh | 1 + build-sysroot.sh | 29 +++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/build-in-container.sh b/build-in-container.sh index ab7aa61..6d0569c 100755 --- a/build-in-container.sh +++ b/build-in-container.sh @@ -16,6 +16,7 @@ docker run \ -e SWIFT_VERSION=${SWIFT_TAG} \ -e STAGING_DIR=${STAGING_DIR} \ -e INSTALL_TAR=${INSTALL_TAG} \ + -e SKIP_FETCH_SOURCES=${SKIP_FETCH_SOURCES} \ -e SWIFT_TARGET_ARCH=${SWIFT_TARGET_ARCH} \ ${DOCKER_TAG} \ ./build.sh diff --git a/build-sysroot.sh b/build-sysroot.sh index 082b9b8..ca4b419 100755 --- a/build-sysroot.sh +++ b/build-sysroot.sh @@ -113,8 +113,10 @@ if [[ $DISTRIBUTION_NAME = "raspios" ]]; then DOWNLOAD_URL=$RASPIOS_URL/$IMAGE_FILE.xz wget -q -N $DOWNLOAD_URL - echo "Uncompressing $IMAGE_FILE.gz and extracting contents..." - xz -dk $IMAGE_FILE.xz && true + if [ ! -f $IMAGE_FILE ]; then + echo "Uncompressing $IMAGE_FILE.gz and extracting contents..." + xz -dk $IMAGE_FILE.xz && true + fi 7z e -y $IMAGE_FILE echo "Mounting 1.img and needed passthroughs..." @@ -126,7 +128,7 @@ if [[ $DISTRIBUTION_NAME = "raspios" ]]; then sudo mount --bind /proc sysroot/proc sudo mount --bind /sys sysroot/sys - echo "Starting chroot to install dependencies..." + # echo "Starting chroot to install dependencies..." sudo cp /usr/bin/qemu-arm-static sysroot/usr/bin REMOVE_DEPS_CMD="apt-get remove -y --purge \ apparmor \ @@ -140,21 +142,32 @@ if [[ $DISTRIBUTION_NAME = "raspios" ]]; then perl-modules* \ raspi* \ rpi* \ + libqt5core5a \ " sudo chroot sysroot qemu-arm-static /bin/bash -c "$REMOVE_DEPS_CMD && $INSTALL_DEPS_CMD && apt-get autoremove -y" echo "Copying files from sysroot to $SYSROOT..." rm -rf $SYSROOT - mkdir -p $SYSROOT/usr - sudo chroot sysroot qemu-arm-static /bin/bash -c "symlinks -cr /usr/lib" + mkdir -p $SYSROOT/usr/lib + sudo chroot sysroot qemu-arm-static /bin/bash -c "apt list --installed && symlinks -cr /usr/include && symlinks -cr /usr/lib" cp -r sysroot/lib $SYSROOT/lib cp -r sysroot/usr/include $SYSROOT/usr/include - cp -r sysroot/usr/lib $SYSROOT/usr/lib + cp -r sysroot/usr/lib/ld-linux-armhf.so.3 $SYSROOT/usr/lib/ + cp -r sysroot/usr/lib/os-release $SYSROOT/usr/lib/ + cp -r sysroot/usr/lib/arm-linux-gnueabihf $SYSROOT/usr/lib/ + cp -r sysroot/usr/lib/linux $SYSROOT/usr/lib/ && true + cp -r sysroot/usr/lib/gcc $SYSROOT/usr/lib/ + + # Cleanup + rm -rf $SYSROOT/usr/include/aarch64-linux-gnu + rm -rf $SYSROOT/usr/lib/gcc/arm-linux-gnueabihf/7 + rm -rf $SYSROOT/usr/lib/gcc/arm-linux-gnueabihf/7.5.0 + rm -rf $SYSROOT/usr/lib/gcc/arm-linux-gnueabihf/8 echo "Umounting and cleaning up..." sudo umount -R sysroot - rm *.fat - rm *.img + rm -f *.fat + rm -f *.img else echo "Starting up qemu emulation" docker run --privileged --rm tonistiigi/binfmt --install all From dfb59736448f589b33196242b915ccdf607672be Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Sun, 29 Dec 2024 16:12:10 -0500 Subject: [PATCH 18/27] Try additional matrix item --- .github/workflows/build-swift-latest.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-swift-latest.yml b/.github/workflows/build-swift-latest.yml index 76fc36f..c4aa5e2 100644 --- a/.github/workflows/build-swift-latest.yml +++ b/.github/workflows/build-swift-latest.yml @@ -6,15 +6,17 @@ on: pull_request: branches: [ "main" ] -env: - DISTRIBUTION: debian-bookworm - jobs: build-latest: strategy: matrix: version: ["6.0.3"] swift-target-arch: ["armv7"] + distribution: ["debian-bookworm"] + include: + - version: "6.0.3" + swift-target-arch: "armv6" + distribution: "raspios-bookworm" env: SWIFT_VERSION: ${{ matrix.version }} SWIFT_TAG: swift-${{ matrix.version }}-RELEASE @@ -37,5 +39,5 @@ jobs: with: swift-tag: ${{ env.SWIFT_TAG }} swift-target-arch: ${{ matrix.swift-target-arch }} - distribution: ${{ env.DISTRIBUTION }} + distribution: ${{ matrix.distribution }} builder-tag: ${{ env.SWIFT_VERSION }} From dd4496500c9fe80a3fca8c08ef57f364d5b62af4 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Sun, 29 Dec 2024 19:46:28 -0500 Subject: [PATCH 19/27] Generate event cleaner sysroot for debian/ubuntu --- build-sysroot.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/build-sysroot.sh b/build-sysroot.sh index ca4b419..d854e7d 100755 --- a/build-sysroot.sh +++ b/build-sysroot.sh @@ -128,8 +128,7 @@ if [[ $DISTRIBUTION_NAME = "raspios" ]]; then sudo mount --bind /proc sysroot/proc sudo mount --bind /sys sysroot/sys - # echo "Starting chroot to install dependencies..." - sudo cp /usr/bin/qemu-arm-static sysroot/usr/bin + echo "Starting chroot to update dependencies & fix symlinks..." REMOVE_DEPS_CMD="apt-get remove -y --purge \ apparmor \ bluez \ @@ -144,12 +143,13 @@ if [[ $DISTRIBUTION_NAME = "raspios" ]]; then rpi* \ libqt5core5a \ " + sudo cp /usr/bin/qemu-arm-static sysroot/usr/bin sudo chroot sysroot qemu-arm-static /bin/bash -c "$REMOVE_DEPS_CMD && $INSTALL_DEPS_CMD && apt-get autoremove -y" + sudo chroot sysroot qemu-arm-static /bin/bash -c "apt list --installed && symlinks -cr /usr/include && symlinks -cr /usr/lib" echo "Copying files from sysroot to $SYSROOT..." rm -rf $SYSROOT mkdir -p $SYSROOT/usr/lib - sudo chroot sysroot qemu-arm-static /bin/bash -c "apt list --installed && symlinks -cr /usr/include && symlinks -cr /usr/lib" cp -r sysroot/lib $SYSROOT/lib cp -r sysroot/usr/include $SYSROOT/usr/include cp -r sysroot/usr/lib/ld-linux-armhf.so.3 $SYSROOT/usr/lib/ @@ -184,10 +184,13 @@ else echo "Extracting sysroot folders to $SYSROOT" rm -rf $SYSROOT - mkdir -p $SYSROOT/usr + mkdir -p $SYSROOT/usr/lib docker cp $CONTAINER_NAME:/lib $SYSROOT/lib - docker cp $CONTAINER_NAME:/usr/lib $SYSROOT/usr/lib docker cp $CONTAINER_NAME:/usr/include $SYSROOT/usr/include + docker cp $CONTAINER_NAME:/usr/lib/ld-linux-armhf.so.3 $SYSROOT/usr/lib/ + docker cp $CONTAINER_NAME:/usr/lib/os-release $SYSROOT/usr/lib/ + docker cp $CONTAINER_NAME:/usr/lib/arm-linux-gnueabihf $SYSROOT/usr/lib/ + docker cp $CONTAINER_NAME:/usr/lib/gcc $SYSROOT/usr/lib/ # Find broken links, re-copy cd $SYSROOT From e55154a92f0618585eb4fee1be04609ba2cef019 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Sun, 29 Dec 2024 19:57:01 -0500 Subject: [PATCH 20/27] Remove Swift version from latest workflow --- .github/workflows/build-swift-latest.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-swift-latest.yml b/.github/workflows/build-swift-latest.yml index c4aa5e2..40b7dd7 100644 --- a/.github/workflows/build-swift-latest.yml +++ b/.github/workflows/build-swift-latest.yml @@ -10,22 +10,20 @@ jobs: build-latest: strategy: matrix: - version: ["6.0.3"] swift-target-arch: ["armv7"] distribution: ["debian-bookworm"] include: - - version: "6.0.3" - swift-target-arch: "armv6" + - swift-target-arch: "armv6" distribution: "raspios-bookworm" env: - SWIFT_VERSION: ${{ matrix.version }} - SWIFT_TAG: swift-${{ matrix.version }}-RELEASE + SWIFT_VERSION: 6.0.3 + SWIFT_TAG: swift-6.0.3-RELEASE name: Build Swift runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ./.github/actions/checkout-swift - name: Fetch Swift Sources + name: Fetch Swift ${{ env.SWIFT_TAG }} with: swift-tag: ${{ env.SWIFT_TAG }} swift-workspace-cache: swift-workspace @@ -35,7 +33,7 @@ jobs: source ./swift-builder/swift-builder-common ./swift-builder/build-container.sh - uses: ./.github/actions/build-for-distribution - name: Build & Publish Swift + name: Build & Publish Swift ${{ env.SWIFT_VERSION }} with: swift-tag: ${{ env.SWIFT_TAG }} swift-target-arch: ${{ matrix.swift-target-arch }} From 65835bc46322a8442a00ec1f6aef15bfb226c21e Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Mon, 30 Dec 2024 07:59:51 -0500 Subject: [PATCH 21/27] Cleanup build-container calls, store SWIFT_VERSION as a string - Otherwise it is seen as a double or int which causes issues --- .github/workflows/build-swift-latest.yml | 6 ++---- .github/workflows/build-swift-nightly.yml | 4 +--- .github/workflows/build-swift-release.yml | 6 ++---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-swift-latest.yml b/.github/workflows/build-swift-latest.yml index 40b7dd7..a1f19b1 100644 --- a/.github/workflows/build-swift-latest.yml +++ b/.github/workflows/build-swift-latest.yml @@ -16,7 +16,7 @@ jobs: - swift-target-arch: "armv6" distribution: "raspios-bookworm" env: - SWIFT_VERSION: 6.0.3 + SWIFT_VERSION: "6.0.3" SWIFT_TAG: swift-6.0.3-RELEASE name: Build Swift runs-on: ubuntu-latest @@ -29,9 +29,7 @@ jobs: swift-workspace-cache: swift-workspace - name: Generate Builder Container shell: bash - run: | - source ./swift-builder/swift-builder-common - ./swift-builder/build-container.sh + run: ./swift-builder/build-container.sh - uses: ./.github/actions/build-for-distribution name: Build & Publish Swift ${{ env.SWIFT_VERSION }} with: diff --git a/.github/workflows/build-swift-nightly.yml b/.github/workflows/build-swift-nightly.yml index f000fb0..81c7e23 100644 --- a/.github/workflows/build-swift-nightly.yml +++ b/.github/workflows/build-swift-nightly.yml @@ -36,9 +36,7 @@ jobs: swift-workspace-cache: ${{ env.SWIFT_WORKSPACE_CACHE }} - name: Build Swift Nightly Container shell: bash - run: | - source ./swift-builder/swift-builder-common - ./swift-builder/build-container.sh + run: ./swift-builder/build-container.sh - uses: ./.github/actions/build-for-distribution name: Build & Publish Swift with: diff --git a/.github/workflows/build-swift-release.yml b/.github/workflows/build-swift-release.yml index 00c2769..6039b71 100644 --- a/.github/workflows/build-swift-release.yml +++ b/.github/workflows/build-swift-release.yml @@ -5,7 +5,7 @@ on: branches: [ "release/6.0.3" ] env: - SWIFT_VERSION: 6.0.3 + SWIFT_VERSION: "6.0.3" SWIFT_TAG: swift-6.0.3-RELEASE SWIFT_WORKSPACE_CACHE: swift-workspace @@ -38,9 +38,7 @@ jobs: - uses: actions/checkout@v4 - name: Generate Builder Container shell: bash - run: | - source ./swift-builder/swift-builder-common - ./swift-builder/build-container.sh + run: ./swift-builder/build-container.sh - uses: ./.github/actions/build-for-distribution name: "Build & Publish Swift ${{ env.SWIFT_VERSION }}" with: From 46979079f8c1a15ebe6bd32ba2a52c6120d67c95 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Mon, 30 Dec 2024 08:08:32 -0500 Subject: [PATCH 22/27] Restore original docker sysroot copy, some files are different in older sysroots --- build-sysroot.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/build-sysroot.sh b/build-sysroot.sh index d854e7d..411133f 100755 --- a/build-sysroot.sh +++ b/build-sysroot.sh @@ -184,13 +184,10 @@ else echo "Extracting sysroot folders to $SYSROOT" rm -rf $SYSROOT - mkdir -p $SYSROOT/usr/lib + mkdir -p $SYSROOT/usr docker cp $CONTAINER_NAME:/lib $SYSROOT/lib docker cp $CONTAINER_NAME:/usr/include $SYSROOT/usr/include - docker cp $CONTAINER_NAME:/usr/lib/ld-linux-armhf.so.3 $SYSROOT/usr/lib/ - docker cp $CONTAINER_NAME:/usr/lib/os-release $SYSROOT/usr/lib/ - docker cp $CONTAINER_NAME:/usr/lib/arm-linux-gnueabihf $SYSROOT/usr/lib/ - docker cp $CONTAINER_NAME:/usr/lib/gcc $SYSROOT/usr/lib/ + docker cp $CONTAINER_NAME:/usr/lib $SYSROOT/usr/lib # Find broken links, re-copy cd $SYSROOT From d7e82b4586c49a8992e43ea460187c4a323515a2 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Sun, 12 Jan 2025 11:28:59 -0500 Subject: [PATCH 23/27] Find gcc install dir in sysroot and pass with --gcc-install-dir --- swift-define | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/swift-define b/swift-define index d920fea..ae70b51 100644 --- a/swift-define +++ b/swift-define @@ -5,6 +5,7 @@ SWIFT_TARGET_ARCH=${SWIFT_TARGET_ARCH:=armv7} case ${SWIFT_TARGET_ARCH} in armv6) # The only version of armv6 supported is the RPI ARM1176JZF-S, which is only supported by Raspbian + # If you attempt to build for armv6 with a Ubuntu or Debian sysroot, binaries will fail to run!!! EXTRA_FLAGS="-march=armv6z -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard" ;; armv7) @@ -31,6 +32,7 @@ SWIFT_BUILD_CONFIGURATION="${SWIFT_BUILD_CONFIGURATION:=Release}" SWIFTPM_CONFIGURATION="${SWIFTPM_CONFIGURATION:=release}" SWIFT_PACKAGE_SRCDIR="${SWIFT_PACKAGE_SRCDIR:=$SRC_ROOT/swift-hello}" SWIFT_PACKAGE_BUILDDIR="${SWIFT_PACKAGE_BUILDDIR:=$SWIFT_PACKAGE_SRCDIR/.build}" +GCC_INSTALL_DIR=${GCC_INSTALL_DIR:=$(dirname $(find ${STAGING_DIR} -name crtbegin.o))} # Build Paths LLVM_SRCDIR=$SRC_ROOT/downloads/llvm-project @@ -58,8 +60,8 @@ INSTALL_TAR=${INSTALL_TAR:=$SRC_ROOT/build/swift-$SWIFT_TARGET_ARCH-$SWIFT_VERSI PREBUILT_XCTOOLCHAIN=$SRC_ROOT/downloads/${SWIFT_VERSION}-osx.pkg # Compilation flags -RUNTIME_FLAGS="-w -fuse-ld=lld --sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME} ${EXTRA_FLAGS}" -LINK_FLAGS="--sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME} ${EXTRA_FLAGS} -latomic" +RUNTIME_FLAGS="-w -fuse-ld=lld --sysroot=${STAGING_DIR} --gcc-install-dir=${GCC_INSTALL_DIR} -target ${SWIFT_TARGET_NAME} ${EXTRA_FLAGS}" +LINK_FLAGS="--sysroot=${STAGING_DIR} --gcc-install-dir=${GCC_INSTALL_DIR} -target ${SWIFT_TARGET_NAME} ${EXTRA_FLAGS} -latomic" ASM_FLAGS="--sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME}" SWIFTC_FLAGS="-target ${SWIFT_TARGET_NAME} \ From a81458c97d67a6ee70210d831b3a945c800b42fc Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Sun, 12 Jan 2025 11:49:18 -0500 Subject: [PATCH 24/27] Perform git stash on swift-corelibs-foundation before updating - Useful if switching from 5.9 to another version --- fetch-sources.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fetch-sources.sh b/fetch-sources.sh index 69ab591..65f8ce0 100755 --- a/fetch-sources.sh +++ b/fetch-sources.sh @@ -7,6 +7,9 @@ mkdir -p ./downloads # Fetch sources cd ./downloads if [[ -d "$SWIFT_SRCDIR" ]]; then + cd swift-corelibs-foundation + git stash + echo "$SWIFT_SRCDIR exists" cd $SWIFT_SRCDIR git stash @@ -67,6 +70,5 @@ patch -d . -p1 <$SRC_ROOT/patches/0001-Swift-fix-find-libstdc++-for-cxx-interop. if [[ $SWIFT_VERSION == *"5.9"* ]]; then echo "Apply Foundation strlcpy/strlcat patch for Swift 5.9" cd ../swift-corelibs-foundation - git stash patch -d . -p1 <$SRC_ROOT/patches/0002-Foundation-5.9-check-for-strlcpy-strlcat.patch fi From 408e3e92aa81c79bdf6bd920978d41fc6854e6c9 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Sun, 12 Jan 2025 13:13:06 -0500 Subject: [PATCH 25/27] Use host arch when fixing Foundation arches --- build-foundation.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build-foundation.sh b/build-foundation.sh index 7b5da00..abcd600 100755 --- a/build-foundation.sh +++ b/build-foundation.sh @@ -49,8 +49,9 @@ echo "Install Foundation" (cd $FOUNDATION_BUILDDIR && ninja install) echo "Fix-up archs" -find ${FOUNDATION_INSTALL_PREFIX}/lib/swift/linux -name "x86_64*.swiftmodule" -execdir mv {} ${SWIFT_TARGET_ARCH}-unknown-linux-gnueabihf.swiftmodule \; -find ${FOUNDATION_INSTALL_PREFIX}/lib/swift/linux -name "x86_64*.swiftdoc" -execdir mv {} ${SWIFT_TARGET_ARCH}-unknown-linux-gnueabihf.swiftdoc \; +HOST_ARCH=$(uname -m) +find ${FOUNDATION_INSTALL_PREFIX}/lib/swift/linux -name "${HOST_ARCH}*.swiftmodule" -execdir mv {} ${SWIFT_TARGET_ARCH}-unknown-linux-gnueabihf.swiftmodule \; +find ${FOUNDATION_INSTALL_PREFIX}/lib/swift/linux -name "${HOST_ARCH}*.swiftdoc" -execdir mv {} ${SWIFT_TARGET_ARCH}-unknown-linux-gnueabihf.swiftdoc \; # Restore Dispatch headers cp -rf ${LIBDISPATCH_INSTALL_PREFIX}/* ${STAGING_DIR}/usr/ From c87d5b91ad2f0ee0bd298a84ff9bb7bbf8d4966f Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Sun, 12 Jan 2025 18:14:29 -0500 Subject: [PATCH 26/27] Don't search for GCC_INSTALL_DIR if sysroot doesn't exist --- swift-define | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/swift-define b/swift-define index ae70b51..c8a98f8 100644 --- a/swift-define +++ b/swift-define @@ -32,7 +32,11 @@ SWIFT_BUILD_CONFIGURATION="${SWIFT_BUILD_CONFIGURATION:=Release}" SWIFTPM_CONFIGURATION="${SWIFTPM_CONFIGURATION:=release}" SWIFT_PACKAGE_SRCDIR="${SWIFT_PACKAGE_SRCDIR:=$SRC_ROOT/swift-hello}" SWIFT_PACKAGE_BUILDDIR="${SWIFT_PACKAGE_BUILDDIR:=$SWIFT_PACKAGE_SRCDIR/.build}" -GCC_INSTALL_DIR=${GCC_INSTALL_DIR:=$(dirname $(find ${STAGING_DIR} -name crtbegin.o))} +if [ -d ${STAGING_DIR} ]; then + GCC_INSTALL_DIR=$(dirname $(find ${STAGING_DIR} -name crtbegin.o)) +else + GCC_INSTALL_DIR=${STAGING_DIR} +fi # Build Paths LLVM_SRCDIR=$SRC_ROOT/downloads/llvm-project From c24e548dbf3704051d7ad6d43aa21a9a907edb4f Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Sun, 12 Jan 2025 18:33:36 -0500 Subject: [PATCH 27/27] Restore missing checkout update and re-save of swift --- .github/actions/checkout-swift/action.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/actions/checkout-swift/action.yml b/.github/actions/checkout-swift/action.yml index 5664d8f..64e9663 100644 --- a/.github/actions/checkout-swift/action.yml +++ b/.github/actions/checkout-swift/action.yml @@ -16,12 +16,10 @@ runs: with: key: ${{ inputs.swift-workspace-cache }} path: downloads - - if: ${{ steps.restore-workspace.outputs.cache-hit != 'true' }} - name: Checkout Sources + - name: Checkout Sources shell: bash run: SWIFT_VERSION=${{ inputs.swift-tag }} ./fetch-sources.sh - - if: ${{ steps.restore-workspace.outputs.cache-hit != 'true' }} - uses: actions/cache/save@v4 + - uses: actions/cache/save@v4 with: key: ${{ inputs.swift-workspace-cache }} path: downloads