From 2f67e07e7a89cb814c9a764ef99a1cda1df5874c Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 21 Jul 2017 17:55:10 +0200 Subject: 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 --- .../ApiExtractor/clangparser/compilersupport.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp') 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 -- cgit v1.2.3