Skip to content

Upstream python changes #1883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lldb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ endif()

if (LLDB_ENABLE_PYTHON)
execute_process(
COMMAND ${PYTHON_EXECUTABLE}
COMMAND ${Python3_EXECUTABLE}
-c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(True, False, ''))"
OUTPUT_VARIABLE LLDB_PYTHON_DEFAULT_RELATIVE_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE)
Expand Down
2 changes: 1 addition & 1 deletion lldb/bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function(create_python_package swig_target working_dir pkg_dir)
set(copy_cmd COMMAND ${CMAKE_COMMAND} -E copy ${ARG_FILES} ${pkg_dir})
endif()
if(NOT ARG_NOINIT)
set(init_cmd COMMAND ${PYTHON_EXECUTABLE}
set(init_cmd COMMAND ${Python3_EXECUTABLE}
"${LLDB_SOURCE_DIR}/bindings/python/createPythonInit.py"
"${pkg_dir}" ${ARG_FILES})
endif()
Expand Down
57 changes: 57 additions & 0 deletions lldb/cmake/modules/FindPythonAndSwig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#.rst:
# FindPythonAndSwig
# -----------
#
# Find the python interpreter and libraries as a whole.

macro(FindPython3)
# Use PYTHON_HOME as a hint to find Python 3.
set(Python3_ROOT_DIR "${PYTHON_HOME}")
find_package(Python3 COMPONENTS Interpreter Development)
if(Python3_FOUND AND Python3_Interpreter_FOUND)

# The install name for the Python 3 framework in Xcode is relative to
# the framework's location and not the dylib itself.
#
# @rpath/Python3.framework/Versions/3.x/Python3
#
# This means that we need to compute the path to the Python3.framework
# and use that as the RPATH instead of the usual dylib's directory.
#
# The check below shouldn't match Homebrew's Python framework as it is
# called Python.framework instead of Python3.framework.
if (APPLE AND Python3_LIBRARIES MATCHES "Python3.framework")
string(FIND "${Python3_LIBRARIES}" "Python3.framework" python_framework_pos)
string(SUBSTRING "${Python3_LIBRARIES}" "0" ${python_framework_pos} Python3_RPATH)
endif()

set(PYTHON3_FOUND TRUE)
mark_as_advanced(
Python3_LIBRARIES
Python3_INCLUDE_DIRS
Python3_EXECUTABLE
Python3_RPATH
SWIG_EXECUTABLE)
endif()
endmacro()

if(Python3_LIBRARIES AND Python3_INCLUDE_DIRS AND Python3_EXECUTABLE AND SWIG_EXECUTABLE)
set(PYTHONANDSWIG_FOUND TRUE)
else()
find_package(SWIG 2.0)
if (SWIG_FOUND)
FindPython3()
else()
message(STATUS "SWIG 2 or later is required for Python support in LLDB but could not be found")
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PythonAndSwig
FOUND_VAR
PYTHONANDSWIG_FOUND
REQUIRED_VARS
Python3_LIBRARIES
Python3_INCLUDE_DIRS
Python3_EXECUTABLE
SWIG_EXECUTABLE)
endif()
113 changes: 0 additions & 113 deletions lldb/cmake/modules/FindPythonInterpAndLibs.cmake

This file was deleted.

11 changes: 3 additions & 8 deletions lldb/cmake/modules/LLDBConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support in LLDB" Li
add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" CursesAndPanel CURSESANDPANEL_FOUND)
add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in LLDB" LibLZMA LIBLZMA_FOUND)
add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" LuaAndSwig LUAANDSWIG_FOUND)
add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonAndSwig PYTHONANDSWIG_FOUND)
add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml2 LIBXML2_FOUND VERSION 2.8)

option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install a copy of it" OFF)
Expand All @@ -79,11 +79,6 @@ if(LLDB_BUILD_FRAMEWORK)
if(NOT APPLE)
message(FATAL_ERROR "LLDB.framework can only be generated when targeting Apple platforms")
endif()
# CMake 3.6 did not correctly emit POST_BUILD commands for Apple Framework targets
# CMake < 3.8 did not have the BUILD_RPATH target property
if(CMAKE_VERSION VERSION_LESS 3.8)
message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.8")
endif()

set(LLDB_FRAMEWORK_VERSION A CACHE STRING "LLDB.framework version (default is A)")
set(LLDB_FRAMEWORK_BUILD_DIR bin CACHE STRING "Output directory for LLDB.framework")
Expand Down Expand Up @@ -148,9 +143,9 @@ if (LLDB_ENABLE_PYTHON)
"Embed PYTHONHOME in the binary. If set to OFF, PYTHONHOME environment variable will be used to to locate Python."
${default_embed_python_home})

include_directories(${PYTHON_INCLUDE_DIRS})
include_directories(${Python3_INCLUDE_DIRS})
if (LLDB_EMBED_PYTHON_HOME)
get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY)
get_filename_component(PYTHON_HOME "${Python3_EXECUTABLE}" DIRECTORY)
set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
"Path to use as PYTHONHOME in lldb. If a relative path is specified, it will be resolved at runtime relative to liblldb directory.")
endif()
Expand Down
10 changes: 5 additions & 5 deletions lldb/source/API/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ if(LLDB_ENABLE_PYTHON AND (BUILD_SHARED_LIBS OR LLVM_LINK_LLVM_DYLIB) AND UNIX A
set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "\$ORIGIN/../../../../lib${LLVM_LIBDIR_SUFFIX}")
endif()

if(PYTHON_RPATH)
set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "${PYTHON_RPATH}")
set_property(TARGET liblldb APPEND PROPERTY BUILD_RPATH "${PYTHON_RPATH}")
if(Python3_RPATH)
set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "${Python3_RPATH}")
set_property(TARGET liblldb APPEND PROPERTY BUILD_RPATH "${Python3_RPATH}")
endif()

if (MSVC)
Expand Down Expand Up @@ -187,9 +187,9 @@ endif()

if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
# Only MSVC has the ABI compatibility problem and avoids using FindPythonLibs,
# so only it needs to explicitly link against ${PYTHON_LIBRARIES}
# so only it needs to explicitly link against ${Python3_LIBRARIES}
if (MSVC AND LLDB_ENABLE_PYTHON)
target_link_libraries(liblldb PRIVATE ${PYTHON_LIBRARIES})
target_link_libraries(liblldb PRIVATE ${Python3_LIBRARIES})
endif()
else()
set_target_properties(liblldb
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/ObjectFile/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ add_subdirectory(ELF)
add_subdirectory(Mach-O)
add_subdirectory(PECOFF)
add_subdirectory(JIT)
add_subdirectory(wasm)
add_subdirectory(wasm)
2 changes: 1 addition & 1 deletion lldb/source/Plugins/ScriptInterpreter/None/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ add_lldb_library(lldbPluginScriptInterpreterNone PLUGIN
LINK_LIBS
lldbCore
lldbInterpreter
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
lldbHost
lldbInterpreter
lldbTarget
${PYTHON_LIBRARIES}
${Python3_LIBRARIES}
${LLDB_LIBEDIT_LIBS}

LINK_COMPONENTS
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/API/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function(add_python_test_target name test_script args comment)
set(PYTHON_TEST_COMMAND
${PYTHON_EXECUTABLE}
${Python3_EXECUTABLE}
${test_script}
${args}
)
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/API/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
config.target_triple = "@TARGET_TRIPLE@"
config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
config.lldb_reproducer_directory = os.path.join("@LLDB_TEST_BUILD_DIRECTORY@", "reproducers")
config.python_executable = "@PYTHON_EXECUTABLE@"
config.python_executable = "@Python3_EXECUTABLE@"
config.dotest_path = "@LLDB_SOURCE_DIR@/test/API/dotest.py"
config.dotest_args_str = "@LLDB_DOTEST_ARGS@"
config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ if(LLDB_BUILT_STANDALONE)
if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit)
# LLVM's make_paths_relative uses Python3_EXECUTABLE which isn't set in a
# standalone LLDB build.
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
set(Python3_EXECUTABLE ${Python3_EXECUTABLE})
add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit)
endif()
endif()
2 changes: 1 addition & 1 deletion lldb/test/Shell/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ config.lldb_tools_dir = "@LLDB_TOOLS_DIR@"
# should not need to be escaped.
config.lldb_lit_tools_dir = r"@LLDB_LIT_TOOLS_DIR@"
config.target_triple = "@TARGET_TRIPLE@"
config.python_executable = "@PYTHON_EXECUTABLE@"
config.python_executable = "@Python3_EXECUTABLE@"
config.have_zlib = @LLVM_ENABLE_ZLIB@
config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@
config.host_triple = "@LLVM_HOST_TRIPLE@"
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/Unit/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.lldb_obj_root = "@LLDB_BINARY_DIR@"
config.lldb_src_root = "@LLDB_SOURCE_DIR@"
config.target_triple = "@TARGET_TRIPLE@"
config.python_executable = "@PYTHON_EXECUTABLE@"
config.python_executable = "@Python3_EXECUTABLE@"

# Support substitution of the tools and libs dirs with user parameters. This is
# used when we can't determine the tool dir at configuration time.
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.lldb_obj_root = "@LLDB_BINARY_DIR@"
config.lldb_src_root = "@LLDB_SOURCE_DIR@"
config.target_triple = "@TARGET_TRIPLE@"
config.python_executable = "@PYTHON_EXECUTABLE@"
config.python_executable = "@Python3_EXECUTABLE@"

# Support substitution of the tools and libs dirs with user parameters. This is
# used when we can't determine the tool dir at configuration time.
Expand Down
2 changes: 1 addition & 1 deletion lldb/tools/intel-features/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ add_lldb_library(lldbIntelFeatures SHARED

LINK_LIBS
${FEATURE_LIBS}
${PYTHON_LIBRARY}
${Python3_LIBRARIES}
)

# Add link dependencies for python wrapper
Expand Down
6 changes: 3 additions & 3 deletions lldb/tools/lldb-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ add_lldb_tool(lldb-test
Support
)

if(PYTHON_RPATH)
set_property(TARGET lldb-test APPEND PROPERTY INSTALL_RPATH "${PYTHON_RPATH}")
set_property(TARGET lldb-test APPEND PROPERTY BUILD_RPATH "${PYTHON_RPATH}")
if(Python3_RPATH)
set_property(TARGET lldb-test APPEND PROPERTY INSTALL_RPATH "${Python3_RPATH}")
set_property(TARGET lldb-test APPEND PROPERTY BUILD_RPATH "${Python3_RPATH}")
endif()

target_include_directories(lldb-test PRIVATE ${LLDB_SOURCE_DIR}/source)
Expand Down
4 changes: 2 additions & 2 deletions lldb/unittests/API/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ add_lldb_unittest(APITests
liblldb
)

if(PYTHON_RPATH)
set_property(TARGET APITests APPEND PROPERTY BUILD_RPATH "${PYTHON_RPATH}")
if(Python3_RPATH)
set_property(TARGET APITests APPEND PROPERTY BUILD_RPATH "${Python3_RPATH}")
endif()
2 changes: 1 addition & 1 deletion lldb/unittests/Process/Linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ add_lldb_unittest(ProcessorTraceTests

LINK_LIBS
lldbPluginProcessLinux
)
)
2 changes: 1 addition & 1 deletion lldb/unittests/ScriptInterpreter/Lua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ add_lldb_unittest(ScriptInterpreterLuaTests
LLVMTestingSupport
LINK_COMPONENTS
Support
)
)
6 changes: 3 additions & 3 deletions lldb/unittests/ScriptInterpreter/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ add_lldb_unittest(ScriptInterpreterPythonTests
Support
)

if(PYTHON_RPATH)
set_property(TARGET ScriptInterpreterPythonTests APPEND PROPERTY BUILD_RPATH "${PYTHON_RPATH}")
endif()
if(Python3_RPATH)
set_property(TARGET ScriptInterpreterPythonTests APPEND PROPERTY BUILD_RPATH "${Python3_RPATH}")
endif()
2 changes: 1 addition & 1 deletion lldb/utils/lldb-dotest/lldb-dotest.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!@PYTHON_EXECUTABLE@
#!@Python3_EXECUTABLE@
import subprocess
import sys

Expand Down