aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2017-07-21 17:55:10 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2017-07-24 07:51:07 +0000
commit2f67e07e7a89cb814c9a764ef99a1cda1df5874c (patch)
tree691787b61cf6f9f68b6a917d058d93dbf1094e57
parentfb7b201893ccc8333a9e1b8ed536faa5e3446276 (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>
m---------sources/pyside2-examples0
-rw-r--r--sources/shiboken2/ApiExtractor/CMakeLists.txt7
-rw-r--r--sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp16
-rw-r--r--sources/shiboken2/CMakeLists.txt21
4 files changed, 42 insertions, 2 deletions
diff --git a/sources/pyside2-examples b/sources/pyside2-examples
-Subproject 8df6dccecc5165f7c3ec5896c9be8baceda7161
+Subproject 48780ead33fd1cfbbc7754356444421e159fa15
diff --git a/sources/shiboken2/ApiExtractor/CMakeLists.txt b/sources/shiboken2/ApiExtractor/CMakeLists.txt
index 2b966aa56..f2af51c02 100644
--- a/sources/shiboken2/ApiExtractor/CMakeLists.txt
+++ b/sources/shiboken2/ApiExtractor/CMakeLists.txt
@@ -27,6 +27,13 @@ add_definitions(-DQT_PLUGIN)
add_definitions(-DQT_SHARED)
add_definitions(-DRXX_ALLOCATOR_INIT_0)
+# Pass the path to the clang includes dir, so it headers like stdarg.h.
+if(UNIX AND NOT APPLE)
+ add_definitions(-DCLANG_BUILTIN_INCLUDES_DIR="${CLANG_BUILTIN_INCLUDES_DIR}")
+else()
+ add_definitions(-DCLANG_BUILTIN_INCLUDES_DIR="")
+endif()
+
set(apiextractor_SRC
apiextractor.cpp
abstractmetabuilder.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
diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt
index 0ca3c2f8f..0d58bcd64 100644
--- a/sources/shiboken2/CMakeLists.txt
+++ b/sources/shiboken2/CMakeLists.txt
@@ -65,6 +65,27 @@ endif()
message(STATUS "CLANG: ${CLANG_DIR}, ${CLANG_LIBRARY} detected by ${CLANG_DIR_SOURCE}")
+# Find highest version clang builtin includes folder to pass along to shiboken.
+set(CLANG_BUILTIN_INCLUDES_DIR_PREFIX ${CLANG_DIR}/lib/clang)
+file(GLOB CLANG_BUILTIN_INCLUDES_DIR_VERSIONS "${CLANG_BUILTIN_INCLUDES_DIR_PREFIX}/*")
+
+# Sort in alphabetical order the list of version folders.
+list(SORT CLANG_BUILTIN_INCLUDES_DIR_VERSIONS)
+
+# Reverse it so the first element is the highest version.
+list(REVERSE CLANG_BUILTIN_INCLUDES_DIR_VERSIONS)
+
+message(STATUS "Found the following CLANG builtins includes directories: ${CLANG_BUILTIN_INCLUDES_DIR_VERSIONS}")
+if(CLANG_BUILTIN_INCLUDES_DIR_VERSIONS)
+ # Get highest version.
+ list(GET CLANG_BUILTIN_INCLUDES_DIR_VERSIONS 0 CLANG_BUILTIN_INCLUDES_DIR_HIGHEST_VERSION)
+ if (CLANG_BUILTIN_INCLUDES_DIR_HIGHEST_VERSION)
+ # Set the final variable to the full include path to pass along to shiboken.
+ set(CLANG_BUILTIN_INCLUDES_DIR "${CLANG_BUILTIN_INCLUDES_DIR_HIGHEST_VERSION}/include")
+ endif()
+endif()
+message(STATUS "CLANG builtins includes directory chosen: ${CLANG_BUILTIN_INCLUDES_DIR}")
+
set(CLANG_EXTRA_INCLUDES ${CLANG_DIR}/include)
set(CLANG_EXTRA_LIBRARIES ${CLANG_LIBRARY})