[PATCH] D95529: [AVR][clang] Fix a bug in AVR toolchain search paths

Ben Shi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 2 06:46:16 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG9b0b435d7931: [AVR][clang] Fix a bug in AVR toolchain search paths (authored by benshi001).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95529/new/

https://reviews.llvm.org/D95529

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Driver/Inputs/basic_avr_tree/usr/bin/avr-ld
  clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/libavr.a
  clang/test/Driver/Inputs/basic_avr_tree/usr/lib/gcc/avr/5.4.0/libgcc.a
  clang/test/Driver/avr-ld.c


Index: clang/test/Driver/avr-ld.c
===================================================================
--- /dev/null
+++ clang/test/Driver/avr-ld.c
@@ -0,0 +1,2 @@
+// RUN: %clang -### --target=avr -mmcu=atmega328 --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINK %s
+// LINK: {{".*ld.*"}} {{.*}} {{"-L.*avr5"}} {{.*}} "-Tdata=0x800100" {{.*}} "-latmega328" "-mavr5"
Index: clang/lib/Driver/ToolChains/AVR.cpp
===================================================================
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -334,10 +334,12 @@
         // No avr-libc found and so no runtime linked.
         D.Diag(diag::warn_drv_avr_libc_not_found);
       } else { // We have enough information to link stdlibs
-        std::string GCCRoot = std::string(GCCInstallation.getInstallPath());
+        std::string GCCRoot(GCCInstallation.getInstallPath());
+        std::string GCCParentPath(GCCInstallation.getParentLibPath());
         std::string LibcRoot = AVRLibcRoot.getValue();
         std::string SubPath = GetMCUSubPath(CPU);
 
+        getProgramPaths().push_back(GCCParentPath + "/../bin");
         getFilePaths().push_back(LibcRoot + std::string("/lib/") + SubPath);
         getFilePaths().push_back(GCCRoot + std::string("/") + SubPath);
 
@@ -419,9 +421,10 @@
 
 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(PossiblePath))
-      return Optional<std::string>(std::string(PossiblePath));
+    if (llvm::sys::fs::is_directory(Path))
+      return Optional<std::string>(Path);
   }
 
   return llvm::None;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95529.320777.patch
Type: text/x-patch
Size: 1833 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210202/84088d37/attachment.bin>


More information about the cfe-commits mailing list