From 224bb199e7228c1521c6577546a4eb62ee43d9ef Mon Sep 17 00:00:00 2001 From: Fabrice de Gans Date: Wed, 16 Oct 2024 13:16:08 -0700 Subject: [PATCH] [Mac Build] Add stdlib build * Add cache files for the stdlib build * Adapt stdlib job to build for both Windows and Mac. --- .github/workflows/build-toolchain.yml | 64 +++++++- .github/workflows/swift-toolchain.yml | 206 +++++++++----------------- Runtime-MacOSX-arm64.cmake | 20 +++ Runtime-MacOSX-x86_64.cmake | 20 +++ 4 files changed, 172 insertions(+), 138 deletions(-) create mode 100644 Runtime-MacOSX-arm64.cmake create mode 100644 Runtime-MacOSX-x86_64.cmake diff --git a/.github/workflows/build-toolchain.yml b/.github/workflows/build-toolchain.yml index a5ab4e90..a783f463 100644 --- a/.github/workflows/build-toolchain.yml +++ b/.github/workflows/build-toolchain.yml @@ -354,72 +354,114 @@ jobs: "include": [ { "arch": "amd64", + "cpu": "x86_64", "os": "Windows", + "platform": "Windows", + "triple": "x86_64-unknown-windows-msvc", + "triple_no_api_level": "x86_64-unknown-windows-msvc", "cc": "cl", "cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}", "cxx": "cl", "cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}", "swiftflags": "${{ steps.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}", + "cmake_linker_flags": "-D CMAKE_EXE_LINKER_FLAGS=\"${{ steps.context.outputs.WINDOWS_CMAKE_EXE_LINKER_FLAGS }}\" -D CMAKE_SHARED_LINKER_FLAGS=\"${{ steps.context.outputs.WINDOWS_CMAKE_EXE_LINKER_FLAGS }}\"", + "llvm_flags": "", "extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=AMD64 -D CMAKE_MT=mt" }, { "arch": "arm64", + "cpu": "aarch64", "os": "Windows", + "platform": "Windows", + "triple": "aarch64-unknown-windows-msvc", + "triple_no_api_level": "aarch64-unknown-windows-msvc", "cc": "cl", "cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}", "cxx": "cl", "cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}", "swiftflags": "${{ steps.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}", + "cmake_linker_flags": "-D CMAKE_EXE_LINKER_FLAGS=\"${{ steps.context.outputs.WINDOWS_CMAKE_EXE_LINKER_FLAGS }}\" -D CMAKE_SHARED_LINKER_FLAGS=\"${{ steps.context.outputs.WINDOWS_CMAKE_EXE_LINKER_FLAGS }}\"", + "llvm_flags": "", "extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=ARM64 -D CMAKE_MT=mt" }, { "arch": "x86", + "cpu": "i686", "os": "Windows", + "platform": "Windows", + "triple": "i686-unknown-windows-msvc", + "triple_no_api_level": "i686-unknown-windows-msvc", "cc": "cl", "cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}", "cxx": "cl", "cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}", "swiftflags": "", + "cmake_linker_flags": "-D CMAKE_EXE_LINKER_FLAGS=\"${{ steps.context.outputs.WINDOWS_CMAKE_EXE_LINKER_FLAGS }}\" -D CMAKE_SHARED_LINKER_FLAGS=\"${{ steps.context.outputs.WINDOWS_CMAKE_EXE_LINKER_FLAGS }}\"", + "llvm_flags": "", "extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=X86 -D CMAKE_MT=mt" }, { "arch": "arm64", + "cpu": "aarch64", "os": "Android", + "platform": "Android", + "triple": "aarch64-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }}", + "triple_no_api_level": "aarch64-unknown-linux-android", "cc": "clang", "cflags": "${{ steps.context.outputs.ANDROID_CMAKE_C_FLAGS }}", "cxx": "clang++", "cxxflags": "${{ steps.context.outputs.ANDROID_CMAKE_CXX_FLAGS }}", - "swiftflags": "", + "swiftflags": "-sdk $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Xclang-linker -target -Xclang-linker aarch64-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }} -Xclang-linker --sysroot -Xclang-linker $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Xclang-linker -resource-dir -Xclang-linker $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/lib/clang/17 -L ${{ github.workspace }}/BinaryCache/swift/lib/swift/android -g", + "cmake_linker_flags": "-D CMAKE_EXE_LINKER_FLAGS=\"${{ steps.context.outputs.ANDROID_CMAKE_EXE_LINKER_FLAGS }}\" -D CMAKE_SHARED_LINKER_FLAGS=\"${{ steps.context.outputs.ANDROID_CMAKE_SHARED_LINKER_FLAGS }}\"", + "llvm_flags": "-DCMAKE_SYSTEM_PROCESSOR=aarch64 -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }}", "extra_flags": "-DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a" }, { "arch": "armv7", + "cpu": "armv7-a", "os": "Android", + "platform": "Android", + "triple": "armv7-unknown-linux-androideabi${{ inputs.ANDROID_API_LEVEL }}", + "triple_no_api_level": "armv7-unknown-linux-androideabi", "cc": "clang", "cflags": "${{ steps.context.outputs.ANDROID_CMAKE_C_FLAGS }}", "cxx": "clang++", "cxxflags": "${{ steps.context.outputs.ANDROID_CMAKE_CXX_FLAGS }}", - "swiftflags": "", + "swiftflags": "-sdk $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Xclang-linker -target -Xclang-linker armv7a-unknown-linux-androideabi${{ inputs.ANDROID_API_LEVEL }} -Xclang-linker --sysroot -Xclang-linker $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Xclang-linker -resource-dir -Xclang-linker $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/lib/clang/17 -L ${{ github.workspace }}/BinaryCache/swift/lib/swift/android -g", + "cmake_linker_flags": "-D CMAKE_EXE_LINKER_FLAGS=\"${{ steps.context.outputs.ANDROID_CMAKE_EXE_LINKER_FLAGS }}\" -D CMAKE_SHARED_LINKER_FLAGS=\"${{ steps.context.outputs.ANDROID_CMAKE_SHARED_LINKER_FLAGS }}\"", + "llvm_flags": "-DCMAKE_SYSTEM_PROCESSOR=armv7-a -DLLVM_HOST_TRIPLE=armv7a-unknown-linux-androideabi${{ inputs.ANDROID_API_LEVEL }}", "extra_flags": "-DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a" }, { "arch": "i686", + "cpu": "i686", "os": "Android", + "platform": "Android", + "triple": "i686-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }}", + "triple_no_api_level": "i686-unknown-linux-android", "cc": "clang", "cflags": "${{ steps.context.outputs.ANDROID_CMAKE_C_FLAGS }}", "cxx": "clang++", "cxxflags": "${{ steps.context.outputs.ANDROID_CMAKE_CXX_FLAGS }}", - "swiftflags": "", + "swiftflags": "-sdk $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Xclang-linker -target -Xclang-linker i686-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }} -Xclang-linker --sysroot -Xclang-linker $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Xclang-linker -resource-dir -Xclang-linker $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/lib/clang/17 -L ${{ github.workspace }}/BinaryCache/swift/lib/swift/android -g", + "cmake_linker_flags": "-D CMAKE_EXE_LINKER_FLAGS=\"${{ steps.context.outputs.ANDROID_CMAKE_EXE_LINKER_FLAGS }}\" -D CMAKE_SHARED_LINKER_FLAGS=\"${{ steps.context.outputs.ANDROID_CMAKE_SHARED_LINKER_FLAGS }}\"", + "llvm_flags": "-DCMAKE_SYSTEM_PROCESSOR=i686 -DLLVM_HOST_TRIPLE=i686-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }}", "extra_flags": "-DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=x86" }, { "arch": "x86_64", + "cpu": "x86_64", "os": "Android", + "platform": "Android", + "triple": "x86_64-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }}", + "triple_no_api_level": "x86_64-unknown-linux-android", "cc": "clang", "cflags": "${{ steps.context.outputs.ANDROID_CMAKE_C_FLAGS }}", "cxx": "clang++", "cxxflags": "${{ steps.context.outputs.ANDROID_CMAKE_CXX_FLAGS }}", - "swiftflags": "", + "swiftflags": "-sdk $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Xclang-linker -target -Xclang-linker x86_64-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }} -Xclang-linker --sysroot -Xclang-linker $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Xclang-linker -resource-dir -Xclang-linker $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/lib/clang/17 -L ${{ github.workspace }}/BinaryCache/swift/lib/swift/android -g", + "cmake_linker_flags": "-D CMAKE_EXE_LINKER_FLAGS=\"${{ steps.context.outputs.ANDROID_CMAKE_EXE_LINKER_FLAGS }}\" -D CMAKE_SHARED_LINKER_FLAGS=\"${{ steps.context.outputs.ANDROID_CMAKE_SHARED_LINKER_FLAGS }}\"", + "llvm_flags": "-DCMAKE_SYSTEM_PROCESSOR=x86_64 -DLLVM_HOST_TRIPLE=x86_64-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }}", "extra_flags": "-DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=x86_64" } ] @@ -471,22 +513,34 @@ jobs: "include": [ { "arch": "x86_64", + "cpu": "x86_64", "os": "Darwin", + "platform": "MacOSX", + "triple": "x86_64-apple-macosx15.0", + "triple_no_api_level": "x86_64-apple-macosx15.0", "cc": "clang", "cflags": "${{ steps.context.outputs.DARWIN_CMAKE_C_FLAGS }}", "cxx": "clang++", "cxxflags": "${{ steps.context.outputs.DARWIN_CMAKE_CXX_FLAGS }}", "swiftflags": "${{ steps.context.outputs.DARWIN_CMAKE_Swift_FLAGS }}", + "cmake_linker_flags": "-D CMAKE_EXE_LINKER_FLAGS=\"${{ steps.context.outputs.DARWIN_CMAKE_EXE_LINKER_FLAGS }}\" -D CMAKE_SHARED_LINKER_FLAGS=\"${{ steps.context.outputs.DARWIN_CMAKE_SHARED_LINKER_FLAGS }}\"", + "llvm_flags": "", "extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=x86_64 -D CMAKE_OSX_DEPLOYMENT_TARGET=10.15 -D CMAKE_OSX_ARCHITECTURES=x86_64" }, { "arch": "arm64", + "cpu": "aarch64", "os": "Darwin", + "platform": "MacOSX", + "triple": "aarch64-apple-macosx15.0", + "triple_no_api_level": "aarch64-apple-macosx15.0", "cc": "clang", "cflags": "${{ steps.context.outputs.DARWIN_CMAKE_C_FLAGS }}", "cxx": "clang++", "cxxflags": "${{ steps.context.outputs.DARWIN_CMAKE_CXX_FLAGS }}", "swiftflags": "${{ steps.context.outputs.DARWIN_CMAKE_Swift_FLAGS }}", + "cmake_linker_flags": "-D CMAKE_EXE_LINKER_FLAGS=\"${{ steps.context.outputs.DARWIN_CMAKE_EXE_LINKER_FLAGS }}\" -D CMAKE_SHARED_LINKER_FLAGS=\"${{ steps.context.outputs.DARWIN_CMAKE_SHARED_LINKER_FLAGS }}\"", + "llvm_flags": "", "extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=arm64 -D CMAKE_OSX_DEPLOYMENT_TARGET=10.15 -D CMAKE_OSX_ARCHITECTURES=arm64" } ] @@ -578,7 +632,7 @@ jobs: uses: ./.github/workflows/swift-toolchain.yml with: build_os: Darwin - build_arch: aarch64 + build_arch: arm64 build_matrix: ${{ needs.context.outputs.darwin_build_matrix }} host_matrix: ${{ needs.context.outputs.darwin_host_matrix }} target_matrix: ${{ needs.context.outputs.darwin_target_matrix }} diff --git a/.github/workflows/swift-toolchain.yml b/.github/workflows/swift-toolchain.yml index be8621cd..67f9bc73 100644 --- a/.github/workflows/swift-toolchain.yml +++ b/.github/workflows/swift-toolchain.yml @@ -1482,112 +1482,13 @@ jobs: path: ${{ github.workspace }}/BuildRoot/Library/libxml2-${{ inputs.libxml2_version }}/usr stdlib: - # TODO: Build this on macOS or make an equivalent Mac-only job - if: always() && inputs.build_os == 'Windows' && needs.compilers.result == 'success' - needs: [compilers, cmark_gfm] + if: always() && needs.compilers.result == 'success' + needs: [compilers] runs-on: ${{ inputs.default_build_runner }} strategy: fail-fast: false - matrix: - include: - - arch: amd64 - cpu: 'x86_64' - triple: 'x86_64-unknown-windows-msvc' - triple_no_api_level: 'x86_64-unknown-windows-msvc' - cc: '$CLANG_CL' - cflags: ${{ inputs.WINDOWS_CMAKE_C_FLAGS }} - cxx: '$CLANG_CL' - cxxflags: ${{ inputs.WINDOWS_CMAKE_CXX_FLAGS }} - swiftflags: ${{ inputs.CMAKE_Swift_FLAGS }} - os: Windows - llvm_flags: - linker_flags: '-D CMAKE_EXE_LINKER_FLAGS="${{ inputs.WINDOWS_CMAKE_EXE_LINKER_FLAGS }}" -D CMAKE_SHARED_LINKER_FLAGS="${{ inputs.WINDOWS_CMAKE_SHARED_LINKER_FLAGS }}"' - extra_flags: - - - arch: arm64 - cpu: 'aarch64' - triple: 'aarch64-unknown-windows-msvc' - triple_no_api_level: 'aarch64-unknown-windows-msvc' - cc: '$CLANG_CL' - cflags: ${{ inputs.WINDOWS_CMAKE_C_FLAGS }} - cxx: '$CLANG_CL' - cxxflags: ${{ inputs.WINDOWS_CMAKE_CXX_FLAGS }} - swiftflags: ${{ inputs.CMAKE_Swift_FLAGS }} - os: Windows - llvm_flags: - linker_flags: '-D CMAKE_EXE_LINKER_FLAGS="${{ inputs.WINDOWS_CMAKE_EXE_LINKER_FLAGS }}" -D CMAKE_SHARED_LINKER_FLAGS="${{ inputs.WINDOWS_CMAKE_SHARED_LINKER_FLAGS }}"' - extra_flags: - - - arch: x86 - cpu: 'i686' - triple: 'i686-unknown-windows-msvc' - triple_no_api_level: 'i686-unknown-windows-msvc' - cc: '$CLANG_CL' - cflags: ${{ inputs.WINDOWS_CMAKE_C_FLAGS }} - cxx: '$CLANG_CL' - cxxflags: ${{ inputs.WINDOWS_CMAKE_CXX_FLAGS }} - swiftflags: ${{ inputs.CMAKE_Swift_FLAGS }} - os: Windows - llvm_flags: - linker_flags: '-D CMAKE_EXE_LINKER_FLAGS="${{ inputs.WINDOWS_CMAKE_EXE_LINKER_FLAGS }}" -D CMAKE_SHARED_LINKER_FLAGS="${{ inputs.WINDOWS_CMAKE_SHARED_LINKER_FLAGS }}"' - extra_flags: - - - arch: arm64 - cpu: 'aarch64' - triple: 'aarch64-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }}' - triple_no_api_level: aarch64-unknown-linux-android - cc: clang - cflags: ${{ inputs.ANDROID_CMAKE_C_FLAGS }} - cxx: clang++ - cxxflags: ${{ inputs.ANDROID_CMAKE_CXX_FLAGS }} - swiftflags: -sdk $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Xclang-linker -target -Xclang-linker aarch64-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }} -Xclang-linker --sysroot -Xclang-linker $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Xclang-linker -resource-dir -Xclang-linker $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/lib/clang/17 -L ${{ github.workspace }}/BinaryCache/swift/lib/swift/android -g - os: Android - llvm_flags: -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }} - linker_flags: '-D CMAKE_EXE_LINKER_FLAGS="${{ inputs.ANDROID_CMAKE_EXE_LINKER_FLAGS }}" -D CMAKE_SHARED_LINKER_FLAGS="${{ inputs.ANDROID_CMAKE_SHARED_LINKER_FLAGS }}"' - extra_flags: -DSWIFT_BUILD_CLANG_OVERLAYS_SKIP_BUILTIN_FLOAT=YES -DLLVM_ENABLE_LIBCXX=YES -DSWIFT_USE_LINKER=lld -DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a - - - arch: armv7 - cpu: armv7 - triple: 'armv7a-unknown-linux-androideabi${{ inputs.ANDROID_API_LEVEL }}' - triple_no_api_level: armv7-unknown-linux-androideabi - cc: clang - cflags: ${{ inputs.ANDROID_CMAKE_C_FLAGS }} - cxx: clang++ - cxxflags: ${{ inputs.ANDROID_CMAKE_CXX_FLAGS }} - swiftflags: -sdk $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Xclang-linker -target -Xclang-linker armv7a-unknown-linux-androideabi${{ inputs.ANDROID_API_LEVEL }} -Xclang-linker --sysroot -Xclang-linker $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Xclang-linker -resource-dir -Xclang-linker $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/lib/clang/17 -L ${{ github.workspace }}/BinaryCache/swift/lib/swift/android -g - os: Android - llvm_flags: -DCMAKE_SYSTEM_PROCESSOR=armv7-a -DLLVM_HOST_TRIPLE=armv7a-unknown-linux-androideabi${{ inputs.ANDROID_API_LEVEL }} - linker_flags: '-D CMAKE_EXE_LINKER_FLAGS="${{ inputs.ANDROID_CMAKE_EXE_LINKER_FLAGS }}" -D CMAKE_SHARED_LINKER_FLAGS="${{ inputs.ANDROID_CMAKE_SHARED_LINKER_FLAGS }}"' - extra_flags: -DSWIFT_BUILD_CLANG_OVERLAYS_SKIP_BUILTIN_FLOAT=YES -DLLVM_ENABLE_LIBCXX=YES -DSWIFT_USE_LINKER=lld -DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a - - - arch: i686 - cpu: i686 - triple: 'i686-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }}' - triple_no_api_level: i686-unknown-linux-android - cc: clang - cflags: ${{ inputs.ANDROID_CMAKE_C_FLAGS }} - cxx: clang++ - cxxflags: ${{ inputs.ANDROID_CMAKE_CXX_FLAGS }} - swiftflags: -sdk $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Xclang-linker -target -Xclang-linker i686-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }} -Xclang-linker --sysroot -Xclang-linker $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Xclang-linker -resource-dir -Xclang-linker $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/lib/clang/17 -L ${{ github.workspace }}/BinaryCache/swift/lib/swift/android -g - os: Android - llvm_flags: -DCMAKE_SYSTEM_PROCESSOR=i686 -DLLVM_HOST_TRIPLE=i686-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }} - linker_flags: '-D CMAKE_EXE_LINKER_FLAGS="${{ inputs.ANDROID_CMAKE_EXE_LINKER_FLAGS }}" -D CMAKE_SHARED_LINKER_FLAGS="${{ inputs.ANDROID_CMAKE_SHARED_LINKER_FLAGS }}"' - extra_flags: -DSWIFT_BUILD_CLANG_OVERLAYS_SKIP_BUILTIN_FLOAT=YES -DLLVM_ENABLE_LIBCXX=YES -DSWIFT_USE_LINKER=lld -DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=x86 - - - arch: x86_64 - cpu: 'x86_64' - triple: 'x86_64-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }}' - triple_no_api_level: x86_64-unknown-linux-android - cc: clang - cflags: ${{ inputs.ANDROID_CMAKE_C_FLAGS }} - cxx: clang++ - cxxflags: ${{ inputs.ANDROID_CMAKE_CXX_FLAGS }} - swiftflags: -sdk $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Xclang-linker -target -Xclang-linker x86_64-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }} -Xclang-linker --sysroot -Xclang-linker $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Xclang-linker -resource-dir -Xclang-linker $NDKPATH/toolchains/llvm/prebuilt/windows-x86_64/lib/clang/17 -L ${{ github.workspace }}/BinaryCache/swift/lib/swift/android -g - os: Android - llvm_flags: -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DLLVM_HOST_TRIPLE=x86_64-unknown-linux-android${{ inputs.ANDROID_API_LEVEL }} - linker_flags: '-D CMAKE_EXE_LINKER_FLAGS="${{ inputs.ANDROID_CMAKE_EXE_LINKER_FLAGS }}" -D CMAKE_SHARED_LINKER_FLAGS="${{ inputs.ANDROID_CMAKE_SHARED_LINKER_FLAGS }}"' - extra_flags: -DSWIFT_BUILD_CLANG_OVERLAYS_SKIP_BUILTIN_FLOAT=YES -DLLVM_ENABLE_LIBCXX=YES -DSWIFT_USE_LINKER=lld -DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=x86_64 + matrix: ${{ fromJSON(inputs.target_matrix) }} name: ${{ matrix.os }} ${{ matrix.arch }} Standard Library @@ -1595,7 +1496,7 @@ jobs: - name: Download Compilers uses: thebrowsercompany/gha-download-tar-artifact@main with: - name: compilers-Windows-${{ inputs.build_arch }} + name: compilers-${{ inputs.build_os }}-${{ inputs.build_arch }} path: ${{ github.workspace }}/BuildRoot/Library - uses: actions/checkout@v4 @@ -1622,12 +1523,17 @@ jobs: ref: ${{ inputs.swift_experimental_string_processing_revision }} path: ${{ github.workspace }}/SourceCache/swift-experimental-string-processing show-progress: false + - uses: actions/checkout@v4 + if: matrix.os == 'Darwin' + with: + path: ${{ github.workspace }}/SourceCache/swift-build # NOTE(compnerd) While we do not have ABI stability on Windows yet, we use # Swift in the compiler, which requires that we have the Swift runtime. As # we have not yet built the runtime, this requires that we use the runtime # from the previous build. - - name: Install Swift Toolchain + - name: Install Swift Toolchain (Windows) + if: inputs.build_os == 'Windows' uses: compnerd/gha-setup-swift@main with: github-repo: thebrowsercompany/swift-build @@ -1635,6 +1541,13 @@ jobs: release-asset-name: installer-amd64.exe release-tag-name: '20231016.5' + - name: Install Swift Toolchain (Mac) + if: inputs.build_os == 'Darwin' + uses: compnerd/gha-setup-swift@main + with: + branch: swift-6.0.1-release + tag: 6.0.1-RELEASE + # NOTE(compnerd): we execute unconditionally as we use CMake from VSDevEnv - uses: compnerd/gha-setup-vsdevenv@main with: @@ -1642,6 +1555,9 @@ jobs: components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' arch: ${{ matrix.arch }} + - uses: seanmiddleditch/gha-setup-ninja@master + if: inputs.build_os == 'Darwin' + # NOTE(compnerd): we execute unconditionally as we reference outputs - uses: nttld/setup-ndk@v1 id: setup-ndk @@ -1650,9 +1566,10 @@ jobs: - name: Configure LLVM run: | - # NOTE: used by `matrix.cc` - $CLANG_CL = "cl" - $NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }} + $NDKPATH = "${{ steps.setup-ndk.outputs.ndk-path }}" + if ("${{ inputs.build_os }}" -eq "Windows") { + $NDKPATH = cygpath -m $NDKPATH + } cmake -B ${{ github.workspace }}/BinaryCache/llvm ` -D CMAKE_BUILD_TYPE=Release ` @@ -1660,7 +1577,6 @@ jobs: -D CMAKE_C_FLAGS="${{ matrix.cflags }}" ` -D CMAKE_CXX_COMPILER=${{ matrix.cxx }} ` -D CMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" ` - -D CMAKE_MT=mt ` -D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/${{ matrix.os }}.platform/Developer/SDKs/${{ matrix.os }}.sdk/usr ` -D CMAKE_SYSTEM_NAME=${{ matrix.os }} ` ${{ matrix.llvm_flags }} ` @@ -1673,42 +1589,62 @@ jobs: - name: Configure Swift Standard Library run: | - # NOTE: used by `matrix.cc` - $CLANG_CL = cygpath -m ${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/clang-cl.exe - - $SWIFTC = cygpath -m ${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe - $NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }} - - $CMAKE_CPU = if ("${{ matrix.cpu }}" -eq "armv7") { - "armv7-a" + if ("${{ matrix.os }}" -eq "Windows") { + $CC = cygpath -m ${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/clang-cl.exe + $CXX = $CC + $SWIFTC = cygpath -m ${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe + $EXTRA_FLAGS = @( + "-D", "MSVC_C_ARCHITECTURE_ID=${{ matrix.arch }}", + "-D", "MSVC_CXX_ARCHITECTURE_ID=${{ matrix.arch }}" + ) + $CacheFile = "${{ github.workspace }}/SourceCache/swift/cmake/caches/Runtime-${{ matrix.platform }}-${{ matrix.cpu }}.cmake" + Remove-Item env:\SDKROOT + } elseif ("${{ matrix.os }}" -eq "Android") { + $CC = "${{ matrix.cc }}" + $CXX = "${{ matrix.cxx }}" + $SWIFTC = cygpath -m ${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe + $NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }} + $EXTRA_FLAGS = @( + "-D", "SWIFT_BUILD_CLANG_OVERLAYS_SKIP_BUILTIN_FLOAT=YES", + "-D", "LLVM_ENABLE_LIBCXX=YES", + "-D", "SWIFT_USE_LINKER=lld", + "-D", "CMAKE_ANDROID_NDK=${NDKPATH}", + "-D", "SWIFT_ANDROID_NDK_PATH=${NDKPATH}", + "-D", "CMAKE_SYSTEM_PROCESSOR=${{ matrix.cpu }}" + ) + if ("${{ matrix.cpu }}" -eq "armv7-a") { + $Cpu = "armv7" + } else { + $Cpu = "${{ matrix.cpu }}" + } + $CacheFile = "${{ github.workspace }}/SourceCache/swift/cmake/caches/Runtime-${{ matrix.platform }}-${Cpu}.cmake" + Remove-Item env:\SDKROOT } else { - "${{ matrix.cpu }}" + $CC = "${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/clang" + $CXX = "${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/clang++" + $SWIFTC = "${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc" + $CacheFile = "${{ github.workspace }}/SourceCache/swift-build/Runtime-${{ matrix.platform }}-${{ matrix.arch }}.cmake" + $EXTRA_FLAGS = @() } - Remove-Item env:\SDKROOT cmake -B ${{ github.workspace }}/BinaryCache/swift ` - -C ${{ github.workspace }}/SourceCache/swift/cmake/caches/Runtime-${{ matrix.os }}-${{ matrix.cpu }}.cmake ` + -C "${CacheFile}" ` -D CMAKE_BUILD_TYPE=Release ` - -D CMAKE_C_COMPILER=${{ matrix.cc }} ` + -D CMAKE_C_COMPILER="${CC}" ` -D CMAKE_C_FLAGS="${{ matrix.cflags }}" ` -D CMAKE_C_COMPILER_TARGET=${{ matrix.triple }} ` - -D CMAKE_CXX_COMPILER=${{ matrix.cxx }} ` + -D CMAKE_CXX_COMPILER="${CXX}" ` -D CMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" ` -D CMAKE_CXX_COMPILER_TARGET=${{ matrix.triple }} ` - -D CMAKE_MT=mt ` - -D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/${{ matrix.os }}.platform/Developer/SDKs/${{ matrix.os }}.sdk/usr ` + -D CMAKE_INSTALL_PREFIX="${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/${{ matrix.platform }}.platform/Developer/SDKs/${{ matrix.platform }}.sdk/usr" ` -D CMAKE_SYSTEM_NAME=${{ matrix.os }} ` - -D CMAKE_SYSTEM_PROCESSOR=${CMAKE_CPU} ` -D CMAKE_Swift_COMPILER=${SWIFTC} ` -D CMAKE_Swift_COMPILER_WORKS=YES ` -D CMAKE_Swift_COMPILER_TARGET=${{ matrix.triple_no_api_level }} ` -D CMAKE_Swift_FLAGS="-resource-dir ${{ github.workspace }}/BinaryCache/swift/lib/swift ${{ matrix.swiftflags }}" ` - -D MSVC_C_ARCHITECTURE_ID=${{ matrix.arch }} ` - -D MSVC_CXX_ARCHITECTURE_ID=${{ matrix.arch }} ` - ${{ matrix.linker_flags }} ` + @EXTRA_FLAGS ` + ${{ matrix.cmake_linker_flags }} ` ${{ matrix.extra_flags }} ` - -D CMAKE_ANDROID_NDK=${NDKPATH} ` - -D SWIFT_ANDROID_NDK_PATH=${NDKPATH} ` -G Ninja ` -S ${{ github.workspace }}/SourceCache/swift ` -D LLVM_DIR=${{ github.workspace }}/BinaryCache/llvm/lib/cmake/llvm ` @@ -1726,17 +1662,21 @@ jobs: -D SWIFT_PATH_TO_STRING_PROCESSING_SOURCE=${{ github.workspace }}/SourceCache/swift-experimental-string-processing - name: Build Swift Standard Library run: | - Remove-Item env:\SDKROOT + if ("${{ inputs.build_os }}" -eq "Windows") { + Remove-Item env:\SDKROOT + } cmake --build ${{ github.workspace }}/BinaryCache/swift - name: Install Swift Standard Library run: | - Remove-Item env:\SDKROOT + if ("${{ inputs.build_os }}" -eq "Windows") { + Remove-Item env:\SDKROOT + } cmake --build ${{ github.workspace }}/BinaryCache/swift --target install - uses: actions/upload-artifact@v4 with: - name: ${{ matrix.os }}-stdlib-${{ matrix.arch }} - path: ${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/${{ matrix.os }}.platform + name: ${{ matrix.platform }}-stdlib-${{ matrix.arch }} + path: ${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/${{ matrix.platform }}.platform - uses: actions/upload-artifact@v4 if: matrix.os == 'Windows' diff --git a/Runtime-MacOSX-arm64.cmake b/Runtime-MacOSX-arm64.cmake new file mode 100644 index 00000000..437d3845 --- /dev/null +++ b/Runtime-MacOSX-arm64.cmake @@ -0,0 +1,20 @@ +set(SWIFT_HOST_VARIANT_SDK OSX CACHE STRING "") +set(SWIFT_HOST_VARIANT_ARCH arm64 CACHE STRING "") +set(SWIFT_DARWIN_SUPPORTED_ARCHS arm64 CACHE STRING "") +set(SWIFT_PRIMARY_VARIANT_ARCH arm64 CACHE STRING "") + +# NOTE(compnerd) disable the tools, we are trying to build just the standard +# library. +set(SWIFT_INCLUDE_TOOLS NO CACHE BOOL "") + +# NOTE(compnerd) cannot build tests since the tests require the toolchain +set(SWIFT_INCLUDE_TESTS NO CACHE BOOL "") + +# NOTE(compnerd) cannot build docs since that requires perl +set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "") + +# NOTE(compnerd) these are part of the toolchain, not the runtime. +set(SWIFT_BUILD_SOURCEKIT NO CACHE BOOL "") + +# NOTE(compnerd) build with the compiler specified, not a just built compiler. +set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER YES CACHE BOOL "") diff --git a/Runtime-MacOSX-x86_64.cmake b/Runtime-MacOSX-x86_64.cmake new file mode 100644 index 00000000..f239e59a --- /dev/null +++ b/Runtime-MacOSX-x86_64.cmake @@ -0,0 +1,20 @@ +set(SWIFT_HOST_VARIANT_SDK OSX CACHE STRING "") +set(SWIFT_HOST_VARIANT_ARCH x86_64 CACHE STRING "") +set(SWIFT_DARWIN_SUPPORTED_ARCHS x86_64 CACHE STRING "") +set(SWIFT_PRIMARY_VARIANT_ARCH x86_64 CACHE STRING "") + +# NOTE(compnerd) disable the tools, we are trying to build just the standard +# library. +set(SWIFT_INCLUDE_TOOLS NO CACHE BOOL "") + +# NOTE(compnerd) cannot build tests since the tests require the toolchain +set(SWIFT_INCLUDE_TESTS NO CACHE BOOL "") + +# NOTE(compnerd) cannot build docs since that requires perl +set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "") + +# NOTE(compnerd) these are part of the toolchain, not the runtime. +set(SWIFT_BUILD_SOURCEKIT NO CACHE BOOL "") + +# NOTE(compnerd) build with the compiler specified, not a just built compiler. +set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER YES CACHE BOOL "")