[clang][WebAssembly] Link crt2-command.o if available#104755
Open
[clang][WebAssembly] Link crt2-command.o if available#104755
Conversation
Member
|
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang Author: YAMAMOTO Takashi (yamt) ChangesFull diff: https://github.com/llvm/llvm-project/pull/104755.diff 1 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 9aacda5fd5702..7b95b95e3eee8 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -103,6 +103,7 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
bool IsCommand = true;
const char *Crt1;
+ const char *Crt2 = nullptr;
const char *Entry = nullptr;
// When -shared is specified, use the reactor exec model unless
@@ -132,13 +133,21 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
Crt1 = "crt1.o";
if (ToolChain.GetFilePath("crt1-command.o") != "crt1-command.o")
Crt1 = "crt1-command.o";
+ // Link another object as well if it's provided. It's planned to
+ // be used to fix https://github.com/WebAssembly/wasi-libc/issues/485
+ if (ToolChain.GetFilePath("crt2-command.o") != "crt2-command.o") {
+ Crt2 = "crt2-command.o";
+ }
} else {
Crt1 = "crt1-reactor.o";
Entry = "_initialize";
}
- if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(Crt1)));
+ if (Crt2)
+ CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(Crt2)));
+ }
if (Entry) {
CmdArgs.push_back(Args.MakeArgString("--entry"));
CmdArgs.push_back(Args.MakeArgString(Entry));
|
yamt
added a commit
to yamt/wasi-libc
that referenced
this pull request
Aug 19, 2024
yamt
added a commit
to yamt/garbage
that referenced
this pull request
Feb 10, 2025
yamt
added a commit
to yamt/garbage
that referenced
this pull request
Feb 10, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cf. WebAssembly/wasi-libc#528