Skip to content

Commit c357fd6

Browse files
authored
Update wasm exception handling model (migration to emsdk 4-x) (#416)
* Update wasm exception handling model (use wasm-exceptions instead of exceptions) Add tests * Use jupyterlite-xeus 4.3.0 * Update host env install command
1 parent 778e639 commit c357fd6

File tree

17 files changed

+103
-48
lines changed

17 files changed

+103
-48
lines changed

.github/workflows/deploy-github-page.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ jobs:
4545
- name: Build and test xeus-cpp in node, then install
4646
shell: bash -l {0}
4747
run: |
48-
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
48+
micromamba create -f environment-wasm-host.yml \
49+
--platform=emscripten-wasm32 \
50+
-c https://prefix.dev/emscripten-forge-4x \
51+
-c https://prefix.dev/conda-forge
4952
5053
mkdir build
5154
pushd build
@@ -56,9 +59,6 @@ jobs:
5659
echo "PREFIX=$PREFIX" >> $GITHUB_ENV
5760
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
5861
59-
micromamba create -n node-env -c conda-forge nodejs=22
60-
export PATH="$MAMBA_ROOT_PREFIX/envs/node-env/bin:$PATH"
61-
6262
emcmake cmake \
6363
-DCMAKE_BUILD_TYPE=Release \
6464
-DCMAKE_INSTALL_PREFIX=$PREFIX \
@@ -142,7 +142,7 @@ jobs:
142142
- name: Jupyter Lite integration
143143
shell: bash -l {0}
144144
run: |
145-
micromamba create -n xeus-lite-host jupyterlite-core=0.6 jupyter_server jupyterlite-xeus -c conda-forge
145+
micromamba create -n xeus-lite-host jupyter_server jupyterlite-xeus -c conda-forge
146146
micromamba activate xeus-lite-host
147147
jupyter lite build \
148148
--XeusAddon.prefix=${{ env.PREFIX }} \

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@ jobs:
230230
- name: Build and test xeus-cpp in node, then install
231231
shell: bash -l {0}
232232
run: |
233-
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
233+
micromamba create -f environment-wasm-host.yml \
234+
--platform=emscripten-wasm32 \
235+
-c https://prefix.dev/emscripten-forge-4x \
236+
-c https://prefix.dev/conda-forge
234237
235238
mkdir build
236239
pushd build
@@ -241,9 +244,6 @@ jobs:
241244
echo "PREFIX=$PREFIX" >> $GITHUB_ENV
242245
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
243246
244-
micromamba create -n node-env -c conda-forge nodejs=22
245-
export PATH="$MAMBA_ROOT_PREFIX/envs/node-env/bin:$PATH"
246-
247247
emcmake cmake \
248248
-DCMAKE_BUILD_TYPE=Release \
249249
-DCMAKE_INSTALL_PREFIX=$PREFIX \
@@ -332,7 +332,7 @@ jobs:
332332
- name: Jupyter Lite integration
333333
shell: bash -l {0}
334334
run: |
335-
micromamba create -n xeus-lite-host jupyterlite-core=0.6 jupyterlite-xeus -c conda-forge
335+
micromamba create -n xeus-lite-host jupyterlite-xeus -c conda-forge
336336
micromamba activate xeus-lite-host
337337
jupyter lite build --XeusAddon.prefix=${{ env.PREFIX }}
338338

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ macro(xeus_cpp_set_common_options target_name)
219219
target_compile_options(${target_name} PUBLIC /wd4251 /wd4141)
220220
target_compile_options(${target_name} PUBLIC /wd4018 /wd4267 /wd4715 /wd4146 /wd4129)
221221
target_compile_options(${target_name} PUBLIC /EHsc)
222+
elseif (EMSCRIPTEN)
223+
target_compile_options(${target_name} PUBLIC -fwasm-exceptions)
222224
else ()
223225
target_compile_options(${target_name} PUBLIC -fexceptions)
224226
endif ()

CONTRIBUTING.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,20 @@ micromamba create -f environment-wasm-build.yml -y
7171
micromamba activate xeus-cpp-wasm-build
7272
```
7373

74-
You are now in a position to build the xeus-cpp kernel. You build and test it in node by executing the following. Prefer using node 22 and above as prior versions lead to flaky test runs. Once the test pass, run the install command.
74+
You are now in a position to build the xeus-cpp kernel. You build and test it in node by executing the following. Once the test pass, run the install command.
7575

7676
```bash
77-
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
77+
micromamba create -f environment-wasm-host.yml \
78+
--platform=emscripten-wasm32 \
79+
-c https://prefix.dev/emscripten-forge-4x \
80+
-c https://prefix.dev/conda-forge
81+
7882
mkdir build
7983
cd build
8084
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
8185
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-host
8286
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
8387

84-
micromamba create -n node-env -c conda-forge nodejs=22
85-
export PATH="$MAMBA_ROOT_PREFIX/envs/node-env/bin:$PATH"
86-
8788
emcmake cmake \
8889
-DCMAKE_BUILD_TYPE=Release \
8990
-DCMAKE_INSTALL_PREFIX=$PREFIX \
@@ -154,7 +155,7 @@ python $BUILD_PREFIX/bin/emrun.py --browser="google-chrome" --kill_exit --timeou
154155

155156
To build and test Jupyter Lite with this kernel locally you can execute the following
156157
```bash
157-
micromamba create -n xeus-lite-host jupyterlite-core=0.6 jupyter_server jupyterlite-xeus -c conda-forge
158+
micromamba create -n xeus-lite-host jupyter_server jupyterlite-xeus -c conda-forge
158159
micromamba activate xeus-lite-host
159160
jupyter lite serve --XeusAddon.prefix=$PREFIX \
160161
--XeusAddon.mounts="$PREFIX/share/xeus-cpp/tagfiles:/share/xeus-cpp/tagfiles" \

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,19 @@ micromamba create -f environment-wasm-build.yml -y
8787
micromamba activate xeus-cpp-wasm-build
8888
```
8989

90-
You are now in a position to build the xeus-cpp kernel. You build and test it in node by executing the following. Prefer using node 22 and above as prior versions lead to flaky test runs. Once the test pass, run the install command.
90+
You are now in a position to build the xeus-cpp kernel. You build and test it in node by executing the following. Once the test pass, run the install command.
9191
```bash
92-
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
92+
micromamba create -f environment-wasm-host.yml \
93+
--platform=emscripten-wasm32 \
94+
-c https://prefix.dev/emscripten-forge-4x \
95+
-c https://prefix.dev/conda-forge
96+
9397
mkdir build
9498
cd build
9599
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
96100
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-host
97101
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
98102

99-
micromamba create -n node-env -c conda-forge nodejs=22
100-
export PATH="$MAMBA_ROOT_PREFIX/envs/node-env/bin:$PATH"
101-
102103
emcmake cmake \
103104
-DCMAKE_BUILD_TYPE=Release \
104105
-DCMAKE_INSTALL_PREFIX=$PREFIX \
@@ -169,7 +170,7 @@ python $BUILD_PREFIX/bin/emrun.py --browser="google-chrome" --kill_exit --timeou
169170

170171
To build and test Jupyter Lite with this kernel locally you can execute the following
171172
```bash
172-
micromamba create -n xeus-lite-host jupyterlite-core=0.6 jupyter_server jupyterlite-xeus -c conda-forge
173+
micromamba create -n xeus-lite-host jupyter_server jupyterlite-xeus -c conda-forge
173174
micromamba activate xeus-lite-host
174175
jupyter lite serve --XeusAddon.prefix=$PREFIX \
175176
--XeusAddon.mounts="$PREFIX/share/xeus-cpp/tagfiles:/share/xeus-cpp/tagfiles" \

docs/source/InstallationAndUsage.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,21 @@ the following
6666
micromamba create -f environment-wasm-build.yml -y
6767
micromamba activate xeus-cpp-wasm-build
6868
69-
You are now in a position to build the xeus-cpp kernel. You build and test it in node by executing the following. Prefer using node 22 and above as prior versions lead to flaky test runs. Once the test pass, run the install command.
69+
You are now in a position to build the xeus-cpp kernel. You build and test it in node by executing the following. Once the test pass, run the install command.
7070

7171
.. code-block:: bash
7272
73-
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
73+
micromamba create -f environment-wasm-host.yml \
74+
--platform=emscripten-wasm32 \
75+
-c https://prefix.dev/emscripten-forge-4x \
76+
-c https://prefix.dev/conda-forge
77+
7478
mkdir build
7579
cd build
7680
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
7781
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-host
7882
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
7983
80-
micromamba create -n node-env -c conda-forge nodejs=22
81-
export PATH="$MAMBA_ROOT_PREFIX/envs/node-env/bin:$PATH"
82-
8384
emcmake cmake \
8485
-DCMAKE_BUILD_TYPE=Release \
8586
-DCMAKE_INSTALL_PREFIX=$PREFIX \
@@ -151,7 +152,7 @@ To build and test Jupyter Lite with this kernel locally you can execute the foll
151152

152153
.. code-block:: bash
153154
154-
micromamba create -n xeus-lite-host jupyterlite-core=0.6 jupyter_server jupyterlite-xeus -c conda-forge
155+
micromamba create -n xeus-lite-host jupyter_server jupyterlite-xeus -c conda-forge
155156
micromamba activate xeus-lite-host
156157
jupyter lite serve --XeusAddon.prefix=$PREFIX
157158
--XeusAddon.mounts="$PREFIX/share/xeus-cpp/tagfiles:/share/xeus-cpp/tagfiles" \

docs/source/conf.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
alias micromamba="$MAMBA_EXE";
2020
micromamba create -f environment-wasm-build.yml -y;
2121
micromamba activate xeus-cpp-wasm-build;
22-
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32;
22+
micromamba create -f environment-wasm-host.yml \
23+
--platform=emscripten-wasm32 \
24+
-c https://prefix.dev/emscripten-forge-4x \
25+
-c https://prefix.dev/conda-forge
2326
mkdir -p build;
2427
cd build;
2528
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/xeus-cpp-wasm-build;
@@ -34,9 +37,8 @@
3437
{XEUS_CPP_ROOT};
3538
emmake make -j $(nproc --all) install;
3639
cd {XEUS_CPP_ROOT};
37-
micromamba create -n xeus-lite-host jupyterlite-core=0.6 jupyter_server jupyterlite-xeus -c conda-forge -y;
40+
micromamba create -n xeus-lite-host jupyter_server jupyterlite-xeus -c conda-forge -y;
3841
micromamba activate xeus-lite-host;
39-
python -m pip install jupyterlite-xeus jupyter_server;
4042
jupyter lite build --XeusAddon.prefix=$PREFIX \\
4143
--XeusAddon.mounts="$PREFIX/share/xeus-cpp/tagfiles:/share/xeus-cpp/tagfiles" \
4244
--XeusAddon.mounts="$PREFIX/etc/xeus-cpp/tags.d:/etc/xeus-cpp/tags.d" \

environment-wasm-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: xeus-cpp-wasm-build
22
channels:
3-
- https://prefix.dev/emscripten-forge-dev
3+
- https://prefix.dev/emscripten-forge-4x
44
- https://prefix.dev/conda-forge
55
dependencies:
66
- cmake
7-
- emscripten_emscripten-wasm32==3.1.73
7+
- emscripten_emscripten-wasm32==4.0.9

environment-wasm-host.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: xeus-cpp-wasm-host
22
channels:
3-
- https://prefix.dev/emscripten-forge-dev
3+
- https://prefix.dev/emscripten-forge-4x
44
- https://prefix.dev/conda-forge
55
dependencies:
66
- nlohmann_json

share/jupyter/kernels/xc11/wasm_kernel.json.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"-Xclang", "-iwithsysroot/include/compat",
77
"-xc",
88
"-std=c11",
9-
"-mllvm", "-enable-emscripten-sjlj",
9+
"-fwasm-exceptions",
10+
"-mllvm", "-wasm-enable-sjlj",
1011
"-msimd128"
1112
],
1213
"language": "c",

0 commit comments

Comments
 (0)