Skip to content

Update Emscripten build to llvm 22 #3963

Update Emscripten build to llvm 22

Update Emscripten build to llvm 22 #3963

Workflow file for this run

name: WASM
on:
pull_request:
branches: [main]
push:
branches: [main]
release:
types: [published]
schedule:
- cron: '30 20 * * *' # Warning: Timezone dep - 20:00 is 1:00
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
env:
# Uniform across every wasm row; referenced below via env.* instead of
# being repeated on each matrix entry.
LLVM_ENABLE_PROJECTS: "clang;lld"
LLVM_TARGETS_TO_BUILD: "WebAssembly"
EMSDK_VER: "4.0.9"
BUILD_STATIC_LIBRARY: ${{ github.event_name == 'schedule' && 'On' || 'Off' }}
jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# clang-runtime is pinned once via a YAML anchor on the first row
# (cache key reads matrix.clang-runtime, so the field must live on
# each row). micromamba_shell_init is derived below from runner.os.
include:
- { name: ubu24-arm-emscr-llvm22, os: ubuntu-24.04-arm, clang-runtime: &clang_rt '22', wasm: true }
- { name: osx26-arm-emscr-llvm22, os: macos-26, clang-runtime: *clang_rt, wasm: true }
- { name: ubu24-x86-emscr-llvm22, os: ubuntu-24.04, clang-runtime: *clang_rt, wasm: true }
- { name: win2025-x86-emscr-llvm22, os: windows-2025, clang-runtime: *clang_rt, wasm: true, skip-in-prs: true }
steps:
- uses: actions/checkout@v6
if: ${{ !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
- name: Set up Python
if: ${{ !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Save PR Info
if: ${{ !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
uses: ./.github/actions/Miscellaneous/Save_PR_Info
- name: Restore cached LLVM-${{ matrix.clang-runtime }} and ${{ matrix.cling == 'On' && 'Cling' || 'Clang-REPL' }} build (Unix like systems emscripten)
if: ${{ !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
uses: actions/cache/restore@v4
id: cache
with:
path: |
llvm-project
${{ matrix.cling=='On' && 'cling' || '' }}
key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-clang-${{ matrix.clang-runtime }}.x-emscripten
- name: Setup emsdk
if: ${{ !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
run: |
git clone --depth=1 https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install ${{ env.EMSDK_VER }}
- name: Setup default Build Type
if: ${{ !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
uses: ./.github/actions/Miscellaneous/Select_Default_Build_Type
- name: Install deps on Windows
if: ${{ runner.os == 'windows' && steps.cache.outputs.cache-hit != 'true' && !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
run: |
choco install findutils ninja
$env:PATH="C:\Program Files (x86)\GnuWin32\bin;$env:PATH"
$env:PATH="C:\Program Files (x86)\Ninja\bin;$env:PATH"
- name: Install deps on MacOS
if: ${{ runner.os == 'macOS' && steps.cache.outputs.cache-hit != 'true' && !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
run: |
brew update
export ARCHITECHURE=$(uname -m)
if [[ "$ARCHITECHURE" != "x86_64" ]]; then
brew remove unxip
fi
# workaround for https://github.com/actions/setup-python/issues/577
for pkg in $(brew list | grep '^python@'); do
brew unlink "$pkg"
brew link --overwrite "$pkg"
done
brew install ninja
- name: Install deps on Linux
if: ${{ runner.os == 'Linux' && steps.cache.outputs.cache-hit != 'true' && !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
run: |
# Install deps
sudo apt-get update
sudo apt-get install ninja-build
sudo apt-get autoremove
sudo apt-get clean
- name: Build LLVM/Cling if the cache is invalid (emscripten)
if: ${{ !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
uses: ./.github/actions/Build_LLVM_WASM
with:
cache-hit: ${{ steps.cache.outputs.cache-hit }}
- name: Cache LLVM-${{ matrix.clang-runtime }} and ${{ matrix.cling == 'On' && 'Cling' || 'Clang-REPL' }} build
if: ${{ steps.cache.outputs.cache-hit != 'true' && !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
uses: actions/cache/save@v4
with:
path: |
llvm-project
${{ matrix.cling=='On' && 'cling' || '' }}
key: ${{ steps.cache.outputs.cache-primary-key }}
- name: install mamba
if: ${{ !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
uses: mamba-org/setup-micromamba@main
with:
init-shell: >-
${{ runner.os == 'Windows' && 'powershell' || 'bash' }}
- name: micromamba shell hook
if: ${{ runner.os == 'Windows' && !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
shell: powershell
run: |
micromamba shell hook -s cmd.exe --root-prefix C:\Users\runneradmin\micromamba-root
- name: Build and test CppInterOp
if: ${{ !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
uses: ./.github/actions/Build_and_Test_CppInterOp
- name: Build xeus-cpp on Unix Systems
if: ${{ runner.os != 'windows' && !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
shell: bash -l {0}
run: |
./emsdk/emsdk activate ${{ env.EMSDK_VER }}
source ./emsdk/emsdk_env.sh
micromamba activate CppInterOp-wasm
git clone --depth=1 https://github.com/compiler-research/xeus-cpp.git
cd ./xeus-cpp
mkdir build
pushd build
export CMAKE_PREFIX_PATH=${{ env.PREFIX }}
export CMAKE_SYSTEM_PREFIX_PATH=${{ env.PREFIX }}
emcmake cmake \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_PREFIX_PATH=${{ env.PREFIX }} \
-DCMAKE_INSTALL_PREFIX=${{ env.PREFIX }} \
-DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
-DXEUS_CPP_RESOURCE_DIR=${{ env.LLVM_BUILD_DIR }}/lib/clang/${{ matrix.clang-runtime }} \
-DSYSROOT_PATH=${{ env.SYSROOT_PATH }} \
..
emmake make -j ${{ env.ncpus }} install
- name: Build xeus-cpp on Windows systems
if: ${{ runner.os == 'windows' && !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
shell: powershell
run: |
.\emsdk\emsdk activate ${{ env.EMSDK_VER }}
.\emsdk\emsdk_env.ps1
micromamba activate CppInterOp-wasm
git clone --depth=1 https://github.com/compiler-research/xeus-cpp.git
cd .\xeus-cpp
mkdir build
pushd build
$env:CMAKE_PREFIX_PATH="${{ env.PREFIX }}"
$env:CMAKE_SYSTEM_PREFIX_PATH="${{ env.PREFIX }}"
emcmake cmake `
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} `
-DCMAKE_PREFIX_PATH=${{ env.PREFIX }} `
-DCMAKE_INSTALL_PREFIX=${{ env.PREFIX }} `
-DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON `
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON `
-DXEUS_CPP_RESOURCE_DIR=${{ env.LLVM_BUILD_DIR }}\lib\clang\${{ matrix.clang-runtime }} `
-DSYSROOT_PATH=${{ env.SYSROOT_PATH }} `
..
emmake make -j ${{ env.ncpus }} install
- name: Test xeus-cpp C++ Emscripten on Unix Systems
if: ${{ runner.os != 'windows' && !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
shell: bash -l {0}
run: |
set -e
micromamba activate CppInterOp-wasm
cd ./xeus-cpp/build/test
node test_xeus_cpp.js
- name: Test xeus-cpp C++ Emscripten on Windows Systems
if: ${{ runner.os == 'windows' && !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
shell: powershell
run: |
function Error-OnFailure {
param (
[Parameter(Mandatory)]
[ScriptBlock]$Command
)
& $Command
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
}
micromamba activate CppInterOp-wasm
cd .\xeus-cpp\build\test
node test_xeus_cpp.js
echo "Running test_xeus_cpp in Firefox"
Error-OnFailure { emrun.bat --browser="firefox.exe" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html }
echo "Running test_xeus_cpp in Chromium"
Error-OnFailure { emrun.bat --browser="chrome.exe" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html }
- name: Jupyter Lite integration
if: ${{ runner.os != 'windows' && !(github.event_name == 'pull_request' && matrix.skip-in-prs == true) }}
shell: bash -l {0}
run: |
cd ./xeus-cpp/
micromamba create -n xeus-lite-host jupyterlite-core jupyterlite-xeus jupyter_server jupyterlab notebook python-libarchive-c -c conda-forge
micromamba activate xeus-lite-host
jupyter lite build --XeusAddon.prefix=${{ env.PREFIX }} --contents notebooks/xeus-cpp-lite-demo.ipynb --contents notebooks/tinyraytracer.ipynb --contents notebooks/images/marie.png --contents notebooks/audio/audio.wav --output-dir dist
- name: Jupyter Lite integration
if: ${{ runner.os == 'windows' && !(github.event_name == 'pull_request' && matrix.skip-in-prs == true)}}
shell: powershell
run: |
cd .\xeus-cpp\
micromamba create -n xeus-lite-host jupyterlite-core jupyterlite-xeus jupyter_server jupyterlab notebook python-libarchive-c -c conda-forge
micromamba activate xeus-lite-host
jupyter lite build --XeusAddon.prefix=${{ env.PREFIX }} --contents notebooks/xeus-cpp-lite-demo.ipynb --contents notebooks/tinyraytracer.ipynb --contents notebooks/images/marie.png --contents notebooks/audio/audio.wav --output-dir dist