[PATCH] D110142: [clang][Driver] Correct runtime path for Arm hard float targets

David Spickett via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 21 02:54:16 PDT 2021


DavidSpickett created this revision.
Herald added a subscriber: kristof.beyls.
DavidSpickett requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

On armv8l and arm (armv7) the architecture in the library
path will be "armhf" if we have hard float enabled.

This fixes failures like:
https://lab.llvm.org/buildbot/#/builders/178/builds/591

Where we can't find the libraries since
https://reviews.llvm.org/D107799 landed.

Before:
$ ./bin/clang --target=armv8l-unknown-linux-gnueabihf -print-runtime-dir
<...>/build-llvm-arm/lib/clang/14.0.0/lib/linux

After:
$ ./bin/clang --target=armv8l-unknown-linux-gnueabihf -print-runtime-dir
<...>/build-llvm-arm/lib/clang/14.0.0/lib/armhf-unknown-linux-gnueabihf


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110142

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp


Index: clang/lib/Driver/ToolChain.cpp
===================================================================
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -75,7 +75,7 @@
                      const ArgList &Args)
     : D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)),
       CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)) {
-  std::string RuntimePath = getRuntimePath();
+  std::string RuntimePath = getRuntimePath(Args);
   if (getVFS().exists(RuntimePath))
     getLibraryPaths().push_back(RuntimePath);
 
@@ -487,9 +487,13 @@
   return Args.MakeArgString(getCompilerRT(Args, Component, Type));
 }
 
-std::string ToolChain::getRuntimePath() const {
+std::string ToolChain::getRuntimePath(const llvm::opt::ArgList &Args) const {
+  llvm::Triple triple = getTriple();
+  RegisterEffectiveTriple TripleRAII(*this, triple);
+  auto arch_name = getArchNameForCompilerRTLib(*this, Args);
+  triple.setArchName(arch_name);
   SmallString<128> P(D.ResourceDir);
-  llvm::sys::path::append(P, "lib", getTripleString());
+  llvm::sys::path::append(P, "lib", triple.getTriple());
   return std::string(P.str());
 }
 
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1830,7 +1830,7 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_runtime_dir)) {
-    std::string CandidateRuntimePath = TC.getRuntimePath();
+    std::string CandidateRuntimePath = TC.getRuntimePath(C.getArgs());
     if (getVFS().exists(CandidateRuntimePath))
       llvm::outs() << CandidateRuntimePath << '\n';
     else
Index: clang/include/clang/Driver/ToolChain.h
===================================================================
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -446,7 +446,7 @@
                                     FileType Type = ToolChain::FT_Static) const;
 
   // Returns target specific runtime path if it exists.
-  virtual std::string getRuntimePath() const;
+  virtual std::string getRuntimePath(const llvm::opt::ArgList &Args) const;
 
   // Returns target specific standard library path if it exists.
   virtual std::string getStdlibPath() const;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110142.373825.patch
Type: text/x-patch
Size: 2267 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210921/d981e00b/attachment.bin>


More information about the cfe-commits mailing list