[clang] [clang-repl] Use default visibility for symbols while building CompilerInstance against emscripten (PR #116779)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 19 02:19:47 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Anutosh Bhat (anutosh491)
<details>
<summary>Changes</summary>
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.
![image](https://github.com/user-attachments/assets/007cb2a8-e732-4e7a-9950-ff54785e62a6)
A better way to deal with this is to pass `-fvisibility=default` to the `CompilerInstance`.
---
Full diff: https://github.com/llvm/llvm-project/pull/116779.diff
2 Files Affected:
- (modified) clang/lib/Interpreter/Interpreter.cpp (+1)
- (modified) clang/lib/Interpreter/Wasm.cpp (-1)
``````````diff
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",
``````````
</details>
https://github.com/llvm/llvm-project/pull/116779
More information about the cfe-commits
mailing list