[lldb-dev] Python3 compatibility for the API

Luke Drummond via lldb-dev lldb-dev at lists.llvm.org
Tue Aug 30 05:01:05 PDT 2016

Hi Zachary, Peter

On 30/08/16 00:14, Zachary Turner via lldb-dev wrote:
> Right, the existing version that is built and what you are using links
> directly against a 2.7 libpython at compile time.  So you would probably
> need to build LLDB from source and tweak the build system to make it
> possible to link against your 3.x version of python.  There's some build
> instructions on the website <http://lldb.llvm.org/build.html>.  I know
> there's a few linux developers around here, so it's possible someone
> else would be interested in making this work as well, but I don't know
> that it's on anyone's immediate timeline.

We build lldb against python3 regularly, because - as Zachary said - 
this is the only way to get scripting support on windows. To link 
against python3 on Linux you *should* just need the correct headers 
installed, and invoke CMake with the correct python path. For Ubuntu:

sudo apt install python3-dev

*should* give you everything you need. However, you may see that cmake 
picks up the python3 interpreter correctly, but tries to link against 
the python2.7 library.

-- Found PythonInterp: /usr/bin/python3 (found version "3.5.2")
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so (found 
version "2.7.12")

This appears to be due to a problem in LLVM's CMakeLists.txt specifying 
support for 2.7 only. I have a patch to fix the issue awaiting review 
[here](https://reviews.llvm.org/D20825) which should fix the issue on 
Linux when multiple pythons are installed. It may be worth applying this 
patch locally and see how you get on.

Hope that helps



More information about the lldb-dev mailing list