[clang] 9b0b435 - [AVR][clang] Fix a bug in AVR toolchain search paths
Ben Shi via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 2 06:46:04 PST 2021
Author: Ben Shi
Date: 2021-02-02T22:45:52+08:00
New Revision: 9b0b435d7931bdb1fb128861cc9063a365a9e648
URL: https://github.com/llvm/llvm-project/commit/9b0b435d7931bdb1fb128861cc9063a365a9e648
DIFF: https://github.com/llvm/llvm-project/commit/9b0b435d7931bdb1fb128861cc9063a365a9e648.diff
LOG: [AVR][clang] Fix a bug in AVR toolchain search paths
Reviewed By: dylanmckay, MaskRay
Differential Revision: https://reviews.llvm.org/D95529
Added:
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
Modified:
clang/lib/Driver/ToolChains/AVR.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/AVR.cpp b/clang/lib/Driver/ToolChains/AVR.cpp
index ae56b7b5249e..ebbc6f2d5c79 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -334,10 +334,12 @@ AVRToolChain::AVRToolChain(const Driver &D, const llvm::Triple &Triple,
// 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 @@ void AVR::Linker::ConstructJob(Compilation &C, const JobAction &JA,
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;
diff --git a/clang/test/Driver/Inputs/basic_avr_tree/usr/bin/avr-ld b/clang/test/Driver/Inputs/basic_avr_tree/usr/bin/avr-ld
new file mode 100755
index 000000000000..e69de29bb2d1
diff --git a/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/libavr.a b/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/libavr.a
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/gcc/avr/5.4.0/libgcc.a b/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/gcc/avr/5.4.0/libgcc.a
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/clang/test/Driver/avr-ld.c b/clang/test/Driver/avr-ld.c
new file mode 100644
index 000000000000..5a37f5a93eb2
--- /dev/null
+++ b/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"
More information about the cfe-commits
mailing list