|
| 1 | +name: Reusable SYCL Linux build workflow |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + cc: |
| 7 | + type: string |
| 8 | + required: false |
| 9 | + default: "gcc" |
| 10 | + cxx: |
| 11 | + type: string |
| 12 | + required: false |
| 13 | + default: "g++" |
| 14 | + build_image: |
| 15 | + type: string |
| 16 | + required: false |
| 17 | + default: "ghcr.io/intel/llvm/ubuntu2204_build:latest" |
| 18 | + build_ref: |
| 19 | + type: string |
| 20 | + required: false |
| 21 | + build_cache_root: |
| 22 | + type: string |
| 23 | + required: true |
| 24 | + build_cache_suffix: |
| 25 | + type: string |
| 26 | + required: false |
| 27 | + default: "default" |
| 28 | + build_configure_extra_args: |
| 29 | + type: string |
| 30 | + required: false |
| 31 | + default: "--hip --cuda --enable-esimd-emulator" |
| 32 | + build_artifact_suffix: |
| 33 | + type: string |
| 34 | + required: true |
| 35 | + artifact_archive_name: |
| 36 | + type: string |
| 37 | + default: llvm_sycl.tar.zst |
| 38 | + changes: |
| 39 | + type: string |
| 40 | + description: 'Filter matches for the changed files in the PR' |
| 41 | + default: '[llvm, clang, sycl, llvm_spirv, xptifw, libclc, libdevice]' |
| 42 | + required: false |
| 43 | + merge_ref: |
| 44 | + description: | |
| 45 | + Commit-ish to merge post-checkout if non-empty. Must be reachable from |
| 46 | + the default_branch input paramter. |
| 47 | + type: string |
| 48 | + default: 'FETCH_HEAD' |
| 49 | + retention-days: |
| 50 | + description: 'Artifacts retention period' |
| 51 | + type: string |
| 52 | + default: 3 |
| 53 | + |
| 54 | + outputs: |
| 55 | + artifact_archive_name: |
| 56 | + value: ${{ jobs.build.outputs.artifact_archive_name }} |
| 57 | + artifact_decompress_command: |
| 58 | + value: ${{ jobs.build.outputs.artifact_decompress_command }} |
| 59 | + |
| 60 | + workflow_dispatch: |
| 61 | + inputs: |
| 62 | + changes: |
| 63 | + description: 'Filter matches for the changed files in the PR' |
| 64 | + type: choice |
| 65 | + options: |
| 66 | + - "[]" |
| 67 | + - '[llvm, clang, sycl, llvm_spirv, xptifw, libclc, libdevice]' |
| 68 | + build_image: |
| 69 | + type: choice |
| 70 | + options: |
| 71 | + - "ghcr.io/intel/llvm/sycl_ubuntu2204_nightly:build" |
| 72 | + cc: |
| 73 | + type: choice |
| 74 | + options: |
| 75 | + - gcc |
| 76 | + cxx: |
| 77 | + type: choice |
| 78 | + options: |
| 79 | + - g++ |
| 80 | + build_configure_extra_args: |
| 81 | + type: choice |
| 82 | + options: |
| 83 | + - "--hip --cuda --enable-esimd-emulator" |
| 84 | + # Cache properties need to match CC/CXX/CMake opts. Any additional choices |
| 85 | + # would need extra care. |
| 86 | + build_cache_root: |
| 87 | + type: choice |
| 88 | + options: |
| 89 | + - "/__w/" |
| 90 | + build_cache_suffix: |
| 91 | + type: choice |
| 92 | + options: |
| 93 | + - "default" |
| 94 | + |
| 95 | + build_artifact_suffix: |
| 96 | + type: choice |
| 97 | + options: |
| 98 | + - "default" |
| 99 | + retention-days: |
| 100 | + type: choice |
| 101 | + options: |
| 102 | + - 3 |
| 103 | + |
| 104 | +jobs: |
| 105 | + build: |
| 106 | + name: Build + LIT |
| 107 | + runs-on: [Linux, build] |
| 108 | + container: |
| 109 | + image: ${{ inputs.build_image }} |
| 110 | + options: -u 1001:1001 |
| 111 | + outputs: |
| 112 | + build_conclusion: ${{ steps.build.conclusion }} |
| 113 | + artifact_archive_name: ${{ steps.artifact_info.outputs.ARCHIVE_NAME }} |
| 114 | + artifact_decompress_command: ${{ steps.artifact_info.outputs.DECOMPRESS }} |
| 115 | + env: |
| 116 | + CCACHE_DIR: ${{ inputs.build_cache_root }}/build_cache_${{ inputs.build_cache_suffix }} |
| 117 | + CCACHE_MAXSIZE: 8G |
| 118 | + steps: |
| 119 | + - name: Deduce artifact archive params |
| 120 | + # To reduce number of inputs parameters that is limited for manual triggers. |
| 121 | + id: artifact_info |
| 122 | + run: | |
| 123 | + NAME="${{inputs.artifact_archive_name}}" |
| 124 | + if [ -z "$NAME" ]; then |
| 125 | + NAME=llvm_sycl.tar.zst |
| 126 | + fi |
| 127 | + echo ARCHIVE_NAME="$NAME" >> $GITHUB_OUTPUT |
| 128 | + if [ "${NAME}" != "${NAME%.tar.gz}" ]; then |
| 129 | + echo COMPRESS="gzip" >> $GITHUB_OUTPUT |
| 130 | + echo DECOMPRESS="gunzip" >> $GITHUB_OUTPUT |
| 131 | + elif [ "${NAME}" != "${NAME%.tar.zst}" ]; then |
| 132 | + echo COMPRESS="zstd -9" >> $GITHUB_OUTPUT |
| 133 | + echo DECOMPRESS="zstd" >> $GITHUB_OUTPUT |
| 134 | + else |
| 135 | + echo "Unsupported extension" |
| 136 | + exit 1 |
| 137 | + fi |
| 138 | + - uses: actions/checkout@v3 |
| 139 | + with: |
| 140 | + sparse-checkout: | |
| 141 | + devops/actions |
| 142 | + # Cleanup will be run after all actions are completed. |
| 143 | + - name: Register cleanup after job is finished |
| 144 | + uses: ./devops/actions/cleanup |
| 145 | + - uses: ./devops/actions/cached_checkout |
| 146 | + with: |
| 147 | + path: src |
| 148 | + ref: ${{ inputs.build_ref || github.sha }} |
| 149 | + merge_ref: ${{ inputs.merge_ref }} |
| 150 | + cache_path: "/__w/repo_cache/" |
| 151 | + - name: Configure |
| 152 | + env: |
| 153 | + CC: ${{ inputs.cc }} |
| 154 | + CXX: ${{ inputs.cxx }} |
| 155 | + ARGS: ${{ inputs.build_configure_extra_args }} |
| 156 | + CUDA_LIB_PATH: "/usr/local/cuda/lib64/stubs" |
| 157 | + run: | |
| 158 | + mkdir -p $CCACHE_DIR |
| 159 | + mkdir -p $GITHUB_WORKSPACE/build |
| 160 | + cd $GITHUB_WORKSPACE/build |
| 161 | + python3 $GITHUB_WORKSPACE/src/buildbot/configure.py -w $GITHUB_WORKSPACE \ |
| 162 | + -s $GITHUB_WORKSPACE/src -o $GITHUB_WORKSPACE/build -t Release \ |
| 163 | + --ci-defaults $ARGS \ |
| 164 | + --cmake-opt=-DCMAKE_C_COMPILER_LAUNCHER=ccache \ |
| 165 | + --cmake-opt=-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ |
| 166 | + --cmake-opt="-DLLVM_INSTALL_UTILS=ON" \ |
| 167 | + --cmake-opt="-DSYCL_PI_TESTS=OFF" |
| 168 | + - name: Compile |
| 169 | + id: build |
| 170 | + run: cmake --build $GITHUB_WORKSPACE/build |
| 171 | + - name: check-llvm |
| 172 | + if: always() && !cancelled() && contains(inputs.changes, 'llvm') |
| 173 | + run: | |
| 174 | + cmake --build $GITHUB_WORKSPACE/build --target check-llvm |
| 175 | + - name: check-clang |
| 176 | + if: always() && !cancelled() && contains(inputs.changes, 'clang') |
| 177 | + run: | |
| 178 | + # Can we move this to Dockerfile? Hopefully, noop on Windows. |
| 179 | + export XDG_CACHE_HOME=$GITHUB_WORKSPACE/os_cache |
| 180 | + cmake --build $GITHUB_WORKSPACE/build --target check-clang |
| 181 | + - name: check-sycl |
| 182 | + if: always() && !cancelled() && contains(inputs.changes, 'sycl') |
| 183 | + run: | |
| 184 | + # TODO consider moving this to Dockerfile. |
| 185 | + export LD_LIBRARY_PATH=/usr/local/cuda/compat/:/usr/local/cuda/lib64:$LD_LIBRARY_PATH |
| 186 | + cmake --build $GITHUB_WORKSPACE/build --target check-sycl |
| 187 | + - name: check-llvm-spirv |
| 188 | + if: always() && !cancelled() && contains(inputs.changes, 'llvm_spirv') |
| 189 | + run: | |
| 190 | + cmake --build $GITHUB_WORKSPACE/build --target check-llvm-spirv |
| 191 | + - name: check-xptifw |
| 192 | + if: always() && !cancelled() && contains(inputs.changes, 'xptifw') |
| 193 | + run: | |
| 194 | + cmake --build $GITHUB_WORKSPACE/build --target check-xptifw |
| 195 | + - name: check-libclc |
| 196 | + if: always() && !cancelled() && contains(inputs.changes, 'libclc') |
| 197 | + run: | |
| 198 | + cmake --build $GITHUB_WORKSPACE/build --target check-libclc |
| 199 | + - name: check-libdevice |
| 200 | + if: always() && !cancelled() && contains(inputs.changes, 'libdevice') |
| 201 | + run: | |
| 202 | + cmake --build $GITHUB_WORKSPACE/build --target check-libdevice |
| 203 | + - name: Install |
| 204 | + if: ${{ always() && !cancelled() && steps.build.conclusion == 'success' }} |
| 205 | + # TODO replace utility installation with a single CMake target |
| 206 | + run: | |
| 207 | + cmake --build $GITHUB_WORKSPACE/build --target deploy-sycl-toolchain |
| 208 | + cmake --build $GITHUB_WORKSPACE/build --target utils/FileCheck/install |
| 209 | + cmake --build $GITHUB_WORKSPACE/build --target utils/count/install |
| 210 | + cmake --build $GITHUB_WORKSPACE/build --target utils/not/install |
| 211 | + cmake --build $GITHUB_WORKSPACE/build --target utils/lit/install |
| 212 | + cmake --build $GITHUB_WORKSPACE/build --target utils/llvm-lit/install |
| 213 | + cmake --build $GITHUB_WORKSPACE/build --target install-llvm-size |
| 214 | + cmake --build $GITHUB_WORKSPACE/build --target install-llvm-cov |
| 215 | + cmake --build $GITHUB_WORKSPACE/build --target install-llvm-profdata |
| 216 | + cmake --build $GITHUB_WORKSPACE/build --target install-compiler-rt |
| 217 | + - name: Additional Install for "--shared-libs" build |
| 218 | + if: ${{ always() && !cancelled() && steps.build.conclusion == 'success' && contains(inputs.build_configure_extra_args, '--shared-libs') }} |
| 219 | + run: | |
| 220 | + cmake --build $GITHUB_WORKSPACE/build --target install-clang-libraries |
| 221 | + cmake --build $GITHUB_WORKSPACE/build --target install-llvm-libraries |
| 222 | +
|
| 223 | + - name: Install lint utilities |
| 224 | + # We install these into our nightly container that CI uses to run lint |
| 225 | + # checks. |
| 226 | + run: | |
| 227 | + cmake --build $GITHUB_WORKSPACE/build --target install-clang-format |
| 228 | + cmake --build $GITHUB_WORKSPACE/build --target install-clang-tidy |
| 229 | +
|
| 230 | + - name: Pack toolchain |
| 231 | + if: ${{ always() && !cancelled() && steps.build.conclusion == 'success' }} |
| 232 | + run: tar -I '${{ steps.artifact_info.outputs.COMPRESS }}' -cf ${{ steps.artifact_info.outputs.ARCHIVE_NAME }} -C $GITHUB_WORKSPACE/build/install . |
| 233 | + - name: Upload toolchain |
| 234 | + if: ${{ always() && !cancelled() && steps.build.conclusion == 'success' }} |
| 235 | + uses: actions/upload-artifact@v3 |
| 236 | + with: |
| 237 | + name: sycl_linux_${{ inputs.build_artifact_suffix }} |
| 238 | + path: ${{ steps.artifact_info.outputs.ARCHIVE_NAME }} |
| 239 | + retention-days: ${{ inputs.retention-days }} |
0 commit comments