-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds support for building WASI shared libraries per https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md. For the time being, the goal is to allow "pseudo-dynamic" linking using the Component Model per https://github.com/WebAssembly/component-model/blob/main/design/mvp/examples/SharedEverythingDynamicLinking.md. This requires all libraries to be available when the component is created, but still allows runtime symbol resolution via `dlopen`/`dlsym` backed by a static lookup table. This is sufficient to support Python native extensions, for example. A complete demo using `wit-component` is available at https://github.com/dicej/component-linking-demo. This requires https://reviews.llvm.org/D153293, which we will need to backport to LLVM 16 we're ready to upgrade to LLVM 17, hence the llvm-D153293-backport.patch file. Signed-off-by: Joel Dice <[email protected]>
- Loading branch information
Showing
6 changed files
with
69 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp | ||
index a1c4cd9ef9c7..4cbc0794f420 100644 | ||
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp | ||
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp | ||
@@ -101,13 +101,16 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA, | ||
<< CM << A->getOption().getName(); | ||
} | ||
} | ||
- if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) | ||
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles, options::OPT_shared)) | ||
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(Crt1))); | ||
if (Entry) { | ||
CmdArgs.push_back(Args.MakeArgString("--entry")); | ||
CmdArgs.push_back(Args.MakeArgString(Entry)); | ||
} | ||
|
||
+ if (Args.hasArg(options::OPT_shared)) | ||
+ CmdArgs.push_back(Args.MakeArgString("-shared")); | ||
+ | ||
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); | ||
|
||
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { | ||
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | ||
index 630c786a3dc7..788e08e3c8a9 100644 | ||
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | ||
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | ||
@@ -98,13 +98,6 @@ static Reloc::Model getEffectiveRelocModel(std::optional<Reloc::Model> RM, | ||
return Reloc::Static; | ||
} | ||
|
||
- if (!TT.isOSEmscripten()) { | ||
- // Relocation modes other than static are currently implemented in a way | ||
- // that only works for Emscripten, so disable them if we aren't targeting | ||
- // Emscripten. | ||
- return Reloc::Static; | ||
- } | ||
- | ||
return *RM; | ||
} | ||
|
Submodule wasi-libc
updated
8 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters