Skip to content

Commit d41c21d

Browse files
fixes to build for WASM
1 parent f486377 commit d41c21d

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,23 @@ include(CMakeSystemSpecificInformation)
77
set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
88
set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)
99

10+
if (EMSCRIPTEN)
11+
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
12+
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s SIDE_MODULE=1")
13+
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s SIDE_MODULE=1")
14+
set(CMAKE_STRIP FALSE)
15+
endif()
16+
1017
add_library(cppyy-backend SHARED
1118
clingwrapper/src/clingwrapper.cxx
1219
)
1320

21+
if (EMSCRIPTEN)
22+
target_link_options(cppyy-backend
23+
PUBLIC "SHELL: -s WASM_BIGINT"
24+
)
25+
endif()
26+
1427
# set_target_properties(cppyy-backend PROPERTIES VERSION ${PROJECT_VERSION})
1528

1629
# set_target_properties(cppyy-backend PROPERTIES PUBLIC_HEADER include/cpp_cppyy.h)

clingwrapper/src/clingwrapper.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ class ApplicationStarter {
206206
g_builtins.insert(name+a);
207207
}
208208

209+
#ifndef __EMSCRIPTEN__
209210
// disable fast path if requested
210211
if (getenv("CPPYY_DISABLE_FASTPATH")) gEnableFastPath = false;
211212

@@ -230,6 +231,7 @@ class ApplicationStarter {
230231
Cpp::AddIncludePath((ClingBuildDir + "/include").c_str());
231232
Cpp::AddIncludePath((std::string(CPPINTEROP_DIR) + "/include").c_str());
232233
Cpp::LoadLibrary("libstdc++", /* lookup= */ true);
234+
#endif
233235

234236
// load frequently used headers
235237
const char* code =

python/cppyy_backend/loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
if 'win32' in sys.platform:
2121
soext = '.dll'
22-
elif 'linux' in sys.platform:
22+
elif 'linux' in sys.platform or 'emscripten' in sys.platform:
2323
soext = '.so'
2424
else:
2525
soext = '.dylib'

0 commit comments

Comments
 (0)