[PATCH] D97669: [clang][AVR] Add avr-libc/include to clang system include paths
Ben Shi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 14 17:57:24 PDT 2021
benshi001 updated this revision to Diff 337591.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97669/new/
https://reviews.llvm.org/D97669
Files:
clang/lib/Driver/ToolChains/AVR.cpp
clang/lib/Driver/ToolChains/AVR.h
clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/include/.keep
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
@@ -2,3 +2,12 @@
// RUN: %clang %s -### -no-canonical-prefixes -target avr 2>&1 | FileCheck -check-prefix=CC1 %s
// CC1: clang{{.*}} "-cc1" "-triple" "avr"
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 | FileCheck -check-prefix CC1A %s
+// 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"}}
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdlibinc | FileCheck -check-prefix CC1C %s
+// CC1C-NOT: "-internal-isystem" {{".*avr/include"}}
Index: clang/lib/Driver/ToolChains/AVR.h
===================================================================
--- clang/lib/Driver/ToolChains/AVR.h
+++ clang/lib/Driver/ToolChains/AVR.h
@@ -22,6 +22,9 @@
public:
AVRToolChain(const Driver &D, const llvm::Triple &Triple,
const llvm::opt::ArgList &Args);
+ void
+ AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const override;
protected:
Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/AVR.cpp
===================================================================
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -353,6 +353,23 @@
}
}
+void AVRToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
+ ArgStringList &CC1Args) const {
+ if (DriverArgs.hasArg(options::OPT_nostdinc) ||
+ DriverArgs.hasArg(options::OPT_nostdlibinc))
+ return;
+
+ // Omit if there is no avr-libc installed.
+ Optional<std::string> AVRLibcRoot = findAVRLibcInstallation();
+ if (!AVRLibcRoot.hasValue())
+ return;
+
+ // Add 'avr-libc/include' to clang system include paths if applicable.
+ std::string AVRInc = AVRLibcRoot.getValue() + "/include";
+ if (llvm::sys::fs::is_directory(AVRInc))
+ addSystemInclude(DriverArgs, CC1Args, AVRInc);
+}
+
Tool *AVRToolChain::buildLinker() const {
return new tools::AVR::Linker(getTriple(), *this, LinkStdlib);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97669.337591.patch
Type: text/x-patch
Size: 2432 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210415/05cf6377/attachment.bin>
More information about the cfe-commits
mailing list