Skip to content

Commit 362de22

Browse files
authored
[lldb] Fix SWIG bug detection in CMake (#169212)
The CMake [`set()`](https://cmake.org/cmake/help/latest/command/set.html) command does not accept a conditional expression as a value. As a result, AFFECTED_BY_SWIG_BUG was being set to a string representation of the condition rather than a boolean value, causing it to always evaluate as truthy in subsequent if-checks.
1 parent e5edb51 commit 362de22

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,12 @@ if (LLDB_ENABLE_PYTHON)
182182

183183
# Enable targeting the Python Limited C API.
184184
set(PYTHON_LIMITED_API_MIN_SWIG_VERSION "4.2")
185-
set(AFFECTED_BY_SWIG_BUG SWIG_VERSION VERSION_EQUAL "4.4.0" AND Python3_VERSION VERSION_GREATER_EQUAL "3.13")
185+
if (SWIG_VERSION VERSION_EQUAL "4.4.0" AND Python3_VERSION VERSION_GREATER_EQUAL "3.13")
186+
set(AFFECTED_BY_SWIG_BUG TRUE)
187+
else()
188+
set(AFFECTED_BY_SWIG_BUG FALSE)
189+
endif()
190+
186191
if (SWIG_VERSION VERSION_GREATER_EQUAL PYTHON_LIMITED_API_MIN_SWIG_VERSION
187192
AND NOT LLDB_EMBED_PYTHON_HOME AND NOT AFFECTED_BY_SWIG_BUG)
188193
set(default_enable_python_limited_api ON)
@@ -195,7 +200,7 @@ if (LLDB_ENABLE_PYTHON)
195200

196201
# Diagnose unsupported configurations.
197202
if (LLDB_ENABLE_PYTHON_LIMITED_API AND AFFECTED_BY_SWIG_BUG)
198-
message(SEND_ERROR "LLDB_ENABLE_PYTHON_LIMITED_API is not compatible with SWIG 4.4.0 and Python 3.13 due to a bug in SWIG: https://github.com/swig/swig/issues/3283")
203+
message(SEND_ERROR "LLDB_ENABLE_PYTHON_LIMITED_API is not compatible with SWIG 4.4.0 and Python >= 3.13 due to a bug in SWIG: https://github.com/swig/swig/issues/3283")
199204
endif()
200205
if (LLDB_ENABLE_PYTHON_LIMITED_API AND LLDB_EMBED_PYTHON_HOME)
201206
message(SEND_ERROR "LLDB_ENABLE_PYTHON_LIMITED_API is not compatible with LLDB_EMBED_PYTHON_HOME")

0 commit comments

Comments
 (0)