Skip to content

Commit 7ca44b5

Browse files
committed
build-all.py wasm - move SIDE_MODULE=2 to cmake
Next to `EXPORTED_FUNCTIONS` and avoid possible issues with pyodide in the future (pyodide is using `SIDE_MODULE=1`, but currently not providing it libraries of type `MODULE`, only for shared ones).
1 parent a6921b8 commit 7ca44b5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

nix/build-all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ def get_cmake_args_prefix_path(additional_paths: "Sequence[str]" = ()) -> "list[
14361436
ADDITIONAL_ARGS = "-Wl,-flat_namespace,-undefined,suppress"
14371437

14381438
if "wasm" in flags:
1439-
ADDITIONAL_ARGS = "-Wl,-undefined,suppress -sSIDE_MODULE=2"
1439+
ADDITIONAL_ARGS = "-Wl,-undefined,suppress"
14401440
# Override CMAKE_TOOLCHAIN_FILE because by default emscripten doesn't support building shared binaries.
14411441
if WASM_DEBUG:
14421442
os.environ["CMAKE_TOOLCHAIN_FILE"] = os.environ["WASM_TOOLCHAIN_FILE"]

src/ifcwrap/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,15 @@ set(SWIG_MODULE_ifcopenshell_wrapper_EXTRA_FLAGS "-interface" "_ifcopenshell_wra
9292
swig_add_library(ifcopenshell_wrapper LANGUAGE python SOURCES IfcPython.i)
9393
SET_PROPERTY(TARGET ${SWIG_MODULE_ifcopenshell_wrapper_REAL_NAME} PROPERTY SWIG_DEPENDS ${IFCOPENSHELL_LIBRARIES})
9494
if (WASM_BUILD)
95-
target_link_options(${SWIG_MODULE_ifcopenshell_wrapper_REAL_NAME} PRIVATE "-sEXPORTED_FUNCTIONS=_PyInit__ifcopenshell_wrapper")
95+
# SIDE_MODULE=1 - add to .so all symbols from linked archives (default used by pyodide).
96+
# Since currently libIfcGeom.a seems to be linked twice it results in duplicated symbols and compilation errors.
97+
# Possibly in the future we can clean up linked libs and try `=1`.
98+
# SIDE_MODULE=2 - add to .so only explicitly exported functions (`-s EXPORTED_FUNCTIONS).
99+
# Have to provide it here to override possible `=1` coming from pyodide.
100+
target_link_options(
101+
${SWIG_MODULE_ifcopenshell_wrapper_REAL_NAME}
102+
PRIVATE "SHELL:-s EXPORTED_FUNCTIONS=_PyInit__ifcopenshell_wrapper -s SIDE_MODULE=2"
103+
)
96104
endif()
97105
if("$ENV{LDFLAGS}" MATCHES ".undefined.suppress")
98106
# On osx there is some state in the python dylib. With `-Wl,undefined,suppress` we can ignore the missing symbols at compile time.

0 commit comments

Comments
 (0)