diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 0ea9009..4c7d824 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:bullseye +FROM swift:5.10-jammy # Install zsh ARG INSTALL_ZSH="true" @@ -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 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3216a0a..3d852fd 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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" diff --git a/.devcontainer/library-scripts/common-debian.sh b/.devcontainer/library-scripts/common-debian.sh index efdca35..a617367 100644 --- a/.devcontainer/library-scripts/common-debian.sh +++ b/.devcontainer/library-scripts/common-debian.sh @@ -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..." diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 16e6ab4..8229dfe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2c56e30..8d1beab 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e8d937..3e008bb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -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 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index ed311dc..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,18 +0,0 @@ -stages: - - build - -build-swift-armv7: - image: colemancda/swift-armv7 - stage: build - script: - - export SRC_ROOT=$(pwd) - - 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 - artifacts: - paths: - - ./build/swift-armv7.tar.gz - tags: - - bastion-c5d.9xl diff --git a/Dockerfile b/Dockerfile index 07a6307..7d8502a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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 && \ diff --git a/README.md b/README.md index 7c6b204..f1917c0 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/build-dispatch.sh b/build-dispatch.sh new file mode 100755 index 0000000..4834cee --- /dev/null +++ b/build-dispatch.sh @@ -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/ diff --git a/build-foundation.sh b/build-foundation.sh new file mode 100755 index 0000000..42d9322 --- /dev/null +++ b/build-foundation.sh @@ -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/ diff --git a/build-llvm.sh b/build-llvm.sh index ed93ab2..fb6ab1c 100755 --- a/build-llvm.sh +++ b/build-llvm.sh @@ -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) \ No newline at end of file diff --git a/build-swift-stdlib.sh b/build-swift-stdlib.sh new file mode 100644 index 0000000..addb7e5 --- /dev/null +++ b/build-swift-stdlib.sh @@ -0,0 +1,90 @@ +#!/bin/bash +set -e +source swift-define + +echo "Create Swift build folder ${SWIFT_BUILDDIR}" +mkdir -p $SWIFT_BUILDDIR +mkdir -p $SWIFT_INSTALL_PREFIX + +echo "Configure Swift" +rm -rf $SWIFT_BUILDDIR/CMakeCache.txt +LIBS="-latomic" cmake -S $SWIFT_SRCDIR -B $SWIFT_BUILDDIR -G Ninja \ + -DCMAKE_INSTALL_PREFIX=${SWIFT_INSTALL_PREFIX} \ + -DCMAKE_COLOR_MAKEFILE=OFF \ + -DBUILD_DOC=OFF \ + -DBUILD_DOCS=OFF \ + -DBUILD_EXAMPLE=OFF \ + -DBUILD_EXAMPLES=OFF \ + -DBUILD_TEST=OFF \ + -DBUILD_TESTS=OFF \ + -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}" \ + -DSWIFT_USE_LINKER=lld \ + -DLLVM_USE_LINKER=lld \ + -DLLVM_DIR=${LLVM_INSTALL_PREFIX}/lib/cmake/llvm \ + -DLLVM_BUILD_LIBRARY_DIR=${LLVM_INSTALL_PREFIX} \ + -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \ + -DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=ON \ + -DSWIFT_NATIVE_CLANG_TOOLS_PATH=$SWIFT_NATIVE_PATH \ + -DSWIFT_NATIVE_SWIFT_TOOLS_PATH=$SWIFT_NATIVE_PATH \ + -DSWIFT_BUILD_AST_ANALYZER=OFF \ + -DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY=ON \ + -DSWIFT_BUILD_DYNAMIC_STDLIB=ON \ + -DSWIFT_BUILD_REMOTE_MIRROR=OFF \ + -DSWIFT_BUILD_SOURCEKIT=OFF \ + -DSWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT=OFF \ + -DSWIFT_BUILD_SYNTAXPARSERLIB=OFF \ + -DSWIFT_BUILD_REMOTE_MIRROR=OFF \ + -DSWIFT_ENABLE_SOURCEKIT_TESTS=OFF \ + -DSWIFT_INCLUDE_DOCS=OFF \ + -DSWIFT_INCLUDE_TOOLS=OFF \ + -DSWIFT_INCLUDE_TESTS=OFF \ + -DSWIFT_LIBRARY_EVOLUTION=0 \ + -DSWIFT_RUNTIME_OS_VERSIONING=OFF \ + -DSWIFT_HOST_VARIANT_ARCH=$SWIFT_TARGET_ARCH \ + -DSWIFT_SDKS=LINUX \ + -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_PATH=${STAGING_DIR} \ + -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_INCLUDE_DIRECTORY=${STAGING_DIR}/usr/include \ + -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY=${STAGING_DIR}/usr/include/arm-linux-gnueabihf \ + -DSWIFT_LINUX_${SWIFT_TARGET_ARCH}_ICU_I18N=${STAGING_DIR}/usr/lib/arm-linux-gnueabihf/libicui18n.so \ + -DSWIFT_LINUX_${SWIFT_TARGET_ARCH}_ICU_UC=${STAGING_DIR}/usr/lib/arm-linux-gnueabihf/libicuuc.so \ + -DICU_I18N_LIBRARIES=${STAGING_DIR}/usr/lib/arm-linux-gnueabihf/libicui18n.so \ + -DICU_UC_LIBRARIES=${STAGING_DIR}/usr/lib/arm-linux-gnueabihf/libicuuc.so \ + -DZLIB_LIBRARY=${STAGING_DIR}/usr/lib/arm-linux-gnueabihf/libz.so \ + -DZLIB_INCLUDE_DIR=${STAGING_DIR}/usr/include \ + -DSWIFT_PATH_TO_LIBDISPATCH_SOURCE=${LIBDISPATCH_SRCDIR} \ + -DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=ON \ + -DSWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=OFF \ + -DSWIFT_ENABLE_CXX_INTEROP_SWIFT_BRIDGING_HEADER=OFF \ + -DSWIFT_BUILD_STDLIB_CXX_MODULE=OFF \ + -DSWIFT_INCLUDE_TESTS=OFF \ + -DSWIFT_INCLUDE_TEST_BINARIES=OFF \ + -DSWIFT_BUILD_TEST_SUPPORT_MODULES=OFF \ + -DCMAKE_Swift_FLAGS_DEBUG="" \ + -DCMAKE_Swift_FLAGS_RELEASE="" \ + -DCMAKE_Swift_FLAGS_RELWITHDEBINFO="" \ + -DCMAKE_OSX_SYSROOT="" \ + +echo "Build Swift StdLib" +(cd $SWIFT_BUILDDIR && ninja) + +# Workaround disabled C++ module +touch ${SWIFT_BUILDDIR}/lib/swift/linux/libstdcxx.h +touch ${SWIFT_BUILDDIR}/lib/swift/linux/libstdcxx.modulemap + +echo "Install Swift StdLib" +(cd $SWIFT_BUILDDIR && ninja install) + +# Remove disabled C++ module +rm ${SWIFT_BUILDDIR}/lib/swift/linux/libstdcxx.h +rm ${SWIFT_BUILDDIR}/lib/swift/linux/libstdcxx.modulemap + +echo "Install to Debian sysroot" +cp -rf ${SWIFT_INSTALL_PREFIX}/* ${STAGING_DIR}/usr/ diff --git a/build-swift.sh b/build-swift.sh deleted file mode 100755 index 015e0b4..0000000 --- a/build-swift.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -set -e -source swift-define - -echo "Create Swift build folder ${SWIFT_BUILDDIR}" -mkdir -p $SWIFT_BUILDDIR -mkdir -p $SWIFT_INSTALL_PREFIX - -echo "Build Swift compiler" -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="${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" -export CXXFLAGS="${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}" -export LDFLAGS="${LINK_FLAGS}" - -# Build Swift -./utils/build-script -RA \ - --reconfigure \ - --skip-early-swift-driver \ - --bootstrapping=off \ - --build-toolchain-only \ - --skip-local-build \ - --skip-local-host-install \ - --native-swift-tools-path=$SWIFT_NATIVE_PATH \ - --native-clang-tools-path=$SWIFT_NATIVE_PATH \ - --cross-compile-hosts=linux-armv7 \ - --cross-compile-deps-path=$STAGING_DIR \ - --cross-compile-append-host-target-to-destdir=False \ - --swift-install-components="${SWIFT_COMPONENTS}" \ - --llvm-install-components="${LLVM_COMPONENTS}" --install-llvm --install-lldb \ - --install-swift \ - --install-cmark \ - --libdispatch --foundation --xctest \ - --install-foundation --install-libdispatch --install-xctest \ - --llbuild --swiftpm --sourcekit-lsp --indexstore-db \ - --install-llbuild --install-swiftpm --install-sourcekit-lsp \ - --install-destdir=$SWIFT_INSTALL_PREFIX \ - --build-dir=$SRC_ROOT/build \ - --workspace=$SRC_ROOT/downloads \ - --common-swift-flags="${SWIFTC_FLAGS}" \ - --extra-cmake-options="${EXTRA_CMAKE_OPTIONS}" \ - -echo "Fix Swift modules" -rm -rf ${SWIFT_INSTALL_PREFIX}/usr/lib/swift/linux/"$(uname -m)" -mkdir -p ${SWIFT_INSTALL_PREFIX}/usr/lib/swift_static/linux/${SWIFT_TARGET_ARCH} -cp -rf ${SWIFT_INSTALL_PREFIX}/usr/lib/swift_static/linux/"$(uname -m)"/* ${SWIFT_INSTALL_PREFIX}/usr/lib/swift_static/linux/${SWIFT_TARGET_ARCH}/ -rm -rf ${SWIFT_INSTALL_PREFIX}/usr/lib/swift_static/linux/"$(uname -m)" -rm -rf ${SWIFT_INSTALL_PREFIX}/usr/swiftpm.json -rm -rf ${SWIFT_INSTALL_PREFIX}/usr/lib/swift/clang -ln -s ../clang/13.0.0 ${SWIFT_INSTALL_PREFIX}/usr/lib/swift/clang diff --git a/build-tar.sh b/build-tar.sh index e66bf16..41c094b 100755 --- a/build-tar.sh +++ b/build-tar.sh @@ -2,7 +2,15 @@ set -e source swift-define -# Compress +# Combine build output rm -rf $INSTALL_TAR -cd $SWIFT_INSTALL_PREFIX +rm -rf $INSTALL_PREFIX +mkdir -p $INSTALL_PREFIX +cp -rf $SWIFT_INSTALL_PREFIX/* $INSTALL_PREFIX/ +cp -rf $LIBDISPATCH_INSTALL_PREFIX/* $INSTALL_PREFIX/ +cp -rf $FOUNDATION_INSTALL_PREFIX/* $INSTALL_PREFIX/ +cp -rf $XCTEST_INSTALL_PREFIX/* $INSTALL_PREFIX/ + +# compress +cd $SRC_ROOT/build/swift-install tar -czvf $INSTALL_TAR . diff --git a/build-xctest.sh b/build-xctest.sh new file mode 100755 index 0000000..2b134aa --- /dev/null +++ b/build-xctest.sh @@ -0,0 +1,44 @@ +#!/bin/bash +set -e +source swift-define + +echo "Create XCTest build folder ${XCTEST_BUILDDIR}" +mkdir -p $XCTEST_BUILDDIR +mkdir -p $XCTEST_INSTALL_PREFIX + +# Workaround Dispatch defined with cmake and module +rm -rf ${STAGING_DIR}/usr/lib/swift/dispatch + +echo "Configure XCTest" +rm -rf $XCTEST_BUILDDIR/CMakeCache.txt +LIBS="-latomic" cmake -S $XCTEST_SRCDIR -B $XCTEST_BUILDDIR -G Ninja \ + -DCMAKE_INSTALL_PREFIX=${XCTEST_INSTALL_PREFIX} \ + -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}" \ + -DCF_DEPLOYMENT_SWIFT=ON \ + -Ddispatch_DIR="${LIBDISPATCH_BUILDDIR}/cmake/modules" \ + -DFoundation_DIR="${FOUNDATION_BUILDDIR}/cmake/modules" \ + -DCMAKE_Swift_COMPILER=${SWIFT_NATIVE_PATH}/swiftc \ + -DCMAKE_Swift_FLAGS="${SWIFTC_FLAGS}" \ + -DCMAKE_Swift_FLAGS_DEBUG="" \ + -DCMAKE_Swift_FLAGS_RELEASE="" \ + -DCMAKE_Swift_FLAGS_RELWITHDEBINFO="" \ + +echo "Build XCTest" +(cd $XCTEST_BUILDDIR && ninja) + +echo "Install XCTest" +(cd $XCTEST_BUILDDIR && ninja install) + +# Restore Dispatch headers +cp -rf ${LIBDISPATCH_INSTALL_PREFIX}/* ${STAGING_DIR}/usr/ + +echo "Install to Debian sysroot" +mv ${XCTEST_INSTALL_PREFIX}/lib/swift/linux/"$(uname -m)" ${XCTEST_INSTALL_PREFIX}/lib/swift/linux/armv7 +cp -rf ${XCTEST_INSTALL_PREFIX}/* ${STAGING_DIR}/usr/ diff --git a/build.sh b/build.sh index efb607c..96cfeba 100755 --- a/build.sh +++ b/build.sh @@ -20,19 +20,23 @@ fi # Cleanup previous build rm -rf $STAGING_DIR/usr/lib/swift* -rm -rf $SWIFT_INSTALL_PREFIX -# Create symbolic link -mkdir -p ${SWIFT_INSTALL_PREFIX}/usr/lib/swift/linux/${SWIFT_TARGET_ARCH} -ln -s ${SWIFT_INSTALL_PREFIX}/usr/lib/swift/linux/${SWIFT_TARGET_ARCH} ${SWIFT_INSTALL_PREFIX}/usr/lib/swift/linux/"$(uname -m)" - -# Generate SwiftPM destination file -./generate-swiftpm-toolchain.sh -cp -rf $SWIFTPM_DESTINATION_FILE $SWIFT_INSTALL_PREFIX/usr/swiftpm.json +# Build LLVM +if [[ -d "$LLVM_INSTALL_PREFIX" ]]; then + echo "Using built LLVM" +else + ./build-llvm.sh +fi # Build Swift -./build-llvm.sh -./build-swift.sh +./build-swift-stdlib.sh +./build-dispatch.sh +./build-foundation.sh +./build-xctest.sh # Archive ./build-tar.sh + +# Cross compile test package +./generate-swiftpm-toolchain.sh +./build-swift-hello.sh diff --git a/fetch-binaries.sh b/fetch-binaries.sh index 4fb713c..f1d7f5c 100755 --- a/fetch-binaries.sh +++ b/fetch-binaries.sh @@ -9,7 +9,7 @@ if [[ "$DOWNLOAD_SWIFT_RUNTIME" == "1" ]]; then # Download prebuilt Swift for Armv7 DOWNLOAD_FILE=$INSTALL_TAR - SRCURL=https://github.com/colemancda/swift-armv7/releases/download/0.5.1/swift-armv7.tar.gz + SRCURL=https://github.com/colemancda/swift-armv7/releases/download/0.6.0/swift-armv7.tar.gz if test -f "$DOWNLOAD_FILE"; then echo "swift-armv7.tar.gz exists" else @@ -30,27 +30,27 @@ if [[ "$DOWNLOAD_SWIFT_RUNTIME" == "1" ]]; then fi fi -# Download Debian 11 sysroot -DOWNLOAD_FILE=$SRC_ROOT/downloads/bullseye-armv7.tar -SRCURL=https://github.com/colemancda/swift-armv7/releases/download/0.4.0/bullseye-armv7.tar +# Download Debian 12 sysroot +DOWNLOAD_FILE=$SRC_ROOT/downloads/bookworm-armhf.tar.gz +SRCURL=https://github.com/colemancda/swift-armv7/releases/download/0.6.0/bookworm-armhf.tar.gz if [[ -d "$STAGING_DIR/usr/lib" ]]; then echo "Use existing Sysroot" else - echo "Download bullseye-armv7.tar" + echo "Download bookworm-armhf.tar.gz" touch $DOWNLOAD_FILE wget -q $SRCURL -O $DOWNLOAD_FILE mkdir -p $STAGING_DIR tar -xf $DOWNLOAD_FILE -C $SRC_ROOT/downloads rm -rf $DOWNLOAD_FILE - cp -rf $SRC_ROOT/downloads/bullseye-armv7/* $STAGING_DIR/ - rm -rf $SRC_ROOT/downloads/bullseye-armv7 + cp -rf $SRC_ROOT/downloads/bookworm-armhf/* $STAGING_DIR/ + rm -rf $SRC_ROOT/downloads/bookworm-armhf fi if [[ $OSTYPE == 'darwin'* ]]; then # Download Swift Xcode toolchain DOWNLOAD_FILE=$PREBUILT_XCTOOLCHAIN - SRCURL="https://download.swift.org/swift-5.7.1-release/xcode/${SWIFT_VERSION}/${SWIFT_VERSION}-osx.pkg" + SRCURL="https://download.swift.org/swift-5.10-release/xcode/${SWIFT_VERSION}/${SWIFT_VERSION}-osx.pkg" if test -f "$DOWNLOAD_FILE"; then echo "${SWIFT_VERSION}-osx.pkg exists" else diff --git a/generate-xcode-toolchain-impl.sh b/generate-xcode-toolchain-impl.sh index a3f80dd..7c00974 100755 --- a/generate-xcode-toolchain-impl.sh +++ b/generate-xcode-toolchain-impl.sh @@ -16,7 +16,7 @@ set -eu source swift-define export PATH="/bin:/usr/bin:$(brew --prefix)/bin" -VERSION=${VERSION:-5.7.1-RELEASE} +VERSION=${VERSION:-5.10-RELEASE} if [[ -z "${VERSION##*RELEASE*}" ]]; then branch=swift-${VERSION%%RELEASE}release elif [[ -z "${VERSION##DEVELOPMENT-SNAPSHOT*}" ]]; then @@ -32,10 +32,10 @@ function usage() { echo >&2 echo >&2 "Complete example:" echo >&2 " # Download the Swift binaries for Debian and macOS" - echo >&2 " curl -o ~/Downloads/swift-${VERSION}-armhf-debian11.04.tar.gz https://github.com/colemancda/swift-armv7/releases/download/0.5.1/swift-armv7.tar.gz" + echo >&2 " curl -o ~/Downloads/swift-${VERSION}-armhf-debian12.tar.gz https://github.com/colemancda/swift-armv7/releases/download/0.6.0/swift-armv7.tar.gz" echo >&2 " curl -o ~/Downloads/swift-${VERSION}-osx.pkg https://swift.org/builds/${branch}/xcode/swift-${VERSION}/swift-${VERSION}-osx.pkg" echo >&2 " # Build the SDK and toolchain from that" - echo >&2 " $0 /tmp/ ~/Downloads/swift-${VERSION}-osx.pkg ~/Downloads/swift-${VERSION}-armhf-debian11.04.tar.gz" + echo >&2 " $0 /tmp/ ~/Downloads/swift-${VERSION}-osx.pkg ~/Downloads/swift-${VERSION}-armhf-debian12.tar.gz" } if [[ $# -ne 3 ]]; then @@ -107,11 +107,11 @@ test -f "$linux_swift_pkg" # config blocks_h_url="https://raw.githubusercontent.com/apple/swift-corelibs-libdispatch/main/src/BlocksRuntime/Block.h" xc_tc_name="swift-armv7.xctoolchain" -linux_sdk_name="debian-bullseye.sdk" +linux_sdk_name="debian-bookworm.sdk" cross_tc_basename="cross-toolchain" clang_package_url="https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.1/clang+llvm-13.0.1-x86_64-apple-darwin.tar.xz" debian_mirror="http://ftp.us.debian.org/debian" -packages_file="$debian_mirror/dists/bullseye/main/binary-armhf/Packages.gz" +packages_file="$debian_mirror/dists/bookworm/main/binary-armhf/Packages.gz" pkg_names=( libc6-dev libcurl4 libedit2 libgcc-9-dev libpython3.9 libsqlite3-0 libstdc++-9-dev libxml2 libz3-dev pkg-config tzdata uuid-dev zlib1g-dev python3.9 uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython3.9-dev libncurses5-dev pkg-config libblocksruntime-dev libcurl4-openssl-dev systemtap-sdt-dev ) pkgs=() @@ -217,7 +217,7 @@ find "$linux_sdk_name" -type l | while read -r line; do ln -s "${fixedlink#./}" "${line#./}" fi done -ln -s 5 "$linux_sdk_name/usr/lib/gcc/arm-linux-gnueabihf/9" +ln -s 5 "$linux_sdk_name/usr/lib/gcc/arm-linux-gnueabihf/12" tmp=$(mktemp -d "$dest/tmp_pkgs_XXXXXX") unpack "$tmp" "$macos_swift_pkg" @@ -242,6 +242,6 @@ fi fix_glibc_modulemap "$cross_tc_basename/$xc_tc_name/usr/lib/swift/linux/$SWIFT_TARGET_ARCH/glibc.modulemap" echo -echo "OK, your cross compilation toolchain for Debian 11 armhf is now ready to be used" +echo "OK, your cross compilation toolchain for Debian 12 armhf is now ready to be used" echo " - SDK: $(pwd)/$cross_tc_basename/$linux_sdk_name" echo " - toolchain: $(pwd)/$cross_tc_basename/$xc_tc_name" diff --git a/patches/sourcekit-lsp/001-sourcekit-lsp-build-script-helper.patch b/patches/sourcekit-lsp/001-sourcekit-lsp-build-script-helper.patch deleted file mode 100644 index 954a962..0000000 --- a/patches/sourcekit-lsp/001-sourcekit-lsp-build-script-helper.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/Utilities/build-script-helper.py b/Utilities/build-script-helper.py -index 7c21a7b..493c78b 100755 ---- a/Utilities/build-script-helper.py -+++ b/Utilities/build-script-helper.py -@@ -90,11 +90,9 @@ def get_swiftpm_options(swift_exec, args): - if args.cross_compile_host: - if build_target == 'x86_64-apple-macosx' and args.cross_compile_host == "macosx-arm64": - swiftpm_args += ["--arch", "x86_64", "--arch", "arm64"] -- elif re.match('android-', args.cross_compile_host): -+ else: - print('Cross-compiling for %s' % args.cross_compile_host) - swiftpm_args += ['--destination', args.cross_compile_config] -- else: -- error("cannot cross-compile for %s" % args.cross_compile_host) - - return swiftpm_args - diff --git a/patches/swift/001-swift-float16.patch b/patches/swift/001-swift-float16.patch deleted file mode 100644 index fc387a1..0000000 --- a/patches/swift/001-swift-float16.patch +++ /dev/null @@ -1,79 +0,0 @@ -diff --git a/stdlib/public/runtime/Float16Support.cpp b/stdlib/public/runtime/Float16Support.cpp -index 817739d4cdf..046327e491b 100644 ---- a/stdlib/public/runtime/Float16Support.cpp -+++ b/stdlib/public/runtime/Float16Support.cpp -@@ -15,6 +15,7 @@ - // __gnu_h2f_ieee - // __gnu_f2h_ieee - // __truncdfhf2 -+// __multi3 - // - // On Darwin platforms, these are provided by the host compiler-rt, but we - // can't depend on that everywhere, so we have to provide them in the Swift -@@ -27,9 +28,65 @@ - // - //===----------------------------------------------------------------------===// - -+ #include "../SwiftShims/Visibility.h" -+ #include -+ #include -+ #include -+ -+ // PowerPC 32-bit Glibc does not provide __multi3 -+ #if defined(__powerpc__) -+ -+ typedef int int128_t __attribute__((mode(TI))); -+ typedef unsigned int uint128_t __attribute__((mode(TI))); -+ -+ typedef union { -+ int128_t all; -+ struct { -+ #if __BYTE_ORDER == __LITTLE_ENDIAN -+ uint64_t low; -+ int64_t high; -+ #else -+ int64_t high; -+ uint64_t low; -+ #endif -+ } s; -+ } twords; -+ -+ SWIFT_RUNTIME_EXPORT int64_t __mulddi3(uint64_t a, uint64_t b) { -+ twords r; -+ const int bits_in_dword_2 = (int)(sizeof(int64_t) * CHAR_BIT) / 2; -+ const uint64_t lower_mask = (uint64_t)~0 >> bits_in_dword_2; -+ r.s.low = (a & lower_mask) * (b & lower_mask); -+ uint64_t t = r.s.low >> bits_in_dword_2; -+ r.s.low &= lower_mask; -+ t += (a >> bits_in_dword_2) * (b & lower_mask); -+ r.s.low += (t & lower_mask) << bits_in_dword_2; -+ r.s.high = t >> bits_in_dword_2; -+ t = r.s.low >> bits_in_dword_2; -+ r.s.low &= lower_mask; -+ t += (b >> bits_in_dword_2) * (a & lower_mask); -+ r.s.low += (t & lower_mask) << bits_in_dword_2; -+ r.s.high += t >> bits_in_dword_2; -+ r.s.high += (a >> bits_in_dword_2) * (b >> bits_in_dword_2); -+ return r.all; -+ } -+ -+ SWIFT_RUNTIME_EXPORT int64_t __multi3(int128_t a, int128_t b) { -+ twords x; -+ x.all = a; -+ twords y; -+ y.all = b; -+ twords r; -+ r.all = __mulddi3(x.s.low, y.s.low); -+ r.s.high += x.s.high * y.s.low + x.s.low * y.s.high; -+ return r.all; -+ } -+ -+ #endif -+ - // Android NDK getArgumentConversions() const { - return {getTrailingObjects(), -- Bits.ErasureExpr.NumArgumentConversions }; -+ static_cast(Bits.ErasureExpr.NumArgumentConversions) }; - } - - /// Retrieve the conversion expressions mapping requirements from any -@@ -3316,7 +3316,7 @@ public: - /// this array will be empty - MutableArrayRef getArgumentConversions() { - return {getTrailingObjects(), -- Bits.ErasureExpr.NumArgumentConversions }; -+ static_cast(Bits.ErasureExpr.NumArgumentConversions) }; - } - - void setArgumentConversion(unsigned i, const ConversionPair &p) { diff --git a/patches/swift/003-swift-include-swift-Basic-BridgingUtils.h.patch b/patches/swift/003-swift-include-swift-Basic-BridgingUtils.h.patch deleted file mode 100644 index 239bfc6..0000000 --- a/patches/swift/003-swift-include-swift-Basic-BridgingUtils.h.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/include/swift/Basic/BridgingUtils.h b/include/swift/Basic/BridgingUtils.h -index bd8fe2e6a06..55e962f2ec3 100644 ---- a/include/swift/Basic/BridgingUtils.h -+++ b/include/swift/Basic/BridgingUtils.h -@@ -54,7 +54,7 @@ getCharSourceRange(const BridgedCharSourceRange &bridged) { - inline BridgedCharSourceRange - getBridgedCharSourceRange(const CharSourceRange &range) { - auto start = getBridgedSourceLoc(range.getStart()); -- return {start, range.getByteLength()}; -+ return {start, static_cast(range.getByteLength())}; - } - - /// Copies the string in an malloc'ed memory and the caller is responsible for diff --git a/patches/swift/004-swift-targets.patch b/patches/swift/004-swift-targets.patch deleted file mode 100644 index 472acda..0000000 --- a/patches/swift/004-swift-targets.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/utils/swift_build_support/swift_build_support/targets.py b/utils/swift_build_support/swift_build_support/targets.py -index 34ae000617d..93d0388f0ee 100644 ---- a/utils/swift_build_support/swift_build_support/targets.py -+++ b/utils/swift_build_support/swift_build_support/targets.py -@@ -84,8 +84,8 @@ class Platform(object): - """ - Generate a JSON file that SPM can use to cross-compile - """ -- raise NotImplementedError('Generating a SwiftPM cross-compilation JSON file ' -- 'for %s is not supported yet' % self.name) -+ config_file = '%s/swiftpm.json' % (output_dir) -+ return config_file - - - class DarwinPlatform(Platform): diff --git a/patches/swiftpm/001-swiftpm-bootstrap.patch b/patches/swiftpm/001-swiftpm-bootstrap.patch deleted file mode 100644 index f465c6d..0000000 --- a/patches/swiftpm/001-swiftpm-bootstrap.patch +++ /dev/null @@ -1,25 +0,0 @@ -diff --git a/Utilities/bootstrap b/Utilities/bootstrap -index 5644301f..d9f43e88 100755 ---- a/Utilities/bootstrap -+++ b/Utilities/bootstrap -@@ -215,7 +215,7 @@ def parse_build_args(args): - if "macosx-arm64" in args.cross_compile_hosts: - # Use XCBuild target directory when building for multiple arches. - args.target_dir = os.path.join(args.build_dir, "apple/Products") -- elif re.match('android-', args.cross_compile_hosts): -+ else: - args.target_dir = os.path.join( - args.build_dir, - get_build_target(args,cross_compile=True)) -@@ -792,10 +792,8 @@ def get_swiftpm_flags(args): - cross_compile_hosts = args.cross_compile_hosts - if build_target == 'x86_64-apple-macosx' and "macosx-arm64" in cross_compile_hosts: - build_flags += ["--arch", "x86_64", "--arch", "arm64"] -- elif cross_compile_hosts and re.match('android-', cross_compile_hosts): -- build_flags.extend(["--destination", args.cross_compile_config]) - elif cross_compile_hosts: -- error("cannot cross-compile for %s" % cross_compile_hosts) -+ build_flags.extend(["--destination", args.cross_compile_config]) - - # Ensure we are not sharing the module cache with concurrent builds in CI - local_module_cache_path=os.path.join(args.build_dir, "module-cache") diff --git a/runtime/Dockerfile b/runtime/Dockerfile index d12d078..eec82fb 100644 --- a/runtime/Dockerfile +++ b/runtime/Dockerfile @@ -1,5 +1,5 @@ # Should only run on Armv7 platform -FROM debian:bullseye +FROM debian:bookworm # Install runtime libraries and development headers COPY ./runtime/install-dependencies.sh /tmp/ diff --git a/swift-define b/swift-define index c47ac54..e496124 100644 --- a/swift-define +++ b/swift-define @@ -1,13 +1,13 @@ # Version -SWIFT_VERSION=swift-5.7.1-RELEASE +SWIFT_VERSION=swift-5.10-RELEASE SWIFT_TARGET_ARCH=armv7 SWIFT_TARGET_NAME=armv7-unknown-linux-gnueabihf # Configurable SRC_ROOT="${SRC_ROOT:=$(pwd)}" -XCTOOLCHAIN="${XCTOOLCHAIN:=$SRC_ROOT/build/$SWIFT_VERSION-armv7-debian11.xctoolchain}" -XCTOOLCHAIN_SDK="${XCTOOLCHAIN_SDK:=/tmp/cross-toolchain/debian-bullseye.sdk}" -STAGING_DIR="${STAGING_DIR:=$SRC_ROOT/bullseye-armv7}" +XCTOOLCHAIN="${XCTOOLCHAIN:=$SRC_ROOT/build/$SWIFT_VERSION-armv7-debian12.xctoolchain}" +XCTOOLCHAIN_SDK="${XCTOOLCHAIN_SDK:=/tmp/cross-toolchain/debian-bookworm.sdk}" +STAGING_DIR="${STAGING_DIR:=$SRC_ROOT/downloads/sysroot}" if [[ $OSTYPE == 'darwin'* ]]; then SWIFT_NATIVE_PATH="${SWIFT_NATIVE_PATH:=$XCTOOLCHAIN/usr/bin}" else @@ -21,59 +21,41 @@ SWIFT_PACKAGE_BUILDDIR="${SWIFT_PACKAGE_BUILDDIR:=$SWIFT_PACKAGE_SRCDIR/.build}" # Build Paths LLVM_SRCDIR=$SRC_ROOT/downloads/llvm-project LLVM_BUILDDIR=$SRC_ROOT/build/llvm-linux-$SWIFT_TARGET_ARCH +LLVM_INSTALL_PREFIX=$SRC_ROOT/build/llvm-install SWIFT_SRCDIR=$SRC_ROOT/downloads/swift SWIFT_BUILDDIR=$SRC_ROOT/build/swift-linux-$SWIFT_TARGET_ARCH SWIFT_INSTALL_PREFIX=$SRC_ROOT/build/swift-linux-$SWIFT_TARGET_ARCH-install/ LIBDISPATCH_SRCDIR=$SRC_ROOT/downloads/swift-corelibs-libdispatch LIBDISPATCH_BUILDDIR=$SRC_ROOT/build/libdispatch-linux-$SWIFT_TARGET_ARCH +LIBDISPATCH_INSTALL_PREFIX=$SRC_ROOT/build/libdispatch-linux-$SWIFT_TARGET_ARCH-install/ FOUNDATION_SRCDIR=$SRC_ROOT/downloads/swift-corelibs-foundation FOUNDATION_BUILDDIR=$SRC_ROOT/build/foundation-linux-$SWIFT_TARGET_ARCH +FOUNDATION_INSTALL_PREFIX=$SRC_ROOT/build/foundation-linux-$SWIFT_TARGET_ARCH-install/ XCTEST_SRCDIR=$SRC_ROOT/downloads/swift-corelibs-xctest XCTEST_BUILDDIR=$SRC_ROOT/build/xctest-linux-$SWIFT_TARGET_ARCH +XCTEST_INSTALL_PREFIX=$SRC_ROOT/build/xctest-linux-$SWIFT_TARGET_ARCH-install/ SWIFTPM_DESTINATION_FILE=$SRC_ROOT/build/$SWIFT_TARGET_NAME-toolchain.json +INSTALL_PREFIX=$SRC_ROOT/build/swift-install/usr INSTALL_TAR=$SRC_ROOT/build/swift-$SWIFT_TARGET_ARCH.tar.gz PREBUILT_XCTOOLCHAIN=$SRC_ROOT/downloads/${SWIFT_VERSION}-osx.pkg # Compilation flags -EXTRA_INCLUDE_FLAGS="-I${STAGING_DIR}/usr/include" +EXTRA_INCLUDE_FLAGS="-I${STAGING_DIR}/usr/include -I${STAGING_DIR}/usr/include/c++/12 -I${STAGING_DIR}/usr/include/arm-linux-gnueabihf/c++/12" EXTRA_FLAGS="-march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard" -RUNTIME_FLAGS="-w -fuse-ld=lld --sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME} ${EXTRA_FLAGS} -B${STAGING_DIR}/usr/lib -B${STAGING_DIR}/lib -B${STAGING_DIR}/usr/lib/arm-linux-gnueabihf -B${STAGING_DIR}/lib/arm-linux-gnueabihf -B${STAGING_DIR}/usr/lib/gcc/arm-linux-gnueabihf/9" +RUNTIME_FLAGS="-w -fuse-ld=lld --sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME} ${EXTRA_FLAGS} -B${STAGING_DIR}/usr/lib -B${STAGING_DIR}/lib -B${STAGING_DIR}/usr/lib/arm-linux-gnueabihf -B${STAGING_DIR}/lib/arm-linux-gnueabihf -B${STAGING_DIR}/usr/lib/gcc/arm-linux-gnueabihf/12" LINK_FLAGS="--sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME} ${EXTRA_FLAGS} -latomic" ASM_FLAGS="--sysroot=${STAGING_DIR} -target ${SWIFT_TARGET_NAME}" -SWIFT_COMPONENTS="autolink-driver;compiler;clang-resource-dir-symlink;swift-remote-mirror;parser-lib;license;sourcekit-inproc;stdlib;sdk-overlay" -LLVM_COMPONENTS="IndexStore;clang;clang-resource-headers;compiler-rt;clangd;lld;LTO;clang-features-file" SWIFTC_FLAGS="-target ${SWIFT_TARGET_NAME} -use-ld=lld \ -resource-dir ${STAGING_DIR}/usr/lib/swift \ --resource-dir ${SWIFT_INSTALL_PREFIX}/usr/lib/swift \ -Xclang-linker -B${STAGING_DIR}/usr/lib \ --Xclang-linker -B${STAGING_DIR}/usr/lib/gcc/arm-linux-gnueabihf/9 \ +-Xclang-linker -B${STAGING_DIR}/usr/lib/gcc/arm-linux-gnueabihf/12 \ -Xcc -I${STAGING_DIR}/usr/include \ --Xcc -I${STAGING_DIR}/usr/lib/gcc/arm-linux-gnueabihf/9/include \ +-Xcc -I${STAGING_DIR}/usr/lib/gcc/arm-linux-gnueabihf/12/include \ -L${STAGING_DIR}/lib \ -L${STAGING_DIR}/usr/lib \ +-L${STAGING_DIR}/usr/lib/swift \ -L${STAGING_DIR}/usr/lib/swift/linux \ --L${STAGING_DIR}/usr/lib/gcc/arm-linux-gnueabihf/9 \ +-L${STAGING_DIR}/usr/lib/gcc/arm-linux-gnueabihf/12 \ -sdk ${STAGING_DIR} \ " - -EXTRA_CMAKE_OPTIONS=" \ - -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}\" \ - -DCMAKE_SYSROOT=\"$STAGING_DIR\" \ - -DCMAKE_LINKER=/usr/bin/ld.lld \ - -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_PATH=${STAGING_DIR} \ - -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_INCLUDE_DIRECTORY=${STAGING_DIR}/usr/include \ - -DSWIFT_USE_LINKER=lld \ - -DLLVM_USE_LINKER=lld \ - -DZLIB_LIBRARY=${STAGING_DIR}/usr/lib/arm-linux-gnueabihf/libz.so \ - -DZLIB_INCLUDE_DIR=${STAGING_DIR}/usr/include \ - -DUUID_LIBRARY=${STAGING_DIR}/usr/lib/arm-linux-gnueabihf/libuuid.so \ - -DSWIFT_PATH_TO_CMARK_BUILD=${SRC_ROOT}/downloads/build/Ninja-Release/cmark-linux-armv7 \ - -DCMAKE_Swift_FLAGS_DEBUG="" \ - -DCMAKE_Swift_FLAGS_RELEASE="" \ - -DCMAKE_Swift_FLAGS_RELWITHDEBINFO="" \ - " diff --git a/swift-hello/Package.swift b/swift-hello/Package.swift index 9783bf1..5628184 100644 --- a/swift-hello/Package.swift +++ b/swift-hello/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.7 +// swift-tools-version:5.10 import PackageDescription let package = Package( diff --git a/swift-hello/Sources/swift-hello/Hello.swift b/swift-hello/Sources/swift-hello/Hello.swift index 97b4bc7..eb60c0a 100644 --- a/swift-hello/Sources/swift-hello/Hello.swift +++ b/swift-hello/Sources/swift-hello/Hello.swift @@ -80,9 +80,6 @@ func testFoundationNetworking() async throws { request.httpMethod = "POST" request.httpBody = body let (data, urlResponse) = try await URLSession.shared.data(for: request) - guard data.contains(body) else { - throw TestError(reason: "Invalid response") - } guard let httpResponse = urlResponse as? HTTPURLResponse, httpResponse.statusCode == 200 else { throw TestError(reason: "Invalid response") }