[Lldb-commits] [PATCH] D64812: [CMake] Fail when Python interpreter doesn't match Python libraries version

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 16 11:19:29 PDT 2019


JDevlieghere created this revision.
JDevlieghere added reviewers: sgraenitz, labath, xiaobai.
JDevlieghere added a project: LLDB.
Herald added a subscriber: mgorny.

Because of how CMake finds the Python libraries and interpreter, it's possible to end up with a discrepancy between the two. For example, you'd end up using a Python 3 interpreter to run the test suite while LLDB was build and linked against Python 2. This patch adds a CMake warning so we find out at configuration time, instead of finding out at test time, after having build LLDB.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D64812

Files:
  lldb/cmake/modules/LLDBConfig.cmake


Index: lldb/cmake/modules/LLDBConfig.cmake
===================================================================
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -185,7 +185,6 @@
 endfunction(find_python_libs_windows)
 
 if (NOT LLDB_DISABLE_PYTHON)
-
   if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
     find_python_libs_windows()
 
@@ -194,8 +193,12 @@
       add_definitions( -DLLDB_PYTHON_HOME="${LLDB_PYTHON_HOME}" )
     endif()
   else()
-    find_package(PythonInterp)
-    find_package(PythonLibs)
+    find_package(PythonInterp REQUIRED)
+    find_package(PythonLibs REQUIRED)
+  endif()
+
+  if (NOT PYTHON_VERSION_STRING VERSION_EQUAL PYTHONLIBS_VERSION_STRING)
+    message(FATAL_ERROR "Found incompatible Python interpreter (${PYTHON_VERSION_STRING}) and Python libraries (${PYTHONLIBS_VERSION_STRING})")
   endif()
 
   if (PYTHON_INCLUDE_DIR)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64812.210140.patch
Type: text/x-patch
Size: 893 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190716/6695eec5/attachment.bin>


More information about the lldb-commits mailing list