aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
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})