[PATCH] D107682: [AVR][clang] Improve search for avr-libc installation path
Ben Shi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 16 20:52:29 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb31199bab486: [AVR][clang] Improve search for avr-libc installation path (authored by benshi001).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107682/new/
https://reviews.llvm.org/D107682
Files:
clang/lib/Driver/ToolChains/AVR.cpp
clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/avr/include/.keep
clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/avr/lib/libavr.a
clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/lib/gcc/avr/10.3.0/libgcc.a
clang/test/Driver/Inputs/basic_avr_tree_2/usr/avr/include/.keep
clang/test/Driver/Inputs/basic_avr_tree_2/usr/avr/lib/libavr.a
clang/test/Driver/avr-toolchain.c
Index: clang/test/Driver/avr-toolchain.c
===================================================================
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -6,12 +6,24 @@
// CHECK1-SAME: "-resource-dir" "[[RESOURCE:[^"]+]]"
// CHECK1-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree]]"
// CHECK1-SAME: "-internal-isystem"
-// CHECK1-SAME: {{^}} "[[SYSROOT]]/usr/lib/avr/include"
+// CHECK1-SAME: {{^}} "[[SYSROOT]]/usr/lib/gcc/avr/5.4.0/../../../avr/include"
// CHECK1-NOT: "-L
// CHECK1: avr-ld"
// CHECK1-SAME: "-o" "a.out"
// CHECK1-SAME: {{^}} "--gc-sections"
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree_2/opt/local -S 2>&1 | FileCheck --check-prefix=CHECK2 %s
+// CHECK2: clang{{.*}} "-cc1" "-triple" "avr"
+// CHECK2-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree_2/opt/local]]"
+// CHECK2-SAME: "-internal-isystem"
+// CHECK2-SAME: {{^}} "[[SYSROOT]]/lib/gcc/avr/10.3.0/../../../../avr/include"
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree_2 -S 2>&1 | FileCheck --check-prefix=CHECK3 %s
+// CHECK3: clang{{.*}} "-cc1" "-triple" "avr"
+// CHECK3-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree_2]]"
+// CHECK3-SAME: "-internal-isystem"
+// CHECK3-SAME: {{^}} "[[SYSROOT]]/usr/avr/include"
+
// RUN: %clang %s -### -target avr 2>&1 | FileCheck -check-prefix=CC1 %s
// CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array"
Index: clang/lib/Driver/ToolChains/AVR.cpp
===================================================================
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -453,11 +453,21 @@
}
llvm::Optional<std::string> AVRToolChain::findAVRLibcInstallation() const {
+ // Search avr-libc installation according to avr-gcc installation.
+ std::string GCCParent(GCCInstallation.getParentLibPath());
+ std::string Path(GCCParent + "/avr");
+ if (llvm::sys::fs::is_directory(Path))
+ return Path;
+ Path = GCCParent + "/../avr";
+ if (llvm::sys::fs::is_directory(Path))
+ return Path;
+
+ // Search avr-libc installation from possible locations, and return the first
+ // one that exists, if there is no avr-gcc installed.
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);
+ return Path;
}
return llvm::None;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107682.366797.patch
Type: text/x-patch
Size: 2538 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210817/c2d73d20/attachment-0001.bin>
More information about the cfe-commits
mailing list