Skip to content

Commit 361dea2

Browse files
anutosh491vgvassilev
authored andcommitted
Add Emscripten compat include paths to wasm kernel specs.
Add supporting tests
1 parent 659e968 commit 361dea2

File tree

8 files changed

+41
-1
lines changed

8 files changed

+41
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"argv": [
44
"@XEUS_CPP_KERNELSPEC_PATH@xcpp",
55
"-resource-dir", "/lib/clang/@CPPINTEROP_LLVM_VERSION_MAJOR@",
6+
"-Xclang", "-iwithsysroot/include/compat",
67
"-xc",
78
"-std=c11",
89
"-mllvm", "-enable-emscripten-sjlj",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"argv": [
44
"@XEUS_CPP_KERNELSPEC_PATH@xcpp",
55
"-resource-dir", "/lib/clang/@CPPINTEROP_LLVM_VERSION_MAJOR@",
6+
"-Xclang", "-iwithsysroot/include/compat",
67
"-xc",
78
"-std=c17",
89
"-mllvm", "-enable-emscripten-sjlj",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"argv": [
44
"@XEUS_CPP_KERNELSPEC_PATH@xcpp",
55
"-resource-dir", "/lib/clang/@CPPINTEROP_LLVM_VERSION_MAJOR@",
6+
"-Xclang", "-iwithsysroot/include/compat",
67
"-xc",
78
"-std=c23",
89
"-mllvm", "-enable-emscripten-sjlj",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"argv": [
44
"@XEUS_CPP_KERNELSPEC_PATH@xcpp",
55
"-resource-dir", "/lib/clang/@CPPINTEROP_LLVM_VERSION_MAJOR@",
6+
"-Xclang", "-iwithsysroot/include/compat",
67
"-std=c++17", "-mllvm", "-enable-emscripten-cxx-exceptions",
78
"-mllvm", "-enable-emscripten-sjlj", "-msimd128"
89
],

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"argv": [
44
"@XEUS_CPP_KERNELSPEC_PATH@xcpp",
55
"-resource-dir", "/lib/clang/@CPPINTEROP_LLVM_VERSION_MAJOR@",
6+
"-Xclang", "-iwithsysroot/include/compat",
67
"-std=c++20", "-mllvm", "-enable-emscripten-cxx-exceptions",
78
"-mllvm", "-enable-emscripten-sjlj", "-msimd128"
89
],

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"argv": [
44
"@XEUS_CPP_KERNELSPEC_PATH@xcpp",
55
"-resource-dir", "/lib/clang/@CPPINTEROP_LLVM_VERSION_MAJOR@",
6+
"-Xclang", "-iwithsysroot/include/compat",
67
"-std=c++23", "-mllvm", "-enable-emscripten-cxx-exceptions",
78
"-mllvm", "-enable-emscripten-sjlj", "-msimd128"
89
],

src/xinterpreter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ void* createInterpreter(const Args &ExtraArgs = {}) {
4545
ClangArgs.push_back("-isystem");
4646
ClangArgs.push_back(CxxInclude.c_str());
4747
}
48+
4849
ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end());
4950
// FIXME: We should process the kernel input options and conditionally pass
5051
// the gpu args here.

test/test_interpreter.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,39 @@ TEST_SUITE("execute_request")
9999
REQUIRE(result["status"] == "ok");
100100
}
101101

102+
#if defined(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
103+
TEST_CASE("headers found in sysroot/include/compat")
104+
{
105+
std::vector<const char*> Args = {};
106+
xcpp::interpreter interpreter((int)Args.size(), Args.data());
107+
std::string code = "#include <xlocale.h>";
108+
nl::json user_expressions = nl::json::object();
109+
xeus::execute_request_config config;
110+
config.silent = false;
111+
config.store_history = false;
112+
config.allow_stdin = false;
113+
nl::json header = nl::json::object();
114+
xeus::xrequest_context::guid_list id = {};
115+
xeus::xrequest_context context(header, id);
116+
117+
std::promise<nl::json> promise;
118+
std::future<nl::json> future = promise.get_future();
119+
auto callback = [&promise](nl::json result) {
120+
promise.set_value(result);
121+
};
122+
123+
interpreter.execute_request(
124+
std::move(context),
125+
std::move(callback),
126+
code,
127+
std::move(config),
128+
user_expressions
129+
);
130+
nl::json result = future.get();
131+
REQUIRE(result["status"] == "ok");
132+
}
133+
#endif
134+
102135
TEST_CASE("fetch_documentation")
103136
{
104137
std::vector<const char*> Args = {/*"-v", "resource-dir", "....."*/};
@@ -1135,4 +1168,4 @@ TEST_CASE("C and C++ stdout/stderr capture")
11351168
REQUIRE(captured_out.find("C++ stdout") != std::string::npos);
11361169
REQUIRE(captured_err.find("C stderr") != std::string::npos);
11371170
REQUIRE(captured_err.find("C++ stderr") != std::string::npos);
1138-
}
1171+
}

0 commit comments

Comments
 (0)