]> granicus.if.org Git - clang/commitdiff
[WebAssembly] Include libclang_rt.builtins in the standard way
authorSam Clegg <sbc@chromium.org>
Fri, 27 Oct 2017 00:26:07 +0000 (00:26 +0000)
committerSam Clegg <sbc@chromium.org>
Fri, 27 Oct 2017 00:26:07 +0000 (00:26 +0000)
Differential Revision: https://reviews.llvm.org/D39218

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316719 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChain.cpp
lib/Driver/ToolChains/CommonArgs.cpp
lib/Driver/ToolChains/WebAssembly.cpp
test/Driver/wasm-toolchain.c

index 593cd82038f251e6fdaf794307ce82672f11f510..126994716621cf70f9c2cc2c39021a5149a83368 100644 (file)
@@ -309,7 +309,13 @@ static StringRef getArchNameForCompilerRTLib(const ToolChain &TC,
 
 std::string ToolChain::getCompilerRTPath() const {
   SmallString<128> Path(getDriver().ResourceDir);
-  StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
+  StringRef OSLibName;
+  if (Triple.isOSFreeBSD())
+    OSLibName = "freebsd";
+  else if (Triple.isOSBinFormatWasm())
+    OSLibName = "wasm";
+  else
+    OSLibName = getOS();
   llvm::sys::path::append(Path, "lib", OSLibName);
   return Path.str();
 }
index dc50c4f121f14a78b2de4d32eb771fff1224f1df..b359cbb77ef89f3ff3f279fff4602944a69a93b3 100644 (file)
@@ -1027,15 +1027,7 @@ void tools::AddRunTimeLibs(const ToolChain &TC, const Driver &D,
 
   switch (RLT) {
   case ToolChain::RLT_CompilerRT:
-    switch (TC.getTriple().getOS()) {
-    default:
-      llvm_unreachable("unsupported OS");
-    case llvm::Triple::Win32:
-    case llvm::Triple::Linux:
-    case llvm::Triple::Fuchsia:
-      CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
-      break;
-    }
+    CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
     break;
   case ToolChain::RLT_Libgcc:
     // Make sure libgcc is not used under MSVC environment by default
index 354f77fd66a5a54f878ed65206c78dd3b60ef97b..9f91237705b9315510da55473e8b844dbb49336f 100644 (file)
@@ -61,7 +61,7 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back("-allow-undefined-file");
     CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("wasm.syms")));
     CmdArgs.push_back("-lc");
-    CmdArgs.push_back("-lcompiler_rt");
+    AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args);
   }
 
   CmdArgs.push_back("-o");
index 39401c94ab75d4bb0dbaa8257865190d4228a9d8..6ef1b1fdb70f82956c02b59564d5cd86c6959939 100644 (file)
 
 // 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" "-lcompiler_rt" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[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" "-lcompiler_rt" "-o" "a.out"
+// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "[[temp]]" "-allow-undefined-file" "wasm.syms" "-lc" "{{.*}}/libclang_rt.builtins-wasm32.a" "-o" "a.out"