From 226581f76ee87ab56f1481702a1112cf54641f48 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 16 Oct 2025 10:56:36 +0500 Subject: [PATCH] build-all.py - provide exported functions to target explicitly Otherwise it broke compilation in some cases when cmake would try to test that linker is working. --- nix/build-all.py | 2 +- src/ifcwrap/CMakeLists.txt | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/nix/build-all.py b/nix/build-all.py index fab851e50a..bd78666b3c 100644 --- a/nix/build-all.py +++ b/nix/build-all.py @@ -1409,7 +1409,7 @@ if "IfcOpenShell-Python" in targets: ADDITIONAL_ARGS = "-Wl,-flat_namespace,-undefined,suppress" if "wasm" in flags: - ADDITIONAL_ARGS = f"-Wl,-undefined,suppress -sSIDE_MODULE=2 -sEXPORTED_FUNCTIONS=_PyInit__ifcopenshell_wrapper" + ADDITIONAL_ARGS = "-Wl,-undefined,suppress -sSIDE_MODULE=2" # NOTE: We don't use `CXXFLAGS` for wrappers, so wrapper is compiled with different flags # (e.g. ` -fdata-sections` is missing, which is set by default for executables) diff --git a/src/ifcwrap/CMakeLists.txt b/src/ifcwrap/CMakeLists.txt index 073b31d9d7..3a31d28a95 100644 --- a/src/ifcwrap/CMakeLists.txt +++ b/src/ifcwrap/CMakeLists.txt @@ -88,6 +88,9 @@ set(SWIG_MODULE_ifcopenshell_wrapper_EXTRA_FLAGS "-interface" "_ifcopenshell_wra swig_add_library(ifcopenshell_wrapper LANGUAGE python SOURCES IfcPython.i) SET_PROPERTY(TARGET ${SWIG_MODULE_ifcopenshell_wrapper_REAL_NAME} PROPERTY SWIG_DEPENDS ${IFCOPENSHELL_LIBRARIES}) +if (WASM_BUILD) + target_link_options(${SWIG_MODULE_ifcopenshell_wrapper_REAL_NAME} PRIVATE "-sEXPORTED_FUNCTIONS=_PyInit__ifcopenshell_wrapper") +endif() if("$ENV{LDFLAGS}" MATCHES ".undefined.suppress") # On osx there is some state in the python dylib. With `-Wl,undefined,suppress` we can ignore the missing symbols at compile time. SWIG_LINK_LIBRARIES(ifcopenshell_wrapper ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${LIBSVGFILL})