2020 default : false
2121 pull_request :
2222 paths :
23- - " .github/actions/setup_base"
23+ - " .github/actions/setup_base/action.yml "
2424 - " .github/workflows/build_llvm.yml"
25- - " scripts/cmake/llvm_cache.cmake "
26- - " scripts/cmake/llvm_wasm_cache.cmake "
25+ - " scripts/cmake/* "
26+ - " scripts/llvm_wasm/* "
2727 - " scripts/build_llvm.sh"
28- - " scripts/build_llvm_wasi .sh"
28+ - " scripts/build_mlir_native_tools .sh"
2929 - " third_party/llvm-project"
3030 push :
3131 branches :
3232 - main
3333 paths :
34- - " .github/actions/setup_base"
34+ - " .github/actions/setup_base/action.yml "
3535 - " .github/workflows/build_llvm.yml"
36- - " scripts/cmake/llvm_cache.cmake "
37- - " scripts/cmake/llvm_wasm_cache.cmake "
36+ - " scripts/cmake/* "
37+ - " scripts/llvm_wasm/* "
3838 - " scripts/build_llvm.sh"
39- - " scripts/build_llvm_wasi .sh"
39+ - " scripts/build_mlir_native_tools .sh"
4040 - " third_party/llvm-project"
4141
4242concurrency :
@@ -48,6 +48,7 @@ concurrency:
4848 cancel-in-progress : true
4949
5050jobs :
51+
5152 build :
5253
5354 strategy :
@@ -58,33 +59,27 @@ jobs:
5859 runs-on : " ubuntu-22.04"
5960 container : " quay.io/pypa/manylinux_2_28_x86_64"
6061 os : " almalinux"
61- arch : x86_64
62+ host-arch : x86_64
63+ target-arch : x86_64
64+
6265 - name : " manylinux_aarch64"
6366 runs-on : " ubuntu-22.04-arm"
6467 container : " quay.io/pypa/manylinux_2_34_aarch64"
6568 os : " almalinux"
66- arch : aarch64
67- # - name: "ubuntu_aarch64"
68- # runs-on: "ubuntu-22.04-arm"
69- # os: "ubuntu"
70- # arch: aarch64
71- # - name: "wasm_wasi"
72- # runs-on: "ubuntu-22.04"
73- # container: "quay.io/pypa/manylinux_2_28_x86_64"
74- # os: "almalinux"
75- # arch: "wasm32-wasi"
69+ host-arch : " aarch64"
70+ target-arch : " aarch64"
71+
7672 - name : " windows_amd64"
7773 runs-on : " windows-2022"
7874 os : " windows"
79- arch : amd64
75+ host-arch : amd64
76+ target-arch : amd64
77+
8078 - name : " macos_arm64"
8179 runs-on : " macos-14"
8280 os : " macos"
83- arch : arm64
84- # - name: "macos_x86_64"
85- # runs-on: "macos-13"
86- # os: "macos"
87- # arch: x86_64
81+ host-arch : arm64
82+ target-arch : arm64
8883
8984 runs-on : ${{ matrix.runs-on }}
9085
@@ -127,7 +122,8 @@ jobs:
127122 cache-key : ${{ env.cache-key }}
128123 restore-key : " mlir_${{ matrix.name }}_clang"
129124 os : ${{ matrix.os }}
130- arch : ${{ matrix.arch }}
125+ host-arch : ${{ matrix.host-arch }}
126+ target-arch : ${{ matrix.target-arch }}
131127 container : ${{ matrix.container }}
132128 runs-on : ${{ matrix.runs-on }}
133129
@@ -150,14 +146,11 @@ jobs:
150146 ###############################
151147 # Build MLIR/LLVM distro
152148 ###############################
153- if [[ "${{ matrix.arch }}" == "wasm32-wasi" ]]; then
154- scripts/build_llvm_wasi.sh
155- else
156- scripts/build_llvm.sh
157- echo "*********************** SMOKE TEST *********************************"
158- "$LLVM_INSTALL_DIR/bin/mlir-tblgen" --version
159- echo "*********************** SMOKE TEST *********************************"
160- fi
149+
150+ scripts/build_llvm.sh
151+ echo "*********************** SMOKE TEST *********************************"
152+ "$LLVM_INSTALL_DIR/bin/mlir-tblgen" --version
153+ echo "*********************** SMOKE TEST *********************************"
161154 ccache -s
162155
163156 ###############################
@@ -178,7 +171,7 @@ jobs:
178171 elif [ x"${{ matrix.os }}" == x"windows" ]; then
179172 PLAT="win"
180173 fi
181- PLAT="${PLAT}_${{ matrix.arch }}"
174+ PLAT="${PLAT}_${{ matrix.host- arch }}"
182175
183176 pushd projects/mlir-native-tools
184177 $python3_command setup.py bdist_wheel --dist-dir ../../wheelhouse --plat $PLAT
@@ -256,9 +249,117 @@ jobs:
256249 limit-access-to-actor : true
257250 install-dependencies : ${{ startsWith(matrix.runs-on, 'macos') || startsWith(matrix.runs-on, 'windows') }}
258251
252+ build-wasm :
253+
254+ runs-on : ubuntu-22.04
255+
256+ name : " Build llvm-mlir wasm"
257+
258+ defaults :
259+ run :
260+ shell : bash
261+
262+ permissions :
263+ id-token : write
264+ contents : write
265+
266+ env :
267+ cache-key : mlir_wasm_emscripten_${{ format('{0}-{1}', github.ref_name, github.run_number) }}
268+
269+ steps :
270+ - name : " Check out repository"
271+ 272+ with :
273+ submodules : true
274+
275+ - name : " Setup base"
276+ uses : ./.github/actions/setup_base
277+ id : setup_base
278+ with :
279+ cache-key : ${{ env.cache-key }}
280+ restore-key : " mlir_wasm_emscripten"
281+ os : " ubuntu"
282+ host-arch : " x86_64"
283+ target-arch : " wasm32"
284+
285+ - name : Build MLIR and LLVM
286+ run : |
287+
288+ ###############################
289+ # Build host mlir-native-tools wheel
290+ ###############################
291+
292+ scripts/build_mlir_native_tools.sh
293+ export LLVM_NATIVE_TOOL_DIR="$PWD/mlir-native-tools-install/bin"
294+ export LLVM_NATIVE_TOOL_DIR="$LLVM_NATIVE_TOOL_DIR"
295+ export LLVM_TABLEGEN="$LLVM_NATIVE_TOOL_DIR/llvm-tblgen"
296+ export MLIR_TABLEGEN="$LLVM_NATIVE_TOOL_DIR/mlir-tblgen"
297+ export MLIR_LINALG_ODS_YAML_GEN="$LLVM_NATIVE_TOOL_DIR/mlir-linalg-ods-yaml-gen"
298+
299+ source "$EMSDK/emsdk_env.sh"
300+
301+ export PATH="$EMSDK/ccache/git-emscripten_64bit/bin:$PATH"
302+ export CCACHE_COMPILERCHECK="string:$($EMSDK/upstream/bin/clang --version | head -n 1)"
303+ export CCACHE="$EMSDK/ccache/git-emscripten_64bit/bin/ccache"
304+ export "CMAKE_C_COMPILER_LAUNCHER=$CCACHE"
305+ export "CMAKE_CXX_COMPILER_LAUNCHER=$CCACHE"
306+
307+ export LLVM_SOURCE_DIR="$PWD/third_party/llvm-project"
308+ pushd $LLVM_SOURCE_DIR && LLVM_SHA_SHORT="$(git rev-parse --short HEAD)" && popd
309+ export WHEEL_VERSION="$(date +'%Y%m%d')+$LLVM_SHA_SHORT"
310+ echo "WHEEL_VERSION=$WHEEL_VERSION" >> $GITHUB_OUTPUT
311+
312+ ###############################
313+ # Build MLIR/LLVM distro
314+ ###############################
315+
316+ $CCACHE -z
317+ pyodide build scripts/llvm_wasm -o wheelhouse --compression-level 10
318+ $CCACHE -s
319+
320+ - name : Upload ccache log
321+ uses : actions/upload-artifact@v4
322+ with :
323+ name : llvm_ccache_log_mlir_wasm32
324+ path : ' /tmp/ccache.log'
325+
326+ - name : " Save cache"
327+ uses : actions/cache/save@v3
328+ if : (!cancelled() && github.event_name == 'push' && github.ref_name == 'main')
329+ with :
330+ path : ${{ steps.setup_base.outputs.cache-dir }}
331+ key : ${{ env.cache-key }}
332+
333+ - name : Upload LLVM distro artifacts
334+ uses : actions/upload-artifact@v4
335+ with :
336+ name : mlir_ubuntu_wasm32_artifact
337+ path : llvm-install
338+ if-no-files-found : warn
339+
340+ - name : Upload mlir-wheel artifact
341+ uses : actions/upload-artifact@v4
342+ with :
343+ name : mlir_wheel_ubuntu_wasm32_artifact
344+ path : wheelhouse/mlir_wheel*
345+ if-no-files-found : warn
346+
347+ - name : Release current commit
348+ if : (github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'workflow_dispatch'
349+ 350+ with :
351+ artifacts : " *.tar.gz,wheelhouse/*.whl"
352+ token : " ${{ secrets.GITHUB_TOKEN }}"
353+ tag : " llvm"
354+ name : " llvm"
355+ removeArtifacts : false
356+ allowUpdates : true
357+ replacesArtifacts : true
358+ makeLatest : true
359+
259360 call-build-python-bindings :
260361
261- needs : [build]
362+ needs : [build, build-wasm ]
262363
263364 permissions :
264365 contents : write
0 commit comments