LLDB doesn't compile on OS X

Hello guys !

I was not able to compile the python lldb support because of scripts/finishSwigWrapperClasses.py.

I found the problem it’s because the --buildConfig parameter was empty. And since the commit below, this parameter is mandatory :

git show b84a8a0216a8ee3e2b6c7e963de5bc2c78ece61d
commit b84a8a0216a8ee3e2b6c7e963de5bc2c78ece61d
Author: Zachary Turner <zturner@google.com>

Create an _d suffixed symlink when doing a debug Windows build.

_lldb is built as an extension module on Windows. Normally to load
an extension module named ‘foo’, Python would look for the file
‘foo.pyd’. However, when a debug interpreter is used, Python will
look for the file ‘foo_d.pyd’. This change checks the build
configuration and creates the correct symlink name based on the
build configuration.

I found a workaround at the moment but this not sustainable because I think this parameter was introduced for good reasons :

ff --git a/scripts/finishSwigWrapperClasses.py b/scripts/finishSwigWrapperClasses.py
index 0fe7dec…3fddecf 100644
— a/scripts/finishSwigWrapperClasses.py
+++ b/scripts/finishSwigWrapperClasses.py
@@ -172,7 +172,7 @@ def validate_arguments( vArgv ):
“–srcRoot”: “m”,
“–targetDir”: “m”,
“–cfgBldDir”: “o”,

  • “–buildConfig”: “m”,
  • “–buildConfig”: “o”,
    “–prefix”: “o”,
    “–cmakeBuildConfiguration”: “o”,
    “–argsFile”: “o” };
    diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
    index b4421fc…048dc5a 100644
    — a/source/CMakeLists.txt
    +++ b/source/CMakeLists.txt
    @@ -176,7 +176,7 @@ if ( LLDB_ENABLE_PYTHON_SCRIPTS_SWIG_API_GENERATION )
    add_custom_command( TARGET liblldb
    POST_BUILD
    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/…/scripts/finishSwigWrapperClasses.py
  • COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/…/scripts/finishSwigWrapperClasses.py --buildConfig=${CMAKE_BUILD_TYPE} “–srcRoot=${LLDB_SOURCE_DIR}” “–targetDir=${CMAKE_CURRENT_BINARY_DIR}/…/scripts” “–cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}/…/scripts” “–prefix=${CMAKE_BINARY_DIR}” “–cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}” -m
  • COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/…/scripts/finishSwigWrapperClasses.py “–srcRoot=${LLDB_SOURCE_DIR}” “–targetDir=${CMAKE_CURRENT_BINARY_DIR}/…/scripts” “–cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}/…/scripts” “–prefix=${CMAKE_BINARY_DIR}” “–cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}” -m
    COMMENT “Python script sym-linking LLDB Python API”)
    endif ()
    endif ()

We should understand why with OS X CMakefile this parameter is empty.

Regards

I’m not a cmake expert, but what is the correct way of detecting debug vs. release, even if the user has not specified CMAKE_BUILD_TYPE explicitly?

I looked into this a little. This argument is used for exactly one reason. To figure out whether to put _d on the end of the extension module name. One question: when you do a debug build of LLDB on MacOSX, does it still use a release version of python? I think the answer is yes, and if so this code was already broken anyway because it should not depend on the value of CMAKE_BUILD_TYPE.

Somehow we need to determine which version of Python we’re linking against. And use that to pass into this script. I suspect it’s something like this:

if (os is windows)
pythonver = (CMAKE_BUILD_TYPE==“Debug” || defined(_DEBUG) ? “Debug” : “Release”
else()
pythonver = “Release”
endif()

Anyone?