diff --git a/.github/workflows/build-llvm.yml b/.github/workflows/build-llvm.yml index 914a8131..1a531caf 100644 --- a/.github/workflows/build-llvm.yml +++ b/.github/workflows/build-llvm.yml @@ -23,7 +23,7 @@ on: branches: [main-turn-off] jobs: - build: + build-llvm: strategy: fail-fast: false matrix: @@ -150,117 +150,17 @@ jobs: --build-dir=build \ ${EXTRA_ARGS} - - name: Build clice using installed LLVM - if: ${{ !matrix.target_triple }} - shell: bash - run: | - pixi run cmake-config ${{ matrix.llvm_mode }} ON -- \ - "-DCLICE_ENABLE_LTO=${{ matrix.lto }}" \ - "-DLLVM_INSTALL_PATH=.llvm/build-install" - pixi run cmake-build ${{ matrix.llvm_mode }} - - - name: Build clice using installed LLVM (cross-compile) - if: ${{ matrix.target_triple }} - shell: bash - run: | - ENV="${{ matrix.pixi_env || 'package' }}" - pixi run -e "$ENV" cmake-config ${{ matrix.llvm_mode }} ON -- \ - "-DCLICE_ENABLE_LTO=${{ matrix.lto }}" \ - "-DCLICE_TARGET_TRIPLE=${{ matrix.target_triple }}" \ - "-DLLVM_INSTALL_PATH=.llvm/build-install" - pixi run -e "$ENV" cmake-build ${{ matrix.llvm_mode }} - - - name: Verify cross-compiled binary architecture - if: ${{ matrix.target_triple && runner.os != 'Windows' }} - shell: bash - run: | - BINARY="build/${{ matrix.llvm_mode }}/bin/clice" - echo "Binary info:" - file "$BINARY" - case "${{ matrix.target_triple }}" in - aarch64-linux-gnu) file "$BINARY" | grep -q "aarch64" ;; - x86_64-apple-darwin) file "$BINARY" | grep -q "x86_64" ;; - esac - - - name: Upload cross-compiled clice for functional test - if: ${{ matrix.target_triple && matrix.lto == 'OFF' }} + # Upload raw install directory for validation (non-LTO only, one per platform/config). + # Artifact name matches the key used by test-cmake.yml: llvm-install-{target_triple|os}-{mode} + - name: Upload LLVM install for validation + if: ${{ matrix.lto == 'OFF' }} uses: actions/upload-artifact@v4 with: - name: cross-clice-${{ matrix.target_triple }}-${{ matrix.llvm_mode }} - path: | - build/${{ matrix.llvm_mode }}/bin/ - build/${{ matrix.llvm_mode }}/lib/ - if-no-files-found: error + name: llvm-install-${{ matrix.target_triple || matrix.os }}-${{ matrix.llvm_mode }} + path: .llvm/build-install/ retention-days: 1 - - name: Run tests - if: ${{ !matrix.target_triple }} - shell: bash - run: pixi run test ${{ matrix.llvm_mode }} - - # Prune is only supported for native builds (requires linking clice to test). - # Cross-compiled targets reuse the native prune manifest of the same OS. - - name: Prune LLVM static libraries (Debug/RelWithDebInfo no LTO) - if: (!matrix.target_triple) && (matrix.llvm_mode == 'Debug' || (matrix.llvm_mode == 'RelWithDebInfo' && matrix.lto == 'OFF')) - shell: bash - run: | - MANIFEST="pruned-libs-${{ matrix.os }}.json" - echo "LLVM_PRUNED_MANIFEST=${MANIFEST}" >> "${GITHUB_ENV}" - python3 scripts/prune-llvm-bin.py \ - --action discover \ - --install-dir ".llvm/build-install/lib" \ - --build-dir "build/${{ matrix.llvm_mode }}" \ - --max-attempts 60 \ - --sleep-seconds 60 \ - --manifest "${MANIFEST}" - - - name: Upload pruned-libs manifest - if: (!matrix.target_triple) && matrix.llvm_mode == 'RelWithDebInfo' && matrix.lto == 'OFF' - uses: actions/upload-artifact@v4 - with: - name: llvm-pruned-libs-${{ matrix.os }} - path: ${{ env.LLVM_PRUNED_MANIFEST }} - if-no-files-found: error - compression-level: 0 - - - name: Apply pruned-libs manifest (RelWithDebInfo + LTO, native only) - if: (!matrix.target_triple) && matrix.llvm_mode == 'RelWithDebInfo' && matrix.lto == 'ON' - shell: bash - env: - GH_TOKEN: ${{ github.token }} - run: | - MANIFEST="pruned-libs-${{ matrix.os }}.json" - python3 scripts/prune-llvm-bin.py \ - --action apply \ - --manifest "${MANIFEST}" \ - --install-dir ".llvm/build-install/lib" \ - --build-dir "build/${{ matrix.llvm_mode }}" \ - --gh-run-id "${{ github.run_id }}" \ - --gh-artifact "llvm-pruned-libs-${{ matrix.os }}" \ - --gh-download-dir "artifacts" \ - --max-attempts 60 \ - --sleep-seconds 60 - - # For cross-compiled LTO builds, apply the native prune manifest. - # The unused library set is arch-independent (same API surface). - - name: Apply pruned-libs manifest (cross-compile + LTO) - if: matrix.target_triple && matrix.lto == 'ON' - shell: bash - env: - GH_TOKEN: ${{ github.token }} - run: | - MANIFEST="pruned-libs-${{ matrix.os }}.json" - python3 scripts/prune-llvm-bin.py \ - --action apply \ - --manifest "${MANIFEST}" \ - --install-dir ".llvm/build-install/lib" \ - --build-dir "build/${{ matrix.llvm_mode }}" \ - --gh-run-id "${{ github.run_id }}" \ - --gh-artifact "llvm-pruned-libs-${{ matrix.os }}" \ - --gh-download-dir "artifacts" \ - --max-attempts 60 \ - --sleep-seconds 60 - + # Package as .tar.xz for the final clice-llvm release (all entries). - name: Package LLVM install directory shell: bash run: | @@ -269,7 +169,6 @@ jobs: MODE_TAG="debug" fi - # Determine arch/platform/toolchain from target triple or runner OS if [[ -n "${{ matrix.target_triple }}" ]]; then case "${{ matrix.target_triple }}" in x86_64-apple-darwin) @@ -304,56 +203,25 @@ jobs: ARCHIVE="${ARCH}-${PLATFORM}-${TOOLCHAIN}-${MODE_TAG}${SUFFIX}.tar.xz" set -eo pipefail - tar -C .llvm -cf - build-install | xz -T0 -9 -c > "${ARCHIVE}" + tar -C .llvm/build-install -cf - . | xz -T0 -9 -c > "${ARCHIVE}" echo "LLVM_INSTALL_ARCHIVE=${ARCHIVE}" >> "${GITHUB_ENV}" - - name: Upload LLVM install artifact + - name: Upload LLVM release archive uses: actions/upload-artifact@v4 with: name: ${{ env.LLVM_INSTALL_ARCHIVE }} path: ${{ env.LLVM_INSTALL_ARCHIVE }} if-no-files-found: error - test-cross: - needs: build - strategy: - fail-fast: false - matrix: - include: - - os: macos-15-intel - llvm_mode: RelWithDebInfo - target_triple: x86_64-apple-darwin - - os: ubuntu-24.04-arm - llvm_mode: RelWithDebInfo - target_triple: aarch64-linux-gnu - - os: windows-11-arm - llvm_mode: RelWithDebInfo - target_triple: aarch64-pc-windows-msvc - runs-on: ${{ matrix.os }} - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - uses: ./.github/actions/setup-pixi - with: - environments: test-run - - - name: Download cross-compiled clice - uses: actions/download-artifact@v4 - with: - name: cross-clice-${{ matrix.target_triple }}-${{ matrix.llvm_mode }} - path: build/${{ matrix.llvm_mode }}/ - - - name: Make binaries executable - if: runner.os != 'Windows' - run: chmod +x build/${{ matrix.llvm_mode }}/bin/* - - - name: Run tests - run: pixi run -e test-run test ${{ matrix.llvm_mode }} + validate: + needs: build-llvm + uses: ./.github/workflows/test-cmake.yml + with: + llvm_from_artifact: true upload: - needs: build - if: ${{ !cancelled() && inputs.llvm_version && !inputs.skip_upload }} + needs: [build-llvm, validate] + if: ${{ inputs.llvm_version && !inputs.skip_upload }} runs-on: ubuntu-24.04 permissions: contents: read diff --git a/.github/workflows/test-cmake.yml b/.github/workflows/test-cmake.yml index f9ad986c..a8122322 100644 --- a/.github/workflows/test-cmake.yml +++ b/.github/workflows/test-cmake.yml @@ -2,6 +2,11 @@ name: cmake on: workflow_call: + inputs: + llvm_from_artifact: + description: "Download LLVM from workflow artifacts instead of release" + type: boolean + default: false env: CCACHE_DIR: ${{ github.workspace }}/.cache/ccache @@ -53,7 +58,15 @@ jobs: with: environments: ${{ matrix.pixi_env || 'default' }} + - name: Download LLVM install + if: ${{ inputs.llvm_from_artifact }} + uses: actions/download-artifact@v4 + with: + name: llvm-install-${{ matrix.target_triple || matrix.os }}-${{ matrix.build_type }} + path: .llvm-install/ + - name: Restore compiler cache + if: ${{ !inputs.llvm_from_artifact }} uses: actions/cache@v4 with: path: ${{ runner.os == 'Windows' && '.cache/sccache' || '.cache/ccache' }} @@ -62,6 +75,7 @@ jobs: ${{ runner.os }}-${{ matrix.build_type }}-${{ matrix.target_triple || 'native' }}-ccache- - name: Zero cache stats + if: ${{ !inputs.llvm_from_artifact }} run: | ENV="${{ matrix.pixi_env || 'default' }}" if [ "$RUNNER_OS" = "Windows" ]; then @@ -74,15 +88,28 @@ jobs: - name: Build (native) if: ${{ !matrix.target_triple }} - run: pixi run build ${{ matrix.build_type }} ON + shell: bash + run: | + if [ "${{ inputs.llvm_from_artifact }}" = "true" ]; then + pixi run cmake-config ${{ matrix.build_type }} ON -- \ + "-DLLVM_INSTALL_PATH=.llvm-install" + pixi run cmake-build ${{ matrix.build_type }} + else + pixi run build ${{ matrix.build_type }} ON + fi - name: Build (cross-compile) if: ${{ matrix.target_triple }} shell: bash run: | ENV="${{ matrix.pixi_env || 'default' }}" + EXTRA_ARGS="" + if [ "${{ inputs.llvm_from_artifact }}" = "true" ]; then + EXTRA_ARGS="-DLLVM_INSTALL_PATH=.llvm-install" + fi pixi run -e "$ENV" cmake-config ${{ matrix.build_type }} OFF -- \ - "-DCLICE_TARGET_TRIPLE=${{ matrix.target_triple }}" + "-DCLICE_TARGET_TRIPLE=${{ matrix.target_triple }}" \ + $EXTRA_ARGS pixi run -e "$ENV" cmake-build ${{ matrix.build_type }} - name: Upload cross-compiled binaries @@ -101,7 +128,7 @@ jobs: run: pixi run test ${{ matrix.build_type }} - name: Print cache stats and stop server - if: always() + if: ${{ always() && !inputs.llvm_from_artifact }} run: | ENV="${{ matrix.pixi_env || 'default' }}" if [ "$RUNNER_OS" = "Windows" ]; then diff --git a/scripts/download-llvm.sh b/scripts/download-llvm.sh index 3a640e03..ae7ba3df 100755 --- a/scripts/download-llvm.sh +++ b/scripts/download-llvm.sh @@ -10,7 +10,7 @@ fi WORKFLOW_ID="$1" mkdir -p artifacts -gh run download "${WORKFLOW_ID}" --dir artifacts +gh run download "${WORKFLOW_ID}" --dir artifacts --pattern "*.tar.xz" echo "Downloaded artifacts:" find artifacts -maxdepth 4 -type f -print