|
| 1 | +name: build-llvm |
| 2 | +description: Action to build llvm artifacts |
| 3 | + |
| 4 | +inputs: |
| 5 | + os: |
| 6 | + type: string |
| 7 | + description: 'operating system, one of ubuntu-22.04, ubuntu-24.04 or windows-2019' |
| 8 | + default: 'ubuntu-22.04' |
| 9 | + arch: |
| 10 | + type: string |
| 11 | + description: 'architecture, one of x86_64, aarch64, x86 or riscv64' |
| 12 | + default: 'x86_64' |
| 13 | + build_type: |
| 14 | + type: string |
| 15 | + description: 'build type, one of Release, RelAssert (default RelAssert)' |
| 16 | + default: RelAssert |
| 17 | + llvm_version: |
| 18 | + type: string |
| 19 | + description: llvm version - used for naming purposes e.g. 19,20,main" |
| 20 | + default: "" |
| 21 | + llvm_branch: |
| 22 | + type: string |
| 23 | + description: "The actual llvm branch to check out e.g. release/19.x" |
| 24 | + use_github_cache: |
| 25 | + type: boolean |
| 26 | + description: "Whether to use caching - will rebuild if not existing" |
| 27 | + default: false |
| 28 | + |
| 29 | +runs: |
| 30 | + using: "composite" |
| 31 | + steps: |
| 32 | + - name: Setup Windows |
| 33 | + if: startsWith(runner.os, 'Windows') |
| 34 | + uses: llvm/actions/setup-windows@main |
| 35 | + with: |
| 36 | + arch: amd64 |
| 37 | + - name: Cache llvm |
| 38 | + id: cache |
| 39 | + if: inputs.use_github_cache == 'true' |
| 40 | + uses: actions/cache@v4 |
| 41 | + with: |
| 42 | + path: |
| 43 | + llvm_install/** |
| 44 | + key: llvm-${{ inputs.os }}-${{ inputs.arch }}-v${{ inputs.llvm_version }}-${{ inputs.build_type }} |
| 45 | + |
| 46 | + - name: Checkout repo llvm |
| 47 | + if: inputs.use_github_cache == 'false' || steps.cache.outputs.cache-hit != 'true' |
| 48 | + uses: actions/checkout@v4 |
| 49 | + with: |
| 50 | + repository: llvm/llvm-project |
| 51 | + ref: ${{inputs.llvm_branch}} |
| 52 | + path: llvm-project |
| 53 | + |
| 54 | + - name: Install Ninja |
| 55 | + uses: llvm/actions/install-ninja@a1ea791b03c8e61f53a0e66f2f73db283aa0f01e # main branch |
| 56 | + |
| 57 | + - name: install aarch64 build tools and set flags |
| 58 | + shell: bash |
| 59 | + if: inputs.arch == 'aarch64' && (inputs.use_github_cache == 'false' || steps.cache.outputs.cache-hit != 'true') |
| 60 | + run: | |
| 61 | + sudo apt-get install --yes g++-aarch64-linux-gnu |
| 62 | + echo "ARCH_FLAGS=-DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/platform/arm-linux/aarch64-toolchain.cmake -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu" > $GITHUB_ENV |
| 63 | +
|
| 64 | + - name: install riscv64 build tools and set flags |
| 65 | + shell: bash |
| 66 | + if: inputs.arch == 'riscv64' && (inputs.use_github_cache == 'false' || steps.cache.outputs.cache-hit != 'true') |
| 67 | + run: | |
| 68 | + sudo apt-get install --yes g++-riscv64-linux-gnu |
| 69 | + echo "ARCH_FLAGS=-DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/platform/riscv64-linux/riscv64-gcc-toolchain.cmake -DLLVM_HOST_TRIPLE=riscv64-unknown-linux-gnu" > $GITHUB_ENV |
| 70 | +
|
| 71 | + - name: install x86 build tools and set flags |
| 72 | + shell: bash |
| 73 | + if: inputs.arch == 'x86' && (inputs.use_github_cache == 'false' || steps.cache.outputs.cache-hit != 'true') |
| 74 | + run: | |
| 75 | + sudo dpkg --add-architecture i386 |
| 76 | + sudo apt-get update |
| 77 | + sudo apt-get install --yes gcc-multilib g++-multilib libc6-dev:i386 lib32tinfo-dev |
| 78 | + echo "ARCH_FLAGS=-DLLVM_BUILD_32_BITS=ON -DLIBXML2_LIBRARIES=IGNORE -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_HOST_TRIPLE=i686-unknown-linux-gnu" > $GITHUB_ENV |
| 79 | +
|
| 80 | + - name: Run cmake |
| 81 | + if: inputs.use_github_cache == 'false' || steps.cache.outputs.cache-hit != 'true' |
| 82 | + shell: ${{ startsWith(runner.os, 'Windows') && 'pwsh' || 'bash' }} |
| 83 | + run: |
| 84 | + cmake llvm-project/llvm |
| 85 | + -DLLVM_ENABLE_DIA_SDK=OFF |
| 86 | + -DCMAKE_INSTALL_PREFIX=llvm_install |
| 87 | + -DLLVM_ENABLE_ZLIB=FALSE |
| 88 | + -DLLVM_ENABLE_ZSTD=FALSE |
| 89 | + -DLLVM_ENABLE_Z3_SOLVER=FALSE |
| 90 | + -DLLVM_ENABLE_PROJECTS="clang;lld" |
| 91 | + -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64;RISCV" |
| 92 | + -Bbuild |
| 93 | + -GNinja |
| 94 | + -DCMAKE_BUILD_TYPE=Release |
| 95 | + ${{ inputs.build_type == 'RelAssert' && '-DLLVM_ENABLE_ASSERTIONS=ON' || '' }} |
| 96 | + ${{ !startsWith(runner.os, 'Windows') && '-DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON' || '' }} |
| 97 | + $ARCH_FLAGS |
| 98 | + |
| 99 | + - name: Run build on llvm |
| 100 | + if: inputs.use_github_cache == 'false' || steps.cache.outputs.cache-hit != 'true' |
| 101 | + shell: ${{ startsWith(runner.os, 'Windows') && 'pwsh' || 'bash' }} |
| 102 | + run: |
| 103 | + cmake --build build --target install |
| 104 | + |
| 105 | + - name: Copy lit tools |
| 106 | + if: inputs.use_github_cache == 'false' || steps.cache.outputs.cache-hit != 'true' |
| 107 | + shell: bash |
| 108 | + run: | |
| 109 | + cp build/bin/FileCheck* llvm_install/bin |
| 110 | + cp build/bin/not* llvm_install/bin |
| 111 | +
|
| 112 | + - name: upload artefact |
| 113 | + uses: ./.github/actions/upload_artifact |
| 114 | + with: |
| 115 | + name: llvm-${{ inputs.os }}-${{ inputs.arch }}-${{ inputs.llvm_version }}-${{ inputs.build_type }} |
| 116 | + path: llvm_install |
| 117 | + needs_tar: ${{ startsWith(runner.os, 'Windows') && 'false' || 'true' }} |
| 118 | + retention-days: 7 |
0 commit comments