https://github.com/anutosh491 created https://github.com/llvm/llvm-project/pull/116779
When running clang-repl in the browser we end up having something like the following ` "" -cc1 -triple wasm32-unknown-emscripten ...... -main-file-name "<<< inputs >>>" .... -fvisibility=hidden .... -o "<<< inputs >>>.o" -x c++ "<<< inputs >>>" ` Due to the default introduced through this commit (https://github.com/llvm/llvm-project/commit/e3d71e14d756d78f9e2538f2e530aa7c051541cd#diff-b5496baaf5c83e1ffa1a26d0815843b8d3224aba84366cbb6aeecf703808c803R2083) That being said, when we generated the shared libraries to be loaded on top of the main module while running clang-repl in the browser, we have to surpass the above through `--export-all` https://github.com/llvm/llvm-project/blob/b3e2b1a7eb258a7c9c55691d08342eface083499/clang/lib/Interpreter/Wasm.cpp#L78 This is because obviously `incr_module_XX.wasm` might want to access symbols out of file from `incr_module_XX-1.wasm` to `incr_mdoule_0.wasm` But this also exports some problematic things like `__dso_handle` that causes conflicts across modules.  A better way to deal with this is to pass `-fvisibility=default` to the `CompilerInstance`. >From 616ebd6b6487eeaa302e6d33de3a371e6c9843f5 Mon Sep 17 00:00:00 2001 From: anutosh491 <andersonbhat...@gmail.com> Date: Tue, 19 Nov 2024 15:38:37 +0530 Subject: [PATCH] Use default visibility for symbols while building CompilerInstance against emscripten --- clang/lib/Interpreter/Interpreter.cpp | 1 + clang/lib/Interpreter/Wasm.cpp | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index 73ad766e655180..999271aae7491d 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -197,6 +197,7 @@ IncrementalCompilerBuilder::CreateCpp() { Argv.push_back("-target"); Argv.push_back("wasm32-unknown-emscripten"); Argv.push_back("-shared"); + Argv.push_back("-fvisibility=default") #endif Argv.insert(Argv.end(), UserArgs.begin(), UserArgs.end()); diff --git a/clang/lib/Interpreter/Wasm.cpp b/clang/lib/Interpreter/Wasm.cpp index 79efbaa03982d0..6d4cc478dd6a85 100644 --- a/clang/lib/Interpreter/Wasm.cpp +++ b/clang/lib/Interpreter/Wasm.cpp @@ -75,7 +75,6 @@ llvm::Error WasmIncrementalExecutor::addModule(PartialTranslationUnit &PTU) { "-shared", "--import-memory", "--no-entry", - "--export-all", "--experimental-pic", "--stack-first", "--allow-undefined", _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits