diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2022-10-31 18:03:22 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-11-02 14:10:12 +0000 |
commit | 8ac3993024937f51115f9742c76b116931274b11 (patch) | |
tree | 9185ede10c15f3cef06f86db861cc64a6506bfb0 | |
parent | 829d786b123dd687fba8d4e27e260835a0c16a33 (diff) |
CMake: Fix windows limited api build to work by default
Previously if one tried to build Qt For Python on Windows without
explicitly specifying --limited-api=yes, the build would fail with
LINK : fatal error LNK1104: cannot open file 'python3.lib'
when linking libpyside.
This happened due to a combination of reasons
- limited api defaulted to ON when configuring shiboken due to
option(FORCE_LIMITED_API "Enable the limited API." "yes")
in ShibokenSetup.cmake
- DPy_LIMITED_API=0x03060000 was recorded as a compile definition to
be propagated to any target consuming libshiboken
- limited api defaulted to OFF when configuring pyside because there
is no option(FORCE_LIMITED_API) in the pyside project, and we also
saved the previously computed value under a different name
(SHIBOKEN_PYTHON_LIMITED_API)
- libpyside was compiled with -DPy_LIMITED_API=0x03060000 but we never
explicitly linked to python3.lib, only python310.lib.
- the following pragma macro in pyconfig.h is transitively included
when building every pyside object file:
#elif defined(Py_LIMITED_API)
#pragma comment(lib,"python3.lib")
which instructed the MSVC linker to try and find python3.lib, but
it can never be found because we specify python310.lib on the link
line
This is a fairly recent breakage due to the merging of
9adf4809460737576430c5d250288db628f18f0e.
Before the mentioned change, FORCE_LIMITED_API would have the value
ON, but the check was done against the string value "yes", which would
always be false, and the build would link to the non-limited api
libraries for both shiboken and pyside.
So it would choose the wrong libraries for both projects, but the
build would not fail, it would simply not be portable across python
interpreters (probably).
In the CI this issue never happened, because we explicitly pass
--limited-api=yes to setup.py, which force overrides FORCE_LIMITED_API
to ON when building both shiboken and pyside.
To fix this, make sure we also check the value of
SHIBOKEN_PYTHON_LIMITED_API when building pyside, which is the
recorded option value exported as part of the shiboken build.
Amends 97df448edbc035a2f531508a5cfe5739fb2de18d
Amends 9adf4809460737576430c5d250288db628f18f0e
Task-number: PYSIDE-2091
Change-Id: I3771bc6b01cc0a65a920beebbd81f3b8d9aaf48a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 9cdf159ad131922772dd08ac38189993fc94ef7a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | sources/shiboken6/cmake/ShibokenHelpers.cmake | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sources/shiboken6/cmake/ShibokenHelpers.cmake b/sources/shiboken6/cmake/ShibokenHelpers.cmake index 387568726..a0d8d3c7f 100644 --- a/sources/shiboken6/cmake/ShibokenHelpers.cmake +++ b/sources/shiboken6/cmake/ShibokenHelpers.cmake @@ -256,7 +256,7 @@ macro(shiboken_check_if_limited_api) OUTPUT_STRIP_TRAILING_WHITESPACE) endif() - if(FORCE_LIMITED_API) + if(FORCE_LIMITED_API OR SHIBOKEN_PYTHON_LIMITED_API) set(PYTHON_LIMITED_API 1) if(WIN32) set(SHIBOKEN_PYTHON_LIBRARIES ${PYTHON_LIMITED_LIBRARIES}) |