|
| 1 | +name: build llvm |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + # if you want to run this workflow, change the branch name to main, |
| 6 | + # if you want to turn off it, change it to non existent branch. |
| 7 | + branches: [main-turn-off] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + # Windows |
| 16 | + - os: windows-2025 |
| 17 | + llvm_mode: Debug |
| 18 | + lto: OFF |
| 19 | + - os: windows-2025 |
| 20 | + llvm_mode: RelWithDebInfo |
| 21 | + lto: OFF |
| 22 | + - os: windows-2025 |
| 23 | + llvm_mode: RelWithDebInfo |
| 24 | + lto: ON |
| 25 | + # Linux |
| 26 | + - os: ubuntu-24.04 |
| 27 | + llvm_mode: Debug |
| 28 | + lto: OFF |
| 29 | + - os: ubuntu-24.04 |
| 30 | + llvm_mode: RelWithDebInfo |
| 31 | + lto: OFF |
| 32 | + - os: ubuntu-24.04 |
| 33 | + llvm_mode: RelWithDebInfo |
| 34 | + lto: ON |
| 35 | + # macOS |
| 36 | + - os: macos-15 |
| 37 | + llvm_mode: Debug |
| 38 | + lto: OFF |
| 39 | + - os: macos-15 |
| 40 | + llvm_mode: RelWithDebInfo |
| 41 | + lto: OFF |
| 42 | + - os: macos-15 |
| 43 | + llvm_mode: RelWithDebInfo |
| 44 | + lto: ON |
| 45 | + |
| 46 | + runs-on: ${{ matrix.os }} |
| 47 | + |
| 48 | + steps: |
| 49 | + - name: Checkout repository |
| 50 | + uses: actions/checkout@v4 |
| 51 | + |
| 52 | + - name: Free Disk Space |
| 53 | + if: runner.os == 'Linux' |
| 54 | + uses: jlumbroso/free-disk-space@main |
| 55 | + |
| 56 | + - name: Increase Swap Space |
| 57 | + if: runner.os == 'Linux' |
| 58 | + run: | |
| 59 | + echo "===== Initial Status =====" |
| 60 | + sudo swapon --show |
| 61 | + free -h |
| 62 | +
|
| 63 | + echo "===== Creating Swap File =====" |
| 64 | + sudo swapoff -a |
| 65 | + sudo fallocate -l 16G /mnt/swapfile |
| 66 | + sudo chmod 600 /mnt/swapfile |
| 67 | + sudo mkswap /mnt/swapfile |
| 68 | + sudo swapon /mnt/swapfile |
| 69 | +
|
| 70 | + echo "===== Final Status =====" |
| 71 | + sudo swapon --show |
| 72 | + free -h |
| 73 | + df -h |
| 74 | +
|
| 75 | + - name: Setup Pixi |
| 76 | + uses: prefix-dev/setup-pixi@v0.9.3 |
| 77 | + with: |
| 78 | + pixi-version: v0.59.0 |
| 79 | + environments: package |
| 80 | + activate-environment: true |
| 81 | + cache: true |
| 82 | + locked: true |
| 83 | + |
| 84 | + - name: Clone llvm-project (21.1.4) |
| 85 | + shell: bash |
| 86 | + run: | |
| 87 | + git clone --branch llvmorg-21.1.4 --depth 1 https://github.com/llvm/llvm-project.git .llvm |
| 88 | +
|
| 89 | + - name: Build LLVM (install-distribution) |
| 90 | + shell: bash |
| 91 | + run: | |
| 92 | + pixi run build-llvm --llvm-src=.llvm --mode="${{ matrix.llvm_mode }}" --lto="${{ matrix.lto }}" --build-dir=build |
| 93 | +
|
| 94 | + - name: Build clice using installed LLVM |
| 95 | + shell: bash |
| 96 | + run: | |
| 97 | + cmake -B build -G Ninja \ |
| 98 | + -DCMAKE_BUILD_TYPE=${{ matrix.llvm_mode }} \ |
| 99 | + -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain.cmake \ |
| 100 | + -DCLICE_ENABLE_TEST=ON \ |
| 101 | + -DCLICE_CI_ENVIRONMENT=ON \ |
| 102 | + -DCLICE_ENABLE_LTO=${{ matrix.lto }} \ |
| 103 | + -DLLVM_INSTALL_PATH=".llvm/build-install" |
| 104 | + cmake --build build |
| 105 | +
|
| 106 | + - name: Run tests |
| 107 | + shell: bash |
| 108 | + run: | |
| 109 | + EXE_EXT="" |
| 110 | + if [[ "${{ runner.os }}" == "Windows" ]]; then |
| 111 | + EXE_EXT=".exe" |
| 112 | + fi |
| 113 | + ./build/bin/unit_tests${EXE_EXT} --test-dir="./tests/data" |
| 114 | + uv run --project tests pytest -s --log-cli-level=INFO tests/integration --executable=./build/bin/clice${EXE_EXT} |
| 115 | +
|
| 116 | + - name: Prune LLVM static libraries (Debug/RelWithDebInfo no LTO) |
| 117 | + if: matrix.llvm_mode == 'Debug' || (matrix.llvm_mode == 'RelWithDebInfo' && matrix.lto == 'OFF') |
| 118 | + shell: bash |
| 119 | + run: | |
| 120 | + MANIFEST="pruned-libs-${{ matrix.os }}.json" |
| 121 | + echo "LLVM_PRUNED_MANIFEST=${MANIFEST}" >> "${GITHUB_ENV}" |
| 122 | + python3 scripts/prune-llvm-bin.py \ |
| 123 | + --action discover \ |
| 124 | + --install-dir ".llvm/build-install/lib" \ |
| 125 | + --build-dir "build" \ |
| 126 | + --max-attempts 60 \ |
| 127 | + --sleep-seconds 60 \ |
| 128 | + --manifest "${MANIFEST}" |
| 129 | +
|
| 130 | + - name: Upload pruned-libs manifest |
| 131 | + if: matrix.llvm_mode == 'RelWithDebInfo' && matrix.lto == 'OFF' |
| 132 | + uses: actions/upload-artifact@v4 |
| 133 | + with: |
| 134 | + name: llvm-pruned-libs-${{ matrix.os }} |
| 135 | + path: ${{ env.LLVM_PRUNED_MANIFEST }} |
| 136 | + if-no-files-found: error |
| 137 | + compression-level: 0 |
| 138 | + |
| 139 | + - name: Apply pruned-libs manifest (RelWithDebInfo + LTO) |
| 140 | + if: matrix.llvm_mode == 'RelWithDebInfo' && matrix.lto == 'ON' |
| 141 | + shell: bash |
| 142 | + env: |
| 143 | + GH_TOKEN: ${{ github.token }} |
| 144 | + run: | |
| 145 | + MANIFEST="pruned-libs-${{ matrix.os }}.json" |
| 146 | + python3 scripts/prune-llvm-bin.py \ |
| 147 | + --action apply \ |
| 148 | + --manifest "${MANIFEST}" \ |
| 149 | + --install-dir ".llvm/build-install/lib" \ |
| 150 | + --build-dir "build" \ |
| 151 | + --gh-run-id "${{ github.run_id }}" \ |
| 152 | + --gh-artifact "llvm-pruned-libs-${{ matrix.os }}" \ |
| 153 | + --gh-download-dir "artifacts" \ |
| 154 | + --max-attempts 60 \ |
| 155 | + --sleep-seconds 60 |
| 156 | +
|
| 157 | + - name: Package LLVM install directory |
| 158 | + shell: bash |
| 159 | + run: | |
| 160 | + MODE_TAG="releasedbg" |
| 161 | + if [[ "${{ matrix.llvm_mode }}" == "Debug" ]]; then |
| 162 | + MODE_TAG="debug" |
| 163 | + fi |
| 164 | +
|
| 165 | + ARCH="x64" |
| 166 | + PLATFORM="linux" |
| 167 | + TOOLCHAIN="gnu" |
| 168 | + if [[ "${{ matrix.os }}" == windows-* ]]; then |
| 169 | + PLATFORM="windows" |
| 170 | + TOOLCHAIN="msvc" |
| 171 | + elif [[ "${{ matrix.os }}" == macos-* ]]; then |
| 172 | + ARCH="arm64" |
| 173 | + PLATFORM="macos" |
| 174 | + TOOLCHAIN="clang" |
| 175 | + fi |
| 176 | +
|
| 177 | + SUFFIX="" |
| 178 | + if [[ "${{ matrix.lto }}" == "ON" ]]; then |
| 179 | + SUFFIX="-lto" |
| 180 | + fi |
| 181 | + if [[ "${{ matrix.llvm_mode }}" == "Debug" ]]; then |
| 182 | + SUFFIX="${SUFFIX}-asan" |
| 183 | + fi |
| 184 | +
|
| 185 | + ARCHIVE="${ARCH}-${PLATFORM}-${TOOLCHAIN}-${MODE_TAG}${SUFFIX}.tar.xz" |
| 186 | +
|
| 187 | + set -eo pipefail |
| 188 | + tar -C .llvm -cf - build-install | xz -T0 -9 -c > "${ARCHIVE}" |
| 189 | + echo "LLVM_INSTALL_ARCHIVE=${ARCHIVE}" >> "${GITHUB_ENV}" |
| 190 | +
|
| 191 | + - name: Upload LLVM install artifact |
| 192 | + uses: actions/upload-artifact@v4 |
| 193 | + with: |
| 194 | + name: ${{ env.LLVM_INSTALL_ARCHIVE }} |
| 195 | + path: ${{ env.LLVM_INSTALL_ARCHIVE }} |
| 196 | + if-no-files-found: error |
0 commit comments