Skip to content

Commit bbf508a

Browse files
aykevlgerekon
authored andcommitted
[Xtensa] Fix Clang builtins include directory
This fixes #83 In short, it adjusts the include path logic to include the builtins directory as long as `-nostdinc` or `-nobuiltininc` isn't specified. Previously, the builtins directory would not be included if either the GCC installation wasn't found, or `-nostdlibinc` was specified (both of which aren't related to the builtins directory).
1 parent 8a79a6c commit bbf508a

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

clang/lib/Driver/ToolChains/Xtensa.cpp

+23-18
Original file line numberDiff line numberDiff line change
@@ -145,29 +145,34 @@ Tool *XtensaToolChain::buildAssembler() const {
145145

146146
void XtensaToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
147147
ArgStringList &CC1Args) const {
148-
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) ||
149-
DriverArgs.hasArg(options::OPT_nostdlibinc))
148+
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
150149
return;
151150

152-
if (!getDriver().SysRoot.empty()) {
153-
SmallString<128> Dir(getDriver().SysRoot);
154-
llvm::sys::path::append(Dir, "include");
155-
addSystemInclude(DriverArgs, CC1Args, Dir.str());
156-
} else if (GCCInstallation.isValid()) {
157-
SmallString<128> Path1(getDriver().ResourceDir);
158-
llvm::sys::path::append(Path1, "include");
159-
SmallString<128> Path2(GCCToolchainDir);
160-
llvm::sys::path::append(Path2, GCCToolchainName, "sys-include");
161-
SmallString<128> Path3(GCCToolchainDir);
162-
llvm::sys::path::append(Path3, GCCToolchainName, "include");
163-
164-
const StringRef Paths[] = {Path1, Path2, Path3};
165-
addSystemIncludes(DriverArgs, CC1Args, Paths);
166-
} else {
167-
SmallString<128> Dir(computeSysRoot());
151+
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
152+
SmallString<128> Dir(getDriver().ResourceDir);
168153
llvm::sys::path::append(Dir, "include");
169154
addSystemInclude(DriverArgs, CC1Args, Dir.str());
170155
}
156+
157+
if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
158+
if (!getDriver().SysRoot.empty()) {
159+
SmallString<128> Dir(getDriver().SysRoot);
160+
llvm::sys::path::append(Dir, "include");
161+
addSystemInclude(DriverArgs, CC1Args, Dir.str());
162+
} else if (GCCInstallation.isValid()) {
163+
SmallString<128> Path1(GCCToolchainDir);
164+
llvm::sys::path::append(Path1, GCCToolchainName, "sys-include");
165+
SmallString<128> Path2(GCCToolchainDir);
166+
llvm::sys::path::append(Path2, GCCToolchainName, "include");
167+
168+
const StringRef Paths[] = {Path1, Path2};
169+
addSystemIncludes(DriverArgs, CC1Args, Paths);
170+
} else {
171+
SmallString<128> Dir(computeSysRoot());
172+
llvm::sys::path::append(Dir, "include");
173+
addSystemInclude(DriverArgs, CC1Args, Dir.str());
174+
}
175+
}
171176
}
172177

173178
void XtensaToolChain::addLibStdCxxIncludePaths(

0 commit comments

Comments
 (0)