Skip to content

Commit

Permalink
[Xtensa] Fix Clang builtins include directory
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
aykevl authored and gerekon committed Nov 3, 2023
1 parent 8a79a6c commit bbf508a
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions clang/lib/Driver/ToolChains/Xtensa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,29 +145,34 @@ Tool *XtensaToolChain::buildAssembler() const {

void XtensaToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) ||
DriverArgs.hasArg(options::OPT_nostdlibinc))
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
return;

if (!getDriver().SysRoot.empty()) {
SmallString<128> Dir(getDriver().SysRoot);
llvm::sys::path::append(Dir, "include");
addSystemInclude(DriverArgs, CC1Args, Dir.str());
} else if (GCCInstallation.isValid()) {
SmallString<128> Path1(getDriver().ResourceDir);
llvm::sys::path::append(Path1, "include");
SmallString<128> Path2(GCCToolchainDir);
llvm::sys::path::append(Path2, GCCToolchainName, "sys-include");
SmallString<128> Path3(GCCToolchainDir);
llvm::sys::path::append(Path3, GCCToolchainName, "include");

const StringRef Paths[] = {Path1, Path2, Path3};
addSystemIncludes(DriverArgs, CC1Args, Paths);
} else {
SmallString<128> Dir(computeSysRoot());
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
SmallString<128> Dir(getDriver().ResourceDir);
llvm::sys::path::append(Dir, "include");
addSystemInclude(DriverArgs, CC1Args, Dir.str());
}

if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
if (!getDriver().SysRoot.empty()) {
SmallString<128> Dir(getDriver().SysRoot);
llvm::sys::path::append(Dir, "include");
addSystemInclude(DriverArgs, CC1Args, Dir.str());
} else if (GCCInstallation.isValid()) {
SmallString<128> Path1(GCCToolchainDir);
llvm::sys::path::append(Path1, GCCToolchainName, "sys-include");
SmallString<128> Path2(GCCToolchainDir);
llvm::sys::path::append(Path2, GCCToolchainName, "include");

const StringRef Paths[] = {Path1, Path2};
addSystemIncludes(DriverArgs, CC1Args, Paths);
} else {
SmallString<128> Dir(computeSysRoot());
llvm::sys::path::append(Dir, "include");
addSystemInclude(DriverArgs, CC1Args, Dir.str());
}
}
}

void XtensaToolChain::addLibStdCxxIncludePaths(
Expand Down

0 comments on commit bbf508a

Please sign in to comment.