[PATCH] D107682: [AVR][clang] Improve search for avr-libc installation path
Ben Shi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 7 05:15:29 PDT 2021
benshi001 updated this revision to Diff 364954.
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/avr-toolchain.c
Index: clang/test/Driver/avr-toolchain.c
===================================================================
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -4,7 +4,7 @@
// CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array"
// RUN: %clang %s -### -no-canonical-prefixes -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 | FileCheck -check-prefix CC1A %s
-// CC1A: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-internal-isystem" {{".*avr/include"}}
+// CC1A: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-internal-isystem" {{".*../../../avr/include"}}
// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdinc | FileCheck -check-prefix CC1B %s
// CC1B-NOT: "-internal-isystem" {{".*avr/include"}}
Index: clang/lib/Driver/ToolChains/AVR.cpp
===================================================================
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -453,9 +453,19 @@
}
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 Optional<std::string>(Path);
+ Path = GCCParent + "/../avr/";
+ if (llvm::sys::fs::is_directory(Path))
+ return Optional<std::string>(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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107682.364954.patch
Type: text/x-patch
Size: 1865 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210807/9470809d/attachment-0001.bin>
More information about the cfe-commits
mailing list