Details
Description
in compilersupport.cpp, the code
static QString compilerFromCMake(const QString &defaultCompiler) { // Added !defined(Q_OS_DARWIN) due to PYSIDE-1032 QString result = defaultCompiler; if (platform() != Platform::macOS) #ifdef CMAKE_CXX_COMPILER result = QString::fromLocal8Bit(CMAKE_CXX_COMPILER); #endif return result; }
stores the CXX compiler at compile time. This isn't really ideal when users want to use shiboken to cross compile on linux.
At conda-forge, we use cross compilation to speed up builds for aarch64.
I'm using the the following patch on 5.15.6 (would need a bit of modification for 6.3.1) to ensure that the compiler can be overridden at run time.
diff -ur a_pyside-setup-opensource-src-5.15.6/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp b_pyside-setup-opensource-src-5.15.6/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp --- a_pyside-setup-opensource-src-5.15.6/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp 2022-09-11 15:46:58.536291467 -0400 +++ b_pyside-setup-opensource-src-5.15.6/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp 2022-09-11 15:47:31.303995179 -0400 @@ -293,13 +293,7 @@ #if defined(Q_CC_CLANG) || defined(Q_CC_GNU) static QString compilerFromCMake(const QString &defaultCompiler) { -// Added !defined(Q_OS_DARWIN) due to PYSIDE-1032 -# if defined(CMAKE_CXX_COMPILER) && !defined(Q_OS_DARWIN) - Q_UNUSED(defaultCompiler) - return QString::fromLocal8Bit(CMAKE_CXX_COMPILER); -# else - return defaultCompiler; -# endif + return qEnvironmentVariable("CXX", defaultCompiler); } #endif // Q_CC_CLANG, Q_CC_GNU
You can adjust the logic as you wish, maybe what you want is
#if defined(Q_CC_CLANG) || defined(Q_CC_GNU) static QString compilerFromCMake(const QString &defaultCompiler) { return qEnvironmentVariable( "CMAKE_CXX_COMPILER", qEnvironmentVariable( "CXX", defaultCompiler) ); } #endif // Q_CC_CLANG, Q_CC_GNU
but generally, I don't think you want this to be stored in the generated binary.
Attachments
Issue Links
- relates to
-
PYSIDE-802 Enable PySide/Shiboken cross compilation for different targets.
- Closed
-
PYSIDE-1812 Allow specifying target sysroot for header extraction when cross-compiling
- Open