[clang] [clang-repl] Implement LoadDynamicLibrary for clang-repl wasm use cases (PR #133037)
Anutosh Bhat via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 27 00:25:41 PDT 2025
================
@@ -711,6 +712,14 @@ llvm::Error Interpreter::Undo(unsigned N) {
}
llvm::Error Interpreter::LoadDynamicLibrary(const char *name) {
+#ifdef __EMSCRIPTEN__
+ void *handle = dlopen(name, RTLD_NOW | RTLD_GLOBAL);
+ if (!handle) {
+ llvm::errs() << dlerror() << '\n';
+ return llvm::make_error<llvm::StringError>("Failed to load dynamic library",
+ llvm::inconvertibleErrorCode());
+ }
+#else
----------------
anutosh491 wrote:
Check how we can use the changes here in cppinterop to get dynamic library loaded and symbol addresses fetched at runtime !
https://github.com/compiler-research/CppInterOp/compare/main...anutosh491:CppInterOp:shared_libs
Everything boils down to preload as we know where in the MEMFS our shared lib exists !
https://github.com/llvm/llvm-project/pull/133037
More information about the cfe-commits
mailing list