[PATCH] D70677: [WebAssembly] Change the llvm-lto dir to use the LLVM Version

Dan Gohman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 25 09:38:29 PST 2019


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

Using the version instead of the VCS revision, which isn't available when LLVM_APPEND_VC_REV is set. The bitcode format should be backwards-compatible at least within a minor version, so the version string should be sufficient.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70677

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


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===================================================================
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -119,14 +119,11 @@
 }
 
 /// Given a base library directory, append path components to form the
-/// LTO directory. The LLVMRevision allows the path to be keyed to the
-/// specific version of LLVM in used, as the bitcode format is not stable.
-static std::string AppendLTOLibDir(const std::string &Dir,
-                                   const std::string &LLVMRevision) {
-    if (LLVMRevision.empty()) {
-        return Dir;
-    }
-    return Dir + "/llvm-lto/" + LLVMRevision;
+/// LTO directory.
+static std::string AppendLTOLibDir(const std::string &Dir) {
+    // The version allows the path to be keyed to the specific version of
+    // LLVM in used, as the bitcode format is not stable.
+    return Dir + "/llvm-lto/" LLVM_VERSION_STRING;
 }
 
 WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple,
@@ -148,15 +145,11 @@
         getMultiarchTriple(getDriver(), Triple, getDriver().SysRoot);
     auto Sysroot = getDriver().SysRoot;
     if (D.isUsingLTO()) {
-      auto LLVMRevision = getLLVMRevision();
-      if (!LLVMRevision.empty()) {
-        // For LTO, enable use of lto-enabled sysroot libraries too, if available.
-        // Note that the directory is keyed to the LLVM revision, as LLVM's
-        // bitcode format is not stable.
-        auto Dir = AppendLTOLibDir(Sysroot + "/lib/" + MultiarchTriple,
-                                   LLVMRevision);
-        getFilePaths().push_back(Dir);
-      }
+      // For LTO, enable use of lto-enabled sysroot libraries too, if available.
+      // Note that the directory is keyed to the LLVM revision, as LLVM's
+      // bitcode format is not stable.
+      auto Dir = AppendLTOLibDir(Sysroot + "/lib/" + MultiarchTriple);
+      getFilePaths().push_back(Dir);
     }
     getFilePaths().push_back(Sysroot + "/lib/" + MultiarchTriple);
   }
@@ -166,12 +159,9 @@
   // If we're doing LTO and we have an LTO library available, use it.
   const auto &D = getDriver();
   if (D.isUsingLTO()) {
-    auto LLVMRevision = getLLVMRevision();
-    if (!LLVMRevision.empty()) {
-      auto Dir = AppendLTOLibDir(ToolChain::getCompilerRTPath(), LLVMRevision);
-      if (llvm::sys::fs::exists(Dir))
-        return Dir;
-    }
+    auto Dir = AppendLTOLibDir(ToolChain::getCompilerRTPath());
+    if (llvm::sys::fs::exists(Dir))
+      return Dir;
   }
 
   // Otherwise just use the default.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70677.230919.patch
Type: text/x-patch
Size: 2592 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191125/550894c6/attachment.bin>


More information about the cfe-commits mailing list