Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/deploy-github-page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ jobs:
echo "PREFIX=$PREFIX" >> $GITHUB_ENV
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
micromamba create -n node-env -c conda-forge nodejs=22
export PATH="$MAMBA_ROOT_PREFIX/envs/node-env/bin:$PATH"
emcmake cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,6 @@ jobs:
echo "PREFIX=$PREFIX" >> $GITHUB_ENV
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
micromamba create -n node-env -c conda-forge nodejs=22
export PATH="$MAMBA_ROOT_PREFIX/envs/node-env/bin:$PATH"
emcmake cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ macro(xeus_cpp_set_common_options target_name)
target_compile_options(${target_name} PUBLIC /wd4251 /wd4141)
target_compile_options(${target_name} PUBLIC /wd4018 /wd4267 /wd4715 /wd4146 /wd4129)
target_compile_options(${target_name} PUBLIC /EHsc)
elseif (EMSCRIPTEN)
target_compile_options(${target_name} PUBLIC -fwasm-exceptions)
else ()
target_compile_options(${target_name} PUBLIC -fexceptions)
endif ()
Expand Down
5 changes: 1 addition & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ micromamba create -f environment-wasm-build.yml -y
micromamba activate xeus-cpp-wasm-build
```

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.
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.

```bash
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
Expand All @@ -81,9 +81,6 @@ export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-host
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot

micromamba create -n node-env -c conda-forge nodejs=22
export PATH="$MAMBA_ROOT_PREFIX/envs/node-env/bin:$PATH"

emcmake cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ micromamba create -f environment-wasm-build.yml -y
micromamba activate xeus-cpp-wasm-build
```

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.
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.
```bash
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
mkdir build
Expand All @@ -97,9 +97,6 @@ export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-host
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot

micromamba create -n node-env -c conda-forge nodejs=22
export PATH="$MAMBA_ROOT_PREFIX/envs/node-env/bin:$PATH"

emcmake cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
Expand Down
5 changes: 1 addition & 4 deletions docs/source/InstallationAndUsage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ the following
micromamba create -f environment-wasm-build.yml -y
micromamba activate xeus-cpp-wasm-build

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.
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.

.. code-block:: bash

Expand All @@ -77,9 +77,6 @@ You are now in a position to build the xeus-cpp kernel. You build and test it in
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-host
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot

micromamba create -n node-env -c conda-forge nodejs=22
export PATH="$MAMBA_ROOT_PREFIX/envs/node-env/bin:$PATH"

emcmake cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
Expand Down
4 changes: 2 additions & 2 deletions environment-wasm-build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: xeus-cpp-wasm-build
channels:
- https://prefix.dev/emscripten-forge-dev
- https://prefix.dev/emscripten-forge-4x
- https://prefix.dev/conda-forge
dependencies:
- cmake
- emscripten_emscripten-wasm32==3.1.73
- emscripten_emscripten-wasm32==4.0.9
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 4.0.9 and not 4.0.18, given that is the latest emsdk in Emscripten forges 4x branch? You mention in this comment #413 (comment) that the 4x branch is now using 4.0.18, so wondering why this has been set to 4.0.9.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cause emscripten-forge devs decided to ;)

Note : The version is still changeable. There's no change affecting us between 9 and 18

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cause emscripten-forge devs decided to ;)

Note : The version is still changeable. There's no change affecting us between 9 and 18

2 changes: 1 addition & 1 deletion environment-wasm-host.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: xeus-cpp-wasm-host
channels:
- https://prefix.dev/emscripten-forge-dev
- https://prefix.dev/emscripten-forge-4x
- https://prefix.dev/conda-forge
dependencies:
- nlohmann_json
Expand Down
3 changes: 2 additions & 1 deletion share/jupyter/kernels/xc11/wasm_kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"-Xclang", "-iwithsysroot/include/compat",
"-xc",
"-std=c11",
"-mllvm", "-enable-emscripten-sjlj",
"-fwasm-exceptions",
"-mllvm", "-wasm-enable-sjlj",
"-msimd128"
],
"language": "c",
Expand Down
3 changes: 2 additions & 1 deletion share/jupyter/kernels/xc17/wasm_kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"-Xclang", "-iwithsysroot/include/compat",
"-xc",
"-std=c17",
"-mllvm", "-enable-emscripten-sjlj",
"-fwasm-exceptions",
"-mllvm", "-wasm-enable-sjlj",
"-msimd128"
],
"language": "c",
Expand Down
3 changes: 2 additions & 1 deletion share/jupyter/kernels/xc23/wasm_kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"-Xclang", "-iwithsysroot/include/compat",
"-xc",
"-std=c23",
"-mllvm", "-enable-emscripten-sjlj",
"-fwasm-exceptions",
"-mllvm", "-wasm-enable-sjlj",
"-msimd128"
],
"language": "c",
Expand Down
4 changes: 2 additions & 2 deletions share/jupyter/kernels/xcpp17/wasm_kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"@XEUS_CPP_KERNELSPEC_PATH@xcpp",
"-resource-dir", "/lib/clang/@CPPINTEROP_LLVM_VERSION_MAJOR@",
"-Xclang", "-iwithsysroot/include/compat",
"-std=c++17", "-mllvm", "-enable-emscripten-cxx-exceptions",
"-mllvm", "-enable-emscripten-sjlj", "-msimd128"
"-std=c++17", "-fwasm-exceptions",
"-mllvm", "-wasm-enable-sjlj", "-msimd128"
],
"language": "cpp",
"metadata": {
Expand Down
4 changes: 2 additions & 2 deletions share/jupyter/kernels/xcpp20/wasm_kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"@XEUS_CPP_KERNELSPEC_PATH@xcpp",
"-resource-dir", "/lib/clang/@CPPINTEROP_LLVM_VERSION_MAJOR@",
"-Xclang", "-iwithsysroot/include/compat",
"-std=c++20", "-mllvm", "-enable-emscripten-cxx-exceptions",
"-mllvm", "-enable-emscripten-sjlj", "-msimd128"
"-std=c++20", "-fwasm-exceptions",
"-mllvm", "-wasm-enable-sjlj", "-msimd128"
],
"language": "cpp",
"metadata": {
Expand Down
4 changes: 2 additions & 2 deletions share/jupyter/kernels/xcpp23/wasm_kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"@XEUS_CPP_KERNELSPEC_PATH@xcpp",
"-resource-dir", "/lib/clang/@CPPINTEROP_LLVM_VERSION_MAJOR@",
"-Xclang", "-iwithsysroot/include/compat",
"-std=c++23", "-mllvm", "-enable-emscripten-cxx-exceptions",
"-mllvm", "-enable-emscripten-sjlj", "-msimd128"
"-std=c++23", "-fwasm-exceptions",
"-mllvm", "-wasm-enable-sjlj", "-msimd128"
],
"language": "cpp",
"metadata": {
Expand Down
6 changes: 3 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if(EMSCRIPTEN)
target_link_libraries(test_xeus_cpp PRIVATE xeus-cpp-static doctest::doctest)

target_compile_options(test_xeus_cpp
PUBLIC "SHELL: -fexceptions"
PUBLIC "SHELL: -fwasm-exceptions"
)
# So we create a html file, as well as the javascript file
set_target_properties(test_xeus_cpp PROPERTIES
Expand All @@ -67,10 +67,10 @@ if(EMSCRIPTEN)
# Without this MINIFY_HTML=0 flag you end up with the situation where the creation of the
# test_xeus_cpp.html file breaks on MacOS, but not Ubuntu
target_link_options(test_xeus_cpp
PUBLIC "SHELL: -fexceptions"
PUBLIC "SHELL: -fwasm-exceptions"
PUBLIC "SHELL: -s MAIN_MODULE=1"
PUBLIC "SHELL: -s WASM_BIGINT"
PUBLIC "SHELL: -s ASSERTIONS=1"
PUBLIC "SHELL: -s ASSERTIONS=0"
PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1"
PUBLIC "SHELL: -s STACK_SIZE=32mb"
PUBLIC "SHELL: -s INITIAL_MEMORY=128mb"
Expand Down
49 changes: 46 additions & 3 deletions test/test_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ TEST_SUITE("execute_request")
{
TEST_CASE("stl")
{
std::vector<const char*> Args = {"stl-test-case", "-v"};
std::vector<const char*> Args = {
"-v",
"-Xclang", "-iwithsysroot/include/compat"
};
xcpp::interpreter interpreter((int)Args.size(), Args.data());
std::string code = "#include <vector>";
nl::json user_expressions = nl::json::object();
Expand Down Expand Up @@ -99,7 +102,6 @@ TEST_SUITE("execute_request")
REQUIRE(result["status"] == "ok");
}

#if defined(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
TEST_CASE("headers found in sysroot/include/compat")
{
std::vector<const char*> Args = {
Expand All @@ -124,6 +126,44 @@ TEST_SUITE("execute_request")
promise.set_value(result);
};

interpreter.execute_request(
std::move(context),
std::move(callback),
code,
std::move(config),
user_expressions
);
nl::json result = future.get();
REQUIRE(result["status"] == "ok");
}

#if defined(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
TEST_CASE("Emscripten Exception Handling")
{
std::vector<const char*> Args = {
"-std=c++20",
"-v",
"-fwasm-exceptions",
"-mllvm", "-wasm-enable-sjlj"
};

xcpp::interpreter interpreter((int)Args.size(), Args.data());
std::string code = "try { throw 1; } catch (...) { 0; }";
nl::json user_expressions = nl::json::object();
xeus::execute_request_config config;
config.silent = false;
config.store_history = false;
config.allow_stdin = false;
nl::json header = nl::json::object();
xeus::xrequest_context::guid_list id = {};
xeus::xrequest_context context(header, id);

std::promise<nl::json> promise;
std::future<nl::json> future = promise.get_future();
auto callback = [&promise](nl::json result) {
promise.set_value(result);
};

interpreter.execute_request(
std::move(context),
std::move(callback),
Expand Down Expand Up @@ -810,7 +850,10 @@ TEST_SUITE("complete_request")
{
TEST_CASE("completion_test")
{
std::vector<const char*> Args = {/*"-v", "resource-dir", "....."*/};
std::vector<const char*> Args = {
"-v",
"-Xclang", "-iwithsysroot/include/compat"
};
xcpp::interpreter interpreter((int)Args.size(), Args.data());
std::string code1 = "#include <iostream>";
nl::json user_expressions = nl::json::object();
Expand Down
Loading