[PATCH] D39354: [WebAssembly] Add crt1.o when calling lld
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 27 11:10:53 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL316777: [WebAssembly] Add crt1.o with calling lld (authored by sbc).
Repository:
rL LLVM
https://reviews.llvm.org/D39354
Files:
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/test/Driver/wasm-toolchain.c
Index: cfe/trunk/test/Driver/wasm-toolchain.c
===================================================================
--- cfe/trunk/test/Driver/wasm-toolchain.c
+++ cfe/trunk/test/Driver/wasm-toolchain.c
@@ -27,10 +27,10 @@
// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
// LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" "-allow-undefined-file" "wasm.syms" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-allow-undefined-file" "wasm.syms" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
// A basic C link command-line with optimization.
// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
// LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" "-allow-undefined-file" "wasm.syms" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-allow-undefined-file" "wasm.syms" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
Index: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
===================================================================
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
@@ -49,6 +49,9 @@
Args.AddAllArgs(CmdArgs, options::OPT_L);
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
+ CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt1.o")));
+
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===================================================================
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -309,14 +309,12 @@
std::string ToolChain::getCompilerRTPath() const {
SmallString<128> Path(getDriver().ResourceDir);
- StringRef OSLibName;
- if (Triple.isOSFreeBSD())
- OSLibName = "freebsd";
- else if (Triple.isOSBinFormatWasm())
- OSLibName = "wasm";
- else
- OSLibName = getOS();
- llvm::sys::path::append(Path, "lib", OSLibName);
+ if (Triple.isOSUnknown()) {
+ llvm::sys::path::append(Path, "lib");
+ } else {
+ StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
+ llvm::sys::path::append(Path, "lib", OSLibName);
+ }
return Path.str();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39354.120656.patch
Type: text/x-patch
Size: 2751 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171027/0465ee9d/attachment.bin>
More information about the cfe-commits
mailing list