diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2017-07-21 17:55:10 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2017-07-24 07:51:07 +0000 |
commit | 2f67e07e7a89cb814c9a764ef99a1cda1df5874c (patch) | |
tree | 691787b61cf6f9f68b6a917d058d93dbf1094e57 /sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp | |
parent | fb7b201893ccc8333a9e1b8ed536faa5e3446276 (diff) |
Fix building on openSuSE and Ubuntu 16.04 CI machines
Previously all the GCC header paths were explicitly passed to
libclang, which caused redefinition errors of builtin functions or
intrisics (like __rdtsc). Instead of passing the include paths
explicitly, we rely on libclang itself recognizing that there are
GCC paths in the default search locations.
Also we need to pass the libclang builtin headers location, because
it is not able to find them by itself. Usually the search location
for these headers is to get the executable path location (aka
the clang++ binary) and navigate to ../lib/clang/VERSION/include
relative to that binary. But because the shared library is used
instead of the binary, we need to explicitly pass that header
location via the -isystem flag.
Task-number: PYSIDE-513
Change-Id: I7c1127d85c0cea4c063c5c2a3548a1eef5eadaf3
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp index df82f9080..d2e64458b 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp @@ -127,7 +127,9 @@ static HeaderPaths gppInternalIncludePaths(const QString &compiler) // which causes std types not being found and construct -I/-F options from the // include paths of the host compiler. +#ifdef Q_CC_CLANG static QByteArray noStandardIncludeOption() { return QByteArrayLiteral("-nostdinc"); } +#endif // Returns clang options needed for emulating the host compiler QByteArrayList emulatedCompilerOptions() @@ -140,8 +142,18 @@ QByteArrayList emulatedCompilerOptions() const HeaderPaths headerPaths = gppInternalIncludePaths(QStringLiteral("clang++")); result.append(noStandardIncludeOption()); #elif defined(Q_CC_GNU) - const HeaderPaths headerPaths = gppInternalIncludePaths(QStringLiteral("g++")); - result.append(noStandardIncludeOption()); + const HeaderPaths headerPaths; + + // The clang builtin includes directory is used to find the definitions for intrinsic functions + // and builtin types. It is necessary to use the clang includes to prevent redefinition errors. + // The default toolchain includes should be picked up automatically by clang without specifying + // them implicitly. + QByteArray clangBuiltinIncludesDir(CLANG_BUILTIN_INCLUDES_DIR); + + if (!clangBuiltinIncludesDir.isEmpty()) { + result.append(QByteArrayLiteral("-isystem")); + result.append(clangBuiltinIncludesDir); + } #else const HeaderPaths headerPaths; #endif |