Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2057

shiboken2 stores compiler value at compile time

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.4.0
    • 5.15.6, 6.3.1
    • Shiboken
    • None
    • conda-forge + 5.15.6
    • Linux/X11

    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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kleint Friedemann Kleint
              mark.harfouche Mark Harfouche
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes