summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver
diff options
context:
space:
mode:
authorErich Keane <erich.keane@intel.com>2017-11-20 17:57:42 +0000
committerErich Keane <erich.keane@intel.com>2017-11-20 17:57:42 +0000
commit5c086c7626fab2617c0178a3951378bcbce2271c (patch)
treee073f8fc692b20d4dfcd8aead20817d8bf883db1 /clang/lib/Driver
parent991447d6f892f4763347528290093c10806ece74 (diff)
downloadbcm5719-llvm-5c086c7626fab2617c0178a3951378bcbce2271c.tar.gz
bcm5719-llvm-5c086c7626fab2617c0178a3951378bcbce2271c.zip
For Linux/gnu compatibility, preinclude <stdc-predef.h> if the file is available
As reported in llvm bugzilla 32377. Here’s a patch to add preinclude of stdc-predef.h. The gcc documentation says “On GNU/Linux, <stdc-predef.h> is pre-included.” See https://gcc.gnu.org/gcc-4.8/porting_to.html; The preinclude is inhibited with –ffreestanding. Basically I fixed the failing test cases by adding –ffreestanding which inhibits this behavior. I fixed all the failing tests, including some in extra/test, there's a separate patch for that which is linked here Patch By: mibintc Differential Revision: https://reviews.llvm.org/D34158 llvm-svn: 318669
Diffstat (limited to 'clang/lib/Driver')
-rw-r--r--clang/lib/Driver/Job.cpp2
-rw-r--r--clang/lib/Driver/ToolChains/Linux.cpp13
-rw-r--r--clang/lib/Driver/ToolChains/Linux.h2
3 files changed, 16 insertions, 1 deletions
diff --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp
index 765c05752d8..b494bc75282 100644
--- a/clang/lib/Driver/Job.cpp
+++ b/clang/lib/Driver/Job.cpp
@@ -64,7 +64,7 @@ static bool skipArgs(const char *Flag, bool HaveCrashVFS, int &SkipNum,
.Cases("-internal-externc-isystem", "-iprefix", true)
.Cases("-iwithprefixbefore", "-isystem", "-iquote", true)
.Cases("-isysroot", "-I", "-F", "-resource-dir", true)
- .Cases("-iframework", "-include-pch", true)
+ .Cases("-iframework", "-include-pch", "-fsystem-include-if-exists", true)
.Default(false);
if (IsInclude)
return HaveCrashVFS ? false : true;
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index ca042f38db8..5ae250759b1 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,17 @@ 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