Skip to content

Commit c2dbd47

Browse files
committed
use TargetOpts
1 parent 3735c88 commit c2dbd47

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lib/Interpreter/CppInterOpInterpreter.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "clang/AST/DeclarationName.h"
1818
#include "clang/AST/GlobalDecl.h"
1919
#include "clang/Basic/LangOptions.h"
20+
#include "clang/Basic/TargetOptions.h"
2021
#include "clang/Frontend/CompilerInstance.h"
2122
#include "clang/Frontend/FrontendOptions.h"
2223
#include "clang/Lex/Preprocessor.h"
@@ -36,6 +37,7 @@
3637
#include "llvm/Support/Error.h"
3738
#include "llvm/Support/TargetSelect.h"
3839
#include "llvm/Support/raw_ostream.h"
40+
#include "llvm/TargetParser/Triple.h"
3941

4042
#include <utility>
4143
#include <vector>
@@ -412,18 +414,17 @@ class Interpreter {
412414
}
413415

414416
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;
424426
}
425-
return kSuccess;
426-
#endif
427+
427428
DynamicLibraryManager* DLM = getDynamicLibraryManager();
428429
std::string canonicalLib;
429430
if (lookup)

0 commit comments

Comments
 (0)