diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 218efba..4003b22 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -97,8 +97,7 @@ jobs: llvm-mingw-*.tar.xz retention-days: 7 - # Build a cross compiler for Linux, targeting Windows. - linux: + linux-profile: if: (github.event_name != 'schedule') || (github.repository == 'mstorsjo/llvm-mingw') needs: [prepare, linux-stage1] runs-on: ubuntu-22.04 @@ -111,8 +110,42 @@ jobs: run: | tar -Jxf llvm-mingw-*.tar.xz rm llvm-mingw-*.tar.xz + mv llvm-mingw* llvm-mingw-stage1 + - name: Build + env: + LLVM_VERSION: ${{needs.prepare.outputs.LLVM_VERSION}} + TAG: ${{needs.prepare.outputs.TAG}} + SOURCE_DATE_EPOCH: ${{needs.prepare.outputs.COMMIT_DATE_UNIX}} + BUILD_DATE: ${{needs.prepare.outputs.BUILD_DATE}} + run: | + # Build LLVM in mostly the same way as it is going to be built in the + # final form. + LLVM_CMAKEFLAGS="-DLLVM_ENABLE_LIBXML2=OFF -DLLDB_ENABLE_PYTHON=OFF" ./build-all.sh --profile $(pwd)/llvm-mingw-stage1 + - uses: actions/upload-artifact@v4 + with: + name: profile + path: | + profile.profdata + retention-days: 7 + + # Build a cross compiler for Linux, targeting Windows. + linux: + if: (github.event_name != 'schedule') || (github.repository == 'mstorsjo/llvm-mingw') + needs: [prepare, linux-stage1, linux-profile] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + name: linux-stage1-ucrt-x86_64-toolchain + - name: Unpack stage1 Clang + run: | + tar -Jxf llvm-mingw-*.tar.xz + rm llvm-mingw-*.tar.xz sudo mv llvm-mingw* /opt/llvm-mingw - echo /opt/llvm-mingw/bin >> $GITHUB_PATH + - uses: actions/download-artifact@v4 + with: + name: profile - name: Build env: LLVM_VERSION: ${{needs.prepare.outputs.LLVM_VERSION}} @@ -120,12 +153,10 @@ jobs: SOURCE_DATE_EPOCH: ${{needs.prepare.outputs.COMMIT_DATE_UNIX}} BUILD_DATE: ${{needs.prepare.outputs.BUILD_DATE}} run: | - mkdir -p install - cp -a /opt/llvm-mingw install # Skip dynamic library dependencies that might make it harder to # run the binaries on other distros (and that have little use within # llvm-mingw). - LLVM_CMAKEFLAGS="-DLLVM_ENABLE_LIBXML2=OFF -DLLDB_ENABLE_PYTHON=OFF" ./build-all.sh $(pwd)/install/llvm-mingw --with-clang --thinlto --llvm-only + LLVM_CMAKEFLAGS="-DLLVM_ENABLE_LIBXML2=OFF -DLLDB_ENABLE_PYTHON=OFF" ./build-all.sh /opt/llvm-mingw $(pwd)/install/llvm-mingw --thinlto --pgo --llvm-only .github/workflows/store-version.sh install/llvm-mingw/versions.txt ./test-libcxx-module.sh $(pwd)/install/llvm-mingw ./run-tests.sh $(pwd)/install/llvm-mingw @@ -145,7 +176,7 @@ jobs: # libraries that were built in the 'linux' step above. linux-cross-aarch64: if: (github.event_name != 'schedule') || (github.repository == 'mstorsjo/llvm-mingw') - needs: [linux-stage1, prepare] + needs: [linux-stage1, linux-profile, prepare] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 @@ -157,7 +188,9 @@ jobs: tar -Jxf llvm-mingw-*.tar.xz rm llvm-mingw-*.tar.xz sudo mv llvm-mingw* /opt/llvm-mingw - echo /opt/llvm-mingw/bin >> $GITHUB_PATH + - uses: actions/download-artifact@v4 + with: + name: profile - name: Build env: LLVM_VERSION: ${{needs.prepare.outputs.LLVM_VERSION}} @@ -165,7 +198,7 @@ jobs: SOURCE_DATE_EPOCH: ${{needs.prepare.outputs.COMMIT_DATE_UNIX}} run: | sudo apt-get update && sudo apt-get install g++-aarch64-linux-gnu - ./build-all.sh $(pwd)/install/llvm-mingw --no-runtimes --host=aarch64-linux-gnu --with-clang --thinlto + ./build-all.sh /opt/llvm-mingw $(pwd)/install/llvm-mingw --no-runtimes --host=aarch64-linux-gnu --thinlto --pgo .github/workflows/store-version.sh install/llvm-mingw/versions.txt - name: Assemble the cross-built toolchain run: | @@ -259,7 +292,7 @@ jobs: # Build a cross compiler for macOS, targeting Windows. macos: if: (github.event_name != 'schedule') || (github.repository == 'mstorsjo/llvm-mingw') - needs: [prepare, macos-stage1] + needs: [prepare, macos-stage1, linux-profile] runs-on: macos-latest steps: - uses: actions/checkout@v4 @@ -271,7 +304,9 @@ jobs: tar -Jxf llvm-*.tar.xz rm llvm-*.tar.xz mv llvm* $HOME/llvm - echo $HOME/llvm/bin >> $GITHUB_PATH + - uses: actions/download-artifact@v4 + with: + name: profile - name: Build env: LLVM_VERSION: ${{needs.prepare.outputs.LLVM_VERSION}} @@ -285,8 +320,7 @@ jobs: # form. Therefore, autodetection will pick them up, but linking # universal binaries fails as those libraries are unavailable in the # other (x86_64) architecture form. - export SDKROOT=$(xcrun --show-sdk-path) - MACOS_REDIST=1 LLVM_CMAKEFLAGS="-DLLVM_ENABLE_ZSTD=OFF -DLLDB_ENABLE_PYTHON=OFF" ./build-all.sh $(pwd)/install/llvm-mingw --with-clang --thinlto + MACOS_REDIST=1 LLVM_CMAKEFLAGS="-DLLVM_ENABLE_ZSTD=OFF -DLLDB_ENABLE_PYTHON=OFF" ./build-all.sh $HOME/llvm $(pwd)/install/llvm-mingw --thinlto --pgo .github/workflows/store-version.sh install/llvm-mingw/versions.txt ./test-libcxx-module.sh $(pwd)/install/llvm-mingw ./run-tests.sh $(pwd)/install/llvm-mingw @@ -363,7 +397,7 @@ jobs: # architectures). The binaries built here match actual releases quite closely. linux-cross-windows: if: (github.event_name != 'schedule') || (github.repository == 'mstorsjo/llvm-mingw') - needs: [linux-stage1, prepare] + needs: [linux-stage1, linux-profile, prepare] runs-on: ubuntu-latest strategy: fail-fast: false @@ -384,6 +418,9 @@ jobs: sudo mv llvm-mingw* /opt/llvm-mingw echo /opt/llvm-mingw/bin >> $GITHUB_PATH - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + name: profile - name: Build env: LLVM_VERSION: ${{needs.prepare.outputs.LLVM_VERSION}} @@ -394,7 +431,7 @@ jobs: BUILD_DATE: ${{needs.prepare.outputs.BUILD_DATE}} run: | sudo apt-get update && sudo apt-get install libltdl-dev swig autoconf-archive - ./build-cross-tools.sh /opt/llvm-mingw $(pwd)/install/llvm-mingw ${{matrix.arch}} --with-python --thinlto + ./build-cross-tools.sh /opt/llvm-mingw $(pwd)/install/llvm-mingw ${{matrix.arch}} --with-python --thinlto --pgo .github/workflows/store-version.sh install/llvm-mingw/versions.txt cd install NAME=llvm-mingw-$TAG-${{matrix.crt}}-${{matrix.arch}} @@ -774,6 +811,7 @@ jobs: rm -rf msys2* rm -rf linux-stage1-* rm -rf macos-llvm* + rm -rf profile* mv *-toolchain/*.zip *-toolchain/*.tar.xz . - name: Upload binaries env: