Skip to content

Commit

Permalink
add wasm job
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Jul 14, 2023
1 parent 2196900 commit e5cbc96
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 1 deletion.
159 changes: 159 additions & 0 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: WASM

on:
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
type: boolean
required: false
default: false
debug_os:
description: 'which runner os to run the tmate action in (if the tmate action is run)'
type: string
default: 'windows-2022'
required: false
debug_detached:
description: 'whether to launch tmate in detached mode (if the tmate action is run)'
type: boolean
required: false
default: true
llvm_commit:
description: 'llvm commit to build'
type: string
required: false
default: ''

pull_request:
release:
types:
- published

schedule:
# At minute 0 past hour 1, 7, 13, and 19. (see https://crontab.guru)
- cron: '00 01,07,13,19 * * *'

jobs:

get_llvm_project_commit:

name: Get latest LLVM commit

runs-on: ubuntu-latest
outputs:
LLVM_PROJECT_COMMIT: ${{ steps.get_llvm_project_commit.outputs.LLVM_PROJECT_COMMIT }}
steps:
- name: Get llvm-project commit
id: get_llvm_project_commit
run: |
if [ x"${{ inputs.llvm_commit }}" == x"" ]; then
sudo apt install jq
LLVM_PROJECT_COMMIT=$(curl -s https://api.github.com/repos/llvm/llvm-project/commits/main | jq -r '.sha[:8]')
else
LLVM_PROJECT_COMMIT="${{ inputs.llvm_commit }}"
fi
echo "LLVM_PROJECT_COMMIT=${LLVM_PROJECT_COMMIT}" | tee -a $GITHUB_OUTPUT
build:
needs: get_llvm_project_commit
continue-on-error: true

runs-on: ubuntu-20.04
outputs:
LLVM_PROJECT_COMMIT: ${{ needs.get_llvm_project_commit.outputs.LLVM_PROJECT_COMMIT }}

steps:
- uses: actions/checkout@v3

- name: Free disk space
uses: jlumbroso/free-disk-space@76866dbe54312617f00798d1762df7f43def6e5c # v1.2.0
with:
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: false # This frees space on the wrong partition.
tool-cache: false # This includes Python, which we need.

- name: Get LLVM
shell: bash
run: |
curl -s https://codeload.github.com/llvm/llvm-project/zip/${{ needs.get_llvm_project_commit.outputs.LLVM_PROJECT_COMMIT }} -o llvm.zip
unzip -q llvm.zip
mv llvm-project-${{ needs.get_llvm_project_commit.outputs.LLVM_PROJECT_COMMIT }} llvm-project
echo "LLVM_PROJECT_MAIN_SRC_DIR=$PWD/llvm-project" | tee -a $GITHUB_ENV
echo "LLVM_PROJECT_HOST_MAIN_BINARY_DIR=$PWD/build_host" | tee -a $GITHUB_ENV
# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled && inputs.debug_os == matrix.os }}
with:
limit-access-to-actor: true
detached: ${{ inputs.debug_detached }}

- name: Install Ninja
uses: llvm/actions/install-ninja@6a57890d0e3f9f35dfc72e7e48bc5e1e527cdd6c # Jan 17

- name: Build host llvm-tblgen/mlir-tblgen
shell: bash
id: build_host_tools
run: |
if [ x"${{ matrix.os }}" == x"ubuntu-20.04" ]; then
export "STATIC_FLAGS=-static-libgcc -static-libstdc++"
fi
cmake \
-G Ninja \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS="-O2 ${STATIC_FLAGS}" \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_ZLIB=OFF \
-DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_TARGETS_TO_BUILD=X86 \
-S${LLVM_PROJECT_MAIN_SRC_DIR}/llvm \
-B${LLVM_PROJECT_HOST_MAIN_BINARY_DIR}
cmake --build ${LLVM_PROJECT_HOST_MAIN_BINARY_DIR} \
--target llvm-tblgen mlir-tblgen mlir-linalg-ods-yaml-gen mlir-pdll llvm-config -j 20
- uses: mymindstorm/setup-emsdk@v11

- name: Verify emcc
run: |
emcc -v
# https://github.com/soedirgo/llvm-wasm
- name: Build host mlir
run: |
EMCC_DEBUG=2 \
CXXFLAGS="-Dwait4=__syscall_wait4" \
LDFLAGS="-s NO_INVOKE_RUN -s EXIT_RUNTIME -s INITIAL_MEMORY=64MB -s ALLOW_MEMORY_GROWTH -s EXPORTED_RUNTIME_METHODS=FS,callMain -s MODULARIZE -s EXPORT_ES6 -s WASM_BIGINT" \
emcmake cmake \
-G Ninja \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$PWD/install \
-DLLVM_DEFAULT_TARGET_TRIPLE=wasm32-wasi \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_THREADS=OFF \
-DLLVM_ENABLE_ZLIB=OFF \
-DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_TABLEGEN=$LLVM_PROJECT_HOST_MAIN_BINARY_DIR/bin/llvm-tblgen \
-DLLVM_TARGET_ARCH=wasm32-emscripten \
-DLLVM_USE_HOST_TOOLS=ON \
-DMLIR_LINALG_ODS_YAML_GEN=$LLVM_PROJECT_HOST_MAIN_BINARY_DIR/bin/mlir-linalg-ods-yaml-gen \
-DMLIR_LINALG_ODS_YAML_GEN_EXE=$LLVM_PROJECT_HOST_MAIN_BINARY_DIR/bin/mlir-linalg-ods-yaml-gen \
-DMLIR_PDLL_TABLEGEN=$LLVM_PROJECT_HOST_MAIN_BINARY_DIR/bin/mlir-pdll \
-DMLIR_TABLEGEN=$LLVM_PROJECT_HOST_MAIN_BINARY_DIR/bin/mlir-tblgen \
-S${LLVM_PROJECT_MAIN_SRC_DIR}/llvm \
\
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
\
-B${LLVM_PROJECT_HOST_MAIN_BINARY_DIR}
cmake --build ${LLVM_PROJECT_HOST_MAIN_BINARY_DIR} --target install
1 change: 0 additions & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ on:
required: false
default: ''

pull_request:
release:
types:
- published
Expand Down

0 comments on commit e5cbc96

Please sign in to comment.