@@ -136,10 +136,16 @@ jobs:
136136 export LLVM_BUILD_DIR="$PWD/llvm-build"
137137 # double nested so that upload artifacts uploads a folder
138138 export LLVM_INSTALL_DIR="$PWD/llvm-install/llvm-install"
139+ pushd $LLVM_SOURCE_DIR && LLVM_SHA_SHORT="$(git rev-parse --short HEAD)" && popd
140+ export WHEEL_VERSION="$(date +'%Y%m%d')_$LLVM_SHA_SHORT"
139141
140142 ccache -z
141143 $python3_command -m pip install -r third_party/llvm-project/mlir/python/requirements.txt
144+ $python3_command -m pip install setuptools wheel
142145
146+ ###############################
147+ # Build MLIR/LLVM distro
148+ ###############################
143149 if [[ "${{ matrix.arch }}" == "wasm32-wasi" ]]; then
144150 scripts/build_llvm_wasi.sh
145151 else
@@ -150,17 +156,49 @@ jobs:
150156 fi
151157 ccache -s
152158
153- pushd $LLVM_SOURCE_DIR && LLVM_SHA_SHORT=$(git rev-parse --short HEAD) && popd
154- tar -czf mlir_${{ matrix.name }}_$(date +'%Y%m%d')_$LLVM_SHA_SHORT.tar.gz -C "$LLVM_INSTALL_DIR/.." llvm-install
159+ ###############################
160+ # Build mlir-native-tools wheel
161+ ###############################
162+ for TOOL in "llvm-tblgen" "mlir-tblgen" "mlir-linalg-ods-yaml-gen" "mlir-pdll" "llvm-config" "FileCheck"; do
163+ if [ x"${{ matrix.os }}" == x"windows" ]; then
164+ TOOL="$TOOL.exe"
165+ fi
166+ cp "$LLVM_INSTALL_DIR/bin/$TOOL" projects/mlir-native-tools
167+ done
168+
169+ if [ x"${{ matrix.os }}" == x"almalinux" ] || [ x"${{ matrix.os }}" == x"ubuntu" ]; then
170+ PLAT="linux"
171+ elif [ x"${{ matrix.os }}" == x"macos" ]; then
172+ PLAT="macosx_12_0"
173+ elif [ x"${{ matrix.os }}" == x"windows" ]; then
174+ PLAT="win"
175+ fi
176+ PLAT="${PLAT}_$(echo ${{ matrix.arch }} | tr '[:upper:]' '[:lower:]')"
177+
178+ pushd projects/mlir-native-tools
179+ $python3_command setup.py bdist_wheel --dist-dir ../../wheelhouse --plat $PLAT
180+ popd
181+
182+ ###############################
183+ # Tar up MLIR/LLVM distro
184+ ###############################
185+ tar -czf "mlir_${{ matrix.name }}_$WHEEL_VERSION.tar.gz" -C "$LLVM_INSTALL_DIR/.." llvm-install
155186 rm -rf "$LLVM_BUILD_DIR" "$LLVM_SOURCE_DIR"
156187
157- - name : Upload artifacts
188+ - name : Upload LLVM distro artifacts
158189 uses : actions/upload-artifact@v4
159190 with :
160191 name : mlir_${{ matrix.name }}_artifact
161192 path : llvm-install
162193 if-no-files-found : warn
163194
195+ - name : Upload mlir-native-tools artifact
196+ uses : actions/upload-artifact@v4
197+ with :
198+ name : mlir_native_tools_${{ matrix.name }}_artifact
199+ path : wheelhouse
200+ if-no-files-found : warn
201+
164202 - name : Upload ccache log
165203 uses : actions/upload-artifact@v4
166204 with :
@@ -171,7 +209,7 @@ jobs:
171209 if : (!cancelled() && ((github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'workflow_dispatch'))
172210173211 with :
174- artifacts : " *.tar.gz"
212+ artifacts : " *.tar.gz,wheelhouse/*.whl "
175213 token : " ${{ secrets.GITHUB_TOKEN }}"
176214 tag : " llvm"
177215 name : " llvm"
0 commit comments