[PATCH] D107682: [AVR][clang] Search avr-libc installtion path according to avr-gcc's

Ben Shi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 6 20:41:38 PDT 2021


benshi001 created this revision.
benshi001 added reviewers: MaskRay, dylanmckay.
Herald added a subscriber: Jim.
benshi001 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107682

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


Index: clang/lib/Driver/ToolChains/AVR.cpp
===================================================================
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -297,12 +297,6 @@
   return Optional<unsigned>();
 }
 
-const StringRef PossibleAVRLibcLocations[] = {
-    "/avr",
-    "/usr/avr",
-    "/usr/lib/avr",
-};
-
 } // end anonymous namespace
 
 /// AVR Toolchain
@@ -453,12 +447,9 @@
 }
 
 llvm::Optional<std::string> AVRToolChain::findAVRLibcInstallation() const {
-  for (StringRef PossiblePath : PossibleAVRLibcLocations) {
-    std::string Path = getDriver().SysRoot + PossiblePath.str();
-    // Return the first avr-libc installation that exists.
-    if (llvm::sys::fs::is_directory(Path))
-      return Optional<std::string>(Path);
-  }
-
+  std::string GCCRoot(GCCInstallation.getInstallPath());
+  std::string Path(GCCRoot + "/../../../avr");
+  if (llvm::sys::fs::is_directory(Path))
+    return Optional<std::string>(Path);
   return llvm::None;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107682.364925.patch
Type: text/x-patch
Size: 1003 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210807/449da444/attachment-0001.bin>


More information about the cfe-commits mailing list