From 0a0cb5e051c3fec7e8ad24aeba0b4aaa6168cda0 Mon Sep 17 00:00:00 2001 From: mcbarton Date: Wed, 29 Oct 2025 19:58:31 +0000 Subject: [PATCH 1/3] Search for lld for Emscripten builds that use cling --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d1aa034d..cb2d8b313 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,6 +106,9 @@ include(GNUInstallDirs) if (CPPINTEROP_USE_CLING) message(STATUS "Mode CPPINTEROP_USE_CLING = ON") find_package(LLVM REQUIRED CONFIG ${llvm_search_hints} NO_DEFAULT_PATH) + if(EMSCRIPTEN) + find_package(LLD REQUIRED CONFIG ${lld_search_hints} NO_DEFAULT_PATH) + endif() find_package(Clang REQUIRED CONFIG ${clang_search_hints} NO_DEFAULT_PATH) find_package(Cling REQUIRED CONFIG ${cling_search_hints} NO_DEFAULT_PATH) endif(CPPINTEROP_USE_CLING) From 3bf5cd7d29dc4adf33c7322a03eca54fb688d58d Mon Sep 17 00:00:00 2001 From: mcbarton Date: Wed, 29 Oct 2025 19:59:26 +0000 Subject: [PATCH 2/3] Add cling-exports.ld with LLVM and Clang exports --- lib/CppInterOp/cling-exports.ld | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 lib/CppInterOp/cling-exports.ld diff --git a/lib/CppInterOp/cling-exports.ld b/lib/CppInterOp/cling-exports.ld new file mode 100644 index 000000000..488b6b58c --- /dev/null +++ b/lib/CppInterOp/cling-exports.ld @@ -0,0 +1,33 @@ +-Wl,--export=_ZN4llvm13StringMapImpl11RehashTableEj +-Wl,--export=_ZN4llvm13StringMapImpl15LookupBucketForENS_9StringRefEj +-Wl,--export=_ZN4llvm13StringMapImpl4hashENS_9StringRefE +-Wl,--export=_ZN4llvm15SmallVectorBaseIjE8grow_podEPvmm +-Wl,--export=_ZN4llvm15allocate_bufferEmm +-Wl,--export=_ZN4llvm3sys17RunningOnValgrindEv +-Wl,--export=_ZN4llvm5APIntC1EjNS_8ArrayRefIyEE +-Wl,--export=_ZN5clang11DeclContext7classofEPKNS_4DeclE +-Wl,--export=_ZN5clang4Decl17castToDeclContextEPKS0_ +-Wl,--export=_ZNK4llvm5APInt13compareSignedERKS0_ +-Wl,--export=_ZNK4llvm5APInt4sextEj +-Wl,--export=_ZNK4llvm5APInt4zextEj +-Wl,--export=_ZNK4llvm5APInt7compareERKS0_ +-Wl,--export=_ZNK5clang10ASTContext14getComplexTypeENS_8QualTypeE +-Wl,--export=_ZNK5clang10ASTContext19getTypeDeclTypeSlowEPKNS_8TypeDeclE +-Wl,--export=_ZNK5clang10ASTContext22getLValueReferenceTypeENS_8QualTypeEb +-Wl,--export=_ZNK5clang10RecordDecl19isInjectedClassNameEv +-Wl,--export=_ZNK5clang11DeclContext11decls_beginEv +-Wl,--export=_ZNK5clang11DeclContext6lookupENS_15DeclarationNameE +-Wl,--export=_ZNK5clang12FunctionDecl12getNumParamsEv +-Wl,--export=_ZNK5clang12FunctionDecl29getTemplateSpecializationArgsEv +-Wl,--export=_ZNK5clang12FunctionDecl31getTemplateInstantiationPatternEb +-Wl,--export=_ZNK5clang17ClassTemplateDecl18getSpecializationsEv +-Wl,--export=_ZNK5clang29VarTemplateSpecializationDecl22getSpecializedTemplateEv +-Wl,--export=_ZNK5clang4Decl13getASTContextEv +-Wl,--export=_ZNK5clang4Decl15hasDefiningAttrEv +-Wl,--export=_ZNK5clang4Sema15getStdNamespaceEv +-Wl,--export=_ZNK5clang4Type14isFloatingTypeEv +-Wl,--export=_ZNK5clang4Type27getUnqualifiedDesugaredTypeEv +-Wl,--export=_ZNK5clang7TagType7getDeclEv +-Wl,--export=_ZNK5clang7VarDecl28isThisDeclarationADefinitionERNS_10ASTContextE +-Wl,--export=_ZN4llvm3sys2fs17getMainExecutableEPKcPv +-Wl,--export=_ZN4llvm3sys4path6appendERNS_15SmallVectorImplIcEERKNS_5TwineES7_S7_S7_ From e2b68c7be7b20f76f8a3a965b125cefc76ac8546 Mon Sep 17 00:00:00 2001 From: mcbarton Date: Wed, 29 Oct 2025 20:01:29 +0000 Subject: [PATCH 3/3] Add different exports.ld for cling --- lib/CppInterOp/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/CppInterOp/CMakeLists.txt b/lib/CppInterOp/CMakeLists.txt index 41288fb60..1267298c3 100644 --- a/lib/CppInterOp/CMakeLists.txt +++ b/lib/CppInterOp/CMakeLists.txt @@ -122,7 +122,11 @@ if(EMSCRIPTEN) # unit tests main_module you get errors due to undefined symbols. The reading of the file # below into a SYMBOLS_LIST variable is a temporary workaround that exports the undefined # symbols from the shared library, until it can be determined why they are not being exported already. - file(READ "${CMAKE_CURRENT_SOURCE_DIR}/exports.ld" SYMBOLS_LIST) + if (CPPINTEROP_USE_CLING) + file(READ "${CMAKE_CURRENT_SOURCE_DIR}/cling-exports.ld" SYMBOLS_LIST) + else() + file(READ "${CMAKE_CURRENT_SOURCE_DIR}/exports.ld" SYMBOLS_LIST) + endif() # Replace newlines with spaces string(REPLACE "\n" " " SYMBOLS_LIST "${SYMBOLS_LIST}")