|
| 1 | +name: 'Builds LLVM' |
| 2 | +description: 'This action builds LLVM for native platforms' |
| 3 | +inputs: |
| 4 | + cache-hit: |
| 5 | + required: true |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_call: |
| 9 | + inputs: |
| 10 | + cache-hit: |
| 11 | + required: true |
| 12 | + type: boolean |
| 13 | + |
| 14 | +runs: |
| 15 | + using: composite |
| 16 | + steps: |
| 17 | + - name: Build LLVM/Cling if the cache is invalid |
| 18 | + if: ${{ inputs.cache-hit != 'true' && runner.os != 'Windows' }} |
| 19 | + shell: bash |
| 20 | + run: | |
| 21 | + cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') |
| 22 | + if [[ "${cling_on}" == "ON" ]]; then |
| 23 | + git clone https://github.com/root-project/cling.git |
| 24 | + cd ./cling |
| 25 | + git checkout tags/v${{ matrix.cling-version }} |
| 26 | + git apply -v ../patches/llvm/cling1.2-LookupHelper.patch |
| 27 | + cd .. |
| 28 | + git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git |
| 29 | + else # repl |
| 30 | + git clone --depth=1 -b release/${{ matrix.clang-runtime }}.x https://github.com/llvm/llvm-project.git |
| 31 | + fi |
| 32 | + cd llvm-project |
| 33 | + # Build |
| 34 | + mkdir build |
| 35 | + if [[ "${cling_on}" == "ON" ]]; then |
| 36 | + cd build |
| 37 | + cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects }}" \ |
| 38 | + -DLLVM_EXTERNAL_PROJECTS=cling \ |
| 39 | + -DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling \ |
| 40 | + -DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" \ |
| 41 | + -DCMAKE_BUILD_TYPE=Release \ |
| 42 | + -DLLVM_ENABLE_ASSERTIONS=ON \ |
| 43 | + -DCLANG_ENABLE_STATIC_ANALYZER=OFF \ |
| 44 | + -DCLANG_ENABLE_ARCMT=OFF \ |
| 45 | + -DCLANG_ENABLE_FORMAT=OFF \ |
| 46 | + -DCLANG_ENABLE_BOOTSTRAP=OFF \ |
| 47 | + -G Ninja \ |
| 48 | + ../llvm |
| 49 | + ninja clang -j ${{ env.ncpus }} |
| 50 | + ninja LLVMOrcDebugging -j ${{ env.ncpus }} |
| 51 | + ninja clingInterpreter -j ${{ env.ncpus }} |
| 52 | + else |
| 53 | + # Apply patches |
| 54 | + llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]') |
| 55 | + if [[ "${llvm_vers}" == "16" ]]||[[ "${llvm_vers}" == "17" ]]; then |
| 56 | + git apply -v ../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch |
| 57 | + echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:" |
| 58 | + fi |
| 59 | + cd build |
| 60 | + cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects}}" \ |
| 61 | + -DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" \ |
| 62 | + -DCMAKE_BUILD_TYPE=Release \ |
| 63 | + -DLLVM_ENABLE_ASSERTIONS=ON \ |
| 64 | + -DCLANG_ENABLE_STATIC_ANALYZER=OFF \ |
| 65 | + -DCLANG_ENABLE_ARCMT=OFF \ |
| 66 | + -DCLANG_ENABLE_FORMAT=OFF \ |
| 67 | + -DCLANG_ENABLE_BOOTSTRAP=OFF \ |
| 68 | + -G Ninja \ |
| 69 | + -DLLVM_INCLUDE_BENCHMARKS=OFF \ |
| 70 | + -DLLVM_INCLUDE_EXAMPLES=OFF \ |
| 71 | + -DLLVM_INCLUDE_TESTS=OFF \ |
| 72 | + ../llvm |
| 73 | + ninja clang clangInterpreter clangStaticAnalyzerCore -j ${{ env.ncpus }} |
| 74 | + cd ./tools/ |
| 75 | + rm -rf $(find . -maxdepth 1 ! -name "clang" ! -name ".") |
| 76 | + cd .. |
| 77 | + rm compile_commands.json build.ninja |
| 78 | + fi |
| 79 | + cd ../ |
| 80 | + rm -rf $(find . -maxdepth 1 ! -name "build" ! -name "llvm" ! -name "clang" ! -name ".") |
| 81 | + if [[ "${cling_on}" == "ON" ]]; then |
| 82 | + cd ./llvm/ |
| 83 | + rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".") |
| 84 | + cd ../clang/ |
| 85 | + rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".") |
| 86 | + cd ../../cling/ |
| 87 | + rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".") |
| 88 | + else # repl |
| 89 | + cd ./llvm/ |
| 90 | + rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".") |
| 91 | + cd ../clang/ |
| 92 | + rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".") |
| 93 | + cd ../.. |
| 94 | + fi |
| 95 | +
|
| 96 | +
|
| 97 | + - name: Build LLVM/Cling on Windows systems if the cache is invalid |
| 98 | + if: ${{ inputs.cache-hit != 'true' && runner.os == 'Windows' }} |
| 99 | + shell: powershell |
| 100 | + run: | |
| 101 | +
|
| 102 | + if ( "${{ matrix.cling }}" -imatch "On" ) |
| 103 | + { |
| 104 | + git clone https://github.com/root-project/cling.git |
| 105 | + cd ./cling |
| 106 | + git checkout tags/v${{ matrix.cling-version }} |
| 107 | + git apply -v ../patches/llvm/cling1.2-LookupHelper.patch |
| 108 | + cd .. |
| 109 | + git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git |
| 110 | + $env:PWD_DIR= $PWD.Path |
| 111 | + $env:CLING_DIR="$env:PWD_DIR\cling" |
| 112 | + echo "CLING_DIR=$env:CLING_DIR" |
| 113 | + } |
| 114 | + else |
| 115 | + { |
| 116 | + git clone --depth=1 -b release/${{ matrix.clang-runtime }}.x https://github.com/llvm/llvm-project.git |
| 117 | + } |
| 118 | +
|
| 119 | + cd llvm-project |
| 120 | + # Build |
| 121 | + mkdir build |
| 122 | + if ( "${{ matrix.cling }}" -imatch "On" ) |
| 123 | + { |
| 124 | + cd build |
| 125 | + cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects}}" ` |
| 126 | + -DLLVM_EXTERNAL_PROJECTS=cling ` |
| 127 | + -DLLVM_EXTERNAL_CLING_SOURCE_DIR="$env:CLING_DIR" ` |
| 128 | + -DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" ` |
| 129 | + -DCMAKE_BUILD_TYPE=Release ` |
| 130 | + -DLLVM_ENABLE_ASSERTIONS=ON ` |
| 131 | + -DCLANG_ENABLE_STATIC_ANALYZER=OFF ` |
| 132 | + -DCLANG_ENABLE_ARCMT=OFF ` |
| 133 | + -DCLANG_ENABLE_FORMAT=OFF ` |
| 134 | + -DCLANG_ENABLE_BOOTSTRAP=OFF ` |
| 135 | + ..\llvm |
| 136 | + cmake --build . --config Release --target clang --parallel ${{ env.ncpus }} |
| 137 | + cmake --build . --config Release --target LLVMOrcDebugging --parallel ${{ env.ncpus }} |
| 138 | + cmake --build . --config Release --target clingInterpreter --parallel ${{ env.ncpus }} |
| 139 | + } |
| 140 | + else |
| 141 | + { |
| 142 | + cp -r ..\patches\llvm\clang${{ matrix.clang-runtime }}* |
| 143 | + #FIXME: Apply patches without hardcoding |
| 144 | + if ( "${{ matrix.clang-runtime }}" -imatch "16" ) |
| 145 | + { |
| 146 | + git apply -v clang16-1-Value.patch |
| 147 | + git apply -v clang16-2-CUDA.patch |
| 148 | + git apply -v clang16-3-WeakRef.patch |
| 149 | + } |
| 150 | + elseif ( "${{ matrix.clang-runtime }}" -imatch "17" ) |
| 151 | + { |
| 152 | + git apply -v clang17-1-NewOperator.patch |
| 153 | + } |
| 154 | + cd build |
| 155 | + echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:" |
| 156 | + cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects}}" ` |
| 157 | + -DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" ` |
| 158 | + -DCMAKE_BUILD_TYPE=Release ` |
| 159 | + -DLLVM_ENABLE_ASSERTIONS=ON ` |
| 160 | + -DCLANG_ENABLE_STATIC_ANALYZER=OFF ` |
| 161 | + -DCLANG_ENABLE_ARCMT=OFF ` |
| 162 | + -DCLANG_ENABLE_FORMAT=OFF ` |
| 163 | + -DCLANG_ENABLE_BOOTSTRAP=OFF ` |
| 164 | + ..\llvm |
| 165 | + cmake --build . --config Release --target clang clangInterpreter clangStaticAnalyzerCore --parallel ${{ env.ncpus }} |
| 166 | + } |
| 167 | + cd ..\ |
| 168 | + rm -r -force $(find.exe . -maxdepth 1 ! -name "build" ! -name "llvm" ! -name "clang" ! -name ".") |
| 169 | + if ( "${{ matrix.cling }}" -imatch "On" ) |
| 170 | + { |
| 171 | + cd .\llvm\ |
| 172 | + rm -r -force $(find.exe . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".") |
| 173 | + cd ..\clang\ |
| 174 | + rm -r -force $(find.exe . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".") |
| 175 | + cd ..\..\cling\ |
| 176 | + rm -r -force $(find.exe . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".") |
| 177 | + } |
| 178 | + else |
| 179 | + { |
| 180 | + cd .\llvm\ |
| 181 | + rm -r -force $(find.exe . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".") |
| 182 | + cd ..\clang\ |
| 183 | + rm -r -force $(find.exe . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".") |
| 184 | + cd ..\.. |
| 185 | + } |
0 commit comments