[clang][AVR] Add avr-libc/include to clang system include paths
Reviewed By: dylanmckay Differential Revision: https://reviews.llvm.org/D97669
This commit is contained in:
@@ -353,6 +353,23 @@ AVRToolChain::AVRToolChain(const Driver &D, const llvm::Triple &Triple,
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ class LLVM_LIBRARY_VISIBILITY AVRToolChain : public Generic_ELF {
|
||||
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;
|
||||
|
||||
@@ -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"}}
|
||||
|
||||
Reference in New Issue
Block a user