summaryrefslogtreecommitdiffstats
path: root/lib/Driver/ToolChains
diff options
context:
space:
mode:
authorErich Keane <erich.keane@intel.com>2017-12-11 17:36:42 +0000
committerErich Keane <erich.keane@intel.com>2017-12-11 17:36:42 +0000
commit20a630420df42944fa7676747f31973bf2021783 (patch)
tree31ad66545e599117e0983a26f5b4f9d83a4e6f84 /lib/Driver/ToolChains
parentf1094b8cc1ca05380b4fad618b7dcfdb113995e8 (diff)
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 Note: this is a recommit after a test failure took down the original (r318669) Patch By: mibintc Differential Revision: https://reviews.llvm.org/D34158 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320391 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ToolChains')
-rw-r--r--lib/Driver/ToolChains/Linux.cpp12
-rw-r--r--lib/Driver/ToolChains/Linux.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp
index 1301cdf114..5c3697391d 100644
--- a/lib/Driver/ToolChains/Linux.cpp
+++ b/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/lib/Driver/ToolChains/Linux.h b/lib/Driver/ToolChains/Linux.h
index 9778c1832c..8b7e2e2ad5 100644
--- a/lib/Driver/ToolChains/Linux.h
+++ b/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,