|
17 | 17 | #include "clang/AST/DeclarationName.h" |
18 | 18 | #include "clang/AST/GlobalDecl.h" |
19 | 19 | #include "clang/Basic/LangOptions.h" |
| 20 | +#include "clang/Basic/TargetOptions.h" |
20 | 21 | #include "clang/Frontend/CompilerInstance.h" |
21 | 22 | #include "clang/Frontend/FrontendOptions.h" |
22 | 23 | #include "clang/Lex/Preprocessor.h" |
|
36 | 37 | #include "llvm/Support/Error.h" |
37 | 38 | #include "llvm/Support/TargetSelect.h" |
38 | 39 | #include "llvm/Support/raw_ostream.h" |
| 40 | +#include "llvm/TargetParser/Triple.h" |
39 | 41 |
|
40 | 42 | #include <utility> |
41 | 43 | #include <vector> |
@@ -412,18 +414,17 @@ class Interpreter { |
412 | 414 | } |
413 | 415 |
|
414 | 416 | CompilationResult loadLibrary(const std::string& filename, bool lookup) { |
415 | | -#ifdef __EMSCRIPTEN__ |
416 | | - if (lookup) { |
417 | | - llvm::errs() << "[cppinterop] Warning: 'lookup' has no effect on WASM.\n"; |
418 | | - } |
419 | | - // In WASM: directly use Interpreter's LoadDynamicLibrary |
420 | | - if (auto Err = inner->LoadDynamicLibrary(filename.c_str())) { |
421 | | - llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), |
422 | | - "loadLibrary: "); |
423 | | - return kFailure; |
| 417 | + llvm::Triple triple(getCompilerInstance()->getTargetOpts().Triple); |
| 418 | + if (triple.isWasm()) { |
| 419 | + // On WASM, dlopen-style canonical lookup has no effect. |
| 420 | + if (auto Err = inner->LoadDynamicLibrary(filename.c_str())) { |
| 421 | + llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), |
| 422 | + "loadLibrary: "); |
| 423 | + return kFailure; |
| 424 | + } |
| 425 | + return kSuccess; |
424 | 426 | } |
425 | | - return kSuccess; |
426 | | -#endif |
| 427 | + |
427 | 428 | DynamicLibraryManager* DLM = getDynamicLibraryManager(); |
428 | 429 | std::string canonicalLib; |
429 | 430 | if (lookup) |
|
0 commit comments