diff options
author | Brad King <brad.king@kitware.com> | 2015-02-04 14:59:29 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-02-04 14:59:29 (GMT) |
commit | 8d8aacd65af229da0cadf81911ffa3ef77db7b57 (patch) | |
tree | 7a85fbe387dae1fb9667176fe6ce350df28e09f0 /src | |
parent | 1074cb11ebdc29bff2fc7eb633252348e0758106 (diff) | |
download | CastXML-8d8aacd65af229da0cadf81911ffa3ef77db7b57.zip CastXML-8d8aacd65af229da0cadf81911ffa3ef77db7b57.tar.gz CastXML-8d8aacd65af229da0cadf81911ffa3ef77db7b57.tar.bz2 |
Detect: Use Clang builtin include dir even with --castxml-cc-<id>
We need implementation-provided headers to come from Clang to match what
is really built in to the parser. When not using --castxml-cc-<id>, the
Clang driver adds its builtin include directory in methods like
Linux::AddClangSystemIncludeArgs
MSVCToolChain::AddClangSystemIncludeArgs
CrossWindowsToolChain::AddClangSystemIncludeArgs
(see lib/Driver/*ToolChain*.cpp). When using --castxml-cc-<id>, we must
add the Clang builtin include dir in the appropriate place.
GNU-like compilers should have a builtin include directory too,
providing files like <emmintrin.h>. The Clang driver does not add this
directory from GCC toolchains and instead adds its own builtin include
directory. In this case, replace the detected compiler builtin include
directory with ours.
MSVC-like compilers have no separate builtin include directory. The
Clang driver simply places its own builtin include direcory before the
system include directory read from the INCLUDE environment variable. In
this case, do the same.
Diffstat (limited to 'src')
-rw-r--r-- | src/Detect.cxx | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Detect.cxx b/src/Detect.cxx index 7e7cfc4..4db82f9 100644 --- a/src/Detect.cxx +++ b/src/Detect.cxx @@ -24,6 +24,12 @@ #include <string.h> //---------------------------------------------------------------------------- +static std::string getClangBuiltinIncludeDir() +{ + return getClangResourceDir() + "/include"; +} + +//---------------------------------------------------------------------------- static bool failedCC(const char* id, std::vector<const char*> const& args, std::string const& out, @@ -118,6 +124,10 @@ static bool detectCC_GNU(const char* const* argBeg, (inc.substr(inc.size()-fwImplicitSuffix.size()) == fwImplicitSuffix)); } + // Replace the compiler builtin include directory with ours. + if(!fw && cxsys::SystemTools::FileExists((inc+"/emmintrin.h"))) { + inc = getClangBuiltinIncludeDir(); + } opts.Includes.push_back(Options::Include(inc, fw)); } } @@ -149,6 +159,8 @@ static bool detectCC_MSVC(const char* const* argBeg, if(const char* predefs = strstr(out.c_str(), "\n#define")) { opts.Predefines = predefs+1; } + // Prepend the Clang compiler builtin include directory. + opts.Includes.push_back(getClangBuiltinIncludeDir()); if(const char* includes_str = cxsys::SystemTools::GetEnv("INCLUDE")) { std::vector<std::string> includes; cxsys::SystemTools::Split(includes_str, includes, ';'); |