https://github.com/anutosh491 created https://github.com/llvm/llvm-project/pull/133037
None >From dfe49e826705a5e9371e17e66e40c31602beea8e Mon Sep 17 00:00:00 2001 From: anutosh491 <andersonbhat...@gmail.com> Date: Wed, 26 Mar 2025 10:33:37 +0530 Subject: [PATCH] Implement LoadDynamicLibrary for clang-repl wasm use cases --- clang/lib/Interpreter/Interpreter.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index fa4c1439c9261..b4c68f340abc0 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -18,6 +18,7 @@ #include "llvm/Support/VirtualFileSystem.h" #ifdef __EMSCRIPTEN__ #include "Wasm.h" +#include <dlfcn.h> #endif // __EMSCRIPTEN__ #include "clang/AST/ASTConsumer.h" @@ -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 auto EE = getExecutionEngine(); if (!EE) return EE.takeError(); @@ -722,6 +731,7 @@ llvm::Error Interpreter::LoadDynamicLibrary(const char *name) { EE->getMainJITDylib().addGenerator(std::move(*DLSG)); else return DLSG.takeError(); +#endif return llvm::Error::success(); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits