Skip to content

Commit 459a64b

Browse files
authored
[lldb] Diagnose unsupported configurations when targeting the Limited C API (#168145)
Diagnose unsupported configurations when targeting the Python Limited C API. I used SEND_ERROR so that if there's multiple issues, you don't need to keep reconfiguring.
1 parent ddf5bb0 commit 459a64b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,25 @@ if (LLDB_ENABLE_PYTHON)
180180
"Path to use as PYTHONHOME in lldb. If a relative path is specified, it will be resolved at runtime relative to liblldb directory.")
181181
endif()
182182

183-
if (SWIG_VERSION VERSION_GREATER_EQUAL "4.2" AND NOT LLDB_EMBED_PYTHON_HOME)
183+
# Enable targeting the Python Limited C API.
184+
set(PYTHON_LIMITED_API_MIN_SWIG_VERSION "4.2")
185+
if (SWIG_VERSION VERSION_GREATER_EQUAL PYTHON_LIMITED_API_MIN_SWIG_VERSION
186+
AND NOT LLDB_EMBED_PYTHON_HOME)
184187
set(default_enable_python_limited_api ON)
185188
else()
186189
set(default_enable_python_limited_api OFF)
187190
endif()
188191
option(LLDB_ENABLE_PYTHON_LIMITED_API "Force LLDB to only use the Python Limited API (requires SWIG 4.2 or later)"
189192
${default_enable_python_limited_api})
193+
194+
# Diagnose unsupported configurations.
195+
if (LLDB_ENABLE_PYTHON_LIMITED_API AND LLDB_EMBED_PYTHON_HOME)
196+
message(SEND_ERROR "LLDB_ENABLE_PYTHON_LIMITED_API is not compatible with LLDB_EMBED_PYTHON_HOME")
197+
endif()
198+
if (LLDB_ENABLE_PYTHON_LIMITED_API AND SWIG_VERSION VERSION_LESS PYTHON_LIMITED_API_MIN_SWIG_VERSION)
199+
message(SEND_ERROR "LLDB_ENABLE_PYTHON_LIMITED_API is not compatible with SWIG ${SWIG_VERSION} (requires SWIG ${PYTHON_LIMITED_API_MIN_SWIG_VERSION})")
200+
endif()
201+
190202
else()
191203
# Even if Python scripting is disabled, we still need a Python interpreter to
192204
# build, for example to generate SBLanguages.h.

0 commit comments

Comments
 (0)