[clang] f9c05fc - [WebAssembly] Use the new crt1-command.o if present.

Dan Gohman via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 11 14:44:47 PST 2021


Author: Dan Gohman
Date: 2021-02-11T14:44:37-08:00
New Revision: f9c05fc391458e455e8e4d4108a7f270f2f7bedc

URL: https://github.com/llvm/llvm-project/commit/f9c05fc391458e455e8e4d4108a7f270f2f7bedc
DIFF: https://github.com/llvm/llvm-project/commit/f9c05fc391458e455e8e4d4108a7f270f2f7bedc.diff

LOG: [WebAssembly] Use the new crt1-command.o if present.

If crt1-command.o exists in the sysroot, the libc has new-style command
support, so use it.

Differential Revision: https://reviews.llvm.org/D89274

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/WebAssembly.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 6b654886e774..83a895b47142 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -77,6 +77,16 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
 
   const char *Crt1 = "crt1.o";
   const char *Entry = NULL;
+
+  // If crt1-command.o exists, it supports new-style commands, so use it.
+  // Otherwise, use the old crt1.o. This is a temporary transition measure.
+  // Once WASI libc no longer needs to support LLVM versions which lack
+  // support for new-style command, it can make crt1.o the same as
+  // crt1-command.o. And once LLVM no longer needs to support WASI libc
+  // versions before that, it can switch to using crt1-command.o.
+  if (ToolChain.GetFilePath("crt1-command.o") != "crt1-command.o")
+    Crt1 = "crt1-command.o";
+
   if (const Arg *A = Args.getLastArg(options::OPT_mexec_model_EQ)) {
     StringRef CM = A->getValue();
     if (CM == "command") {


        


More information about the cfe-commits mailing list