[PATCH] D70687: [WebAssembly] Add an llvm-lto path for compiler-rt.

Dan Gohman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 25 11:04:23 PST 2019


sunfish created this revision.
Herald added subscribers: cfe-commits, dexonsmith, aheejin, jgravelle-google, inglorion, sbc100, mehdi_amini, dberris, dschuff.
Herald added a project: clang.

This allows LTO-enabled builds of compiler-rt to be used.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70687

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/WebAssembly.h


Index: clang/lib/Driver/ToolChains/WebAssembly.h
===================================================================
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -71,6 +71,7 @@
   const char *getDefaultLinker() const override { return "wasm-ld"; }
 
   Tool *buildLinker() const override;
+  std::string getCompilerRTPath() const;
 };
 
 } // end namespace toolchains
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===================================================================
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -155,6 +155,19 @@
   }
 }
 
+std::string WebAssembly::getCompilerRTPath() const {
+  // If we're doing LTO and we have an LTO library available, use it.
+  const auto &D = getDriver();
+  if (D.isUsingLTO()) {
+    auto Dir = AppendLTOLibDir(ToolChain::getCompilerRTPath());
+    if (llvm::sys::fs::exists(Dir))
+      return Dir;
+  }
+
+  // Otherwise just use the default.
+  return ToolChain::getCompilerRTPath();
+}
+
 bool WebAssembly::IsMathErrnoDefault() const { return false; }
 
 bool WebAssembly::IsObjCNonFragileABIDefault() const { return true; }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70687.230939.patch
Type: text/x-patch
Size: 1196 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191125/4f175866/attachment.bin>


More information about the llvm-commits mailing list