summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/ToolChains
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Driver/ToolChains')
-rw-r--r--clang/lib/Driver/ToolChains/Linux.cpp12
-rw-r--r--clang/lib/Driver/ToolChains/Linux.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index 1301cdf114a..5c3697391d5 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -710,6 +710,8 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
+
+ AddGnuIncludeArgs(DriverArgs, CC1Args);
}
static std::string DetectLibcxxIncludePath(StringRef base) {
@@ -748,6 +750,16 @@ std::string Linux::findLibCxxIncludePath() const {
return "";
}
+void Linux::AddGnuIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const {
+ if (!DriverArgs.hasArg(options::OPT_ffreestanding)) {
+ // For gcc compatibility, clang will preinclude <stdc-predef.h>
+ // -ffreestanding suppresses this behavior.
+ CC1Args.push_back("-fsystem-include-if-exists");
+ CC1Args.push_back("stdc-predef.h");
+ }
+}
+
void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const {
// We need a detected GCC installation on Linux to provide libstdc++'s
diff --git a/clang/lib/Driver/ToolChains/Linux.h b/clang/lib/Driver/ToolChains/Linux.h
index 9778c1832cc..8b7e2e2ad53 100644
--- a/clang/lib/Driver/ToolChains/Linux.h
+++ b/clang/lib/Driver/ToolChains/Linux.h
@@ -31,6 +31,8 @@ public:
void addLibStdCxxIncludePaths(
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
+ void AddGnuIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const;
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
OpenPOWER on IntegriCloud