Skip to content

Commit 45bc525

Browse files
committed
Merge commit '1c630cb2fbc0' from apple/stable/20200714 into swift/main
Conflicts: lldb/cmake/modules/FindPythonInterpAndLibs.cmake lldb/test/Shell/lit.site.cfg.py.in
2 parents 894877c + 1c630cb commit 45bc525

File tree

34 files changed

+238
-208
lines changed

34 files changed

+238
-208
lines changed

lldb/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ endif()
6161

6262
if (LLDB_ENABLE_PYTHON)
6363
execute_process(
64-
COMMAND ${PYTHON_EXECUTABLE}
64+
COMMAND ${Python3_EXECUTABLE}
6565
-c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(True, False, ''))"
6666
OUTPUT_VARIABLE LLDB_PYTHON_DEFAULT_RELATIVE_PATH
6767
OUTPUT_STRIP_TRAILING_WHITESPACE)

lldb/bindings/python/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function(create_python_package swig_target working_dir pkg_dir)
2626
set(copy_cmd COMMAND ${CMAKE_COMMAND} -E copy ${ARG_FILES} ${pkg_dir})
2727
endif()
2828
if(NOT ARG_NOINIT)
29-
set(init_cmd COMMAND ${PYTHON_EXECUTABLE}
29+
set(init_cmd COMMAND ${Python3_EXECUTABLE}
3030
"${LLDB_SOURCE_DIR}/bindings/python/createPythonInit.py"
3131
"${pkg_dir}" ${ARG_FILES})
3232
endif()
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#.rst:
2+
# FindPythonAndSwig
3+
# -----------
4+
#
5+
# Find the python interpreter and libraries as a whole.
6+
7+
macro(FindPython3)
8+
# Use PYTHON_HOME as a hint to find Python 3.
9+
set(Python3_ROOT_DIR "${PYTHON_HOME}")
10+
find_package(Python3 COMPONENTS Interpreter Development)
11+
if(Python3_FOUND AND Python3_Interpreter_FOUND)
12+
13+
# The install name for the Python 3 framework in Xcode is relative to
14+
# the framework's location and not the dylib itself.
15+
#
16+
# @rpath/Python3.framework/Versions/3.x/Python3
17+
#
18+
# This means that we need to compute the path to the Python3.framework
19+
# and use that as the RPATH instead of the usual dylib's directory.
20+
#
21+
# The check below shouldn't match Homebrew's Python framework as it is
22+
# called Python.framework instead of Python3.framework.
23+
if (APPLE AND Python3_LIBRARIES MATCHES "Python3.framework")
24+
string(FIND "${Python3_LIBRARIES}" "Python3.framework" python_framework_pos)
25+
string(SUBSTRING "${Python3_LIBRARIES}" "0" ${python_framework_pos} Python3_RPATH)
26+
endif()
27+
28+
set(PYTHON3_FOUND TRUE)
29+
mark_as_advanced(
30+
Python3_LIBRARIES
31+
Python3_INCLUDE_DIRS
32+
Python3_EXECUTABLE
33+
Python3_RPATH
34+
SWIG_EXECUTABLE)
35+
endif()
36+
endmacro()
37+
38+
if(Python3_LIBRARIES AND Python3_INCLUDE_DIRS AND Python3_EXECUTABLE AND SWIG_EXECUTABLE)
39+
set(PYTHONANDSWIG_FOUND TRUE)
40+
else()
41+
find_package(SWIG 2.0)
42+
if (SWIG_FOUND)
43+
FindPython3()
44+
else()
45+
message(STATUS "SWIG 2 or later is required for Python support in LLDB but could not be found")
46+
endif()
47+
48+
include(FindPackageHandleStandardArgs)
49+
find_package_handle_standard_args(PythonAndSwig
50+
FOUND_VAR
51+
PYTHONANDSWIG_FOUND
52+
REQUIRED_VARS
53+
Python3_LIBRARIES
54+
Python3_INCLUDE_DIRS
55+
Python3_EXECUTABLE
56+
SWIG_EXECUTABLE)
57+
endif()

lldb/cmake/modules/FindPythonInterpAndLibs.cmake

Lines changed: 0 additions & 116 deletions
This file was deleted.

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support in LLDB" Li
5656
add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" CursesAndPanel CURSESANDPANEL_FOUND)
5757
add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in LLDB" LibLZMA LIBLZMA_FOUND)
5858
add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" LuaAndSwig LUAANDSWIG_FOUND)
59-
add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
59+
add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonAndSwig PYTHONANDSWIG_FOUND)
6060
add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml2 LIBXML2_FOUND VERSION 2.8)
6161

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

9792
set(LLDB_FRAMEWORK_VERSION A CACHE STRING "LLDB.framework version (default is A)")
9893
set(LLDB_FRAMEWORK_BUILD_DIR bin CACHE STRING "Output directory for LLDB.framework")
@@ -158,9 +153,9 @@ if (LLDB_ENABLE_PYTHON)
158153
"Embed PYTHONHOME in the binary. If set to OFF, PYTHONHOME environment variable will be used to to locate Python."
159154
${default_embed_python_home})
160155

161-
include_directories(${PYTHON_INCLUDE_DIRS})
156+
include_directories(${Python3_INCLUDE_DIRS})
162157
if (LLDB_EMBED_PYTHON_HOME)
163-
get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY)
158+
get_filename_component(PYTHON_HOME "${Python3_EXECUTABLE}" DIRECTORY)
164159
set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
165160
"Path to use as PYTHONHOME in lldb. If a relative path is specified, it will be resolved at runtime relative to liblldb directory.")
166161
endif()

lldb/source/API/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ if(LLDB_ENABLE_PYTHON AND (BUILD_SHARED_LIBS OR LLVM_LINK_LLVM_DYLIB) AND UNIX A
134134
set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "\$ORIGIN/../../../../lib${LLVM_LIBDIR_SUFFIX}")
135135
endif()
136136

137-
if(PYTHON_RPATH)
138-
set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "${PYTHON_RPATH}")
139-
set_property(TARGET liblldb APPEND PROPERTY BUILD_RPATH "${PYTHON_RPATH}")
137+
if(Python3_RPATH)
138+
set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "${Python3_RPATH}")
139+
set_property(TARGET liblldb APPEND PROPERTY BUILD_RPATH "${Python3_RPATH}")
140140
endif()
141141

142142
if (MSVC)
@@ -200,9 +200,9 @@ endif()
200200

201201
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
202202
# Only MSVC has the ABI compatibility problem and avoids using FindPythonLibs,
203-
# so only it needs to explicitly link against ${PYTHON_LIBRARIES}
203+
# so only it needs to explicitly link against ${Python3_LIBRARIES}
204204
if (MSVC AND LLDB_ENABLE_PYTHON)
205-
target_link_libraries(liblldb PRIVATE ${PYTHON_LIBRARIES})
205+
target_link_libraries(liblldb PRIVATE ${Python3_LIBRARIES})
206206
endif()
207207
else()
208208
set_target_properties(liblldb

lldb/source/Plugins/ObjectFile/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ add_subdirectory(ELF)
33
add_subdirectory(Mach-O)
44
add_subdirectory(PECOFF)
55
add_subdirectory(JIT)
6-
add_subdirectory(wasm)
6+
add_subdirectory(wasm)

lldb/source/Plugins/ScriptInterpreter/None/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ add_lldb_library(lldbPluginScriptInterpreterNone PLUGIN
44
LINK_LIBS
55
lldbCore
66
lldbInterpreter
7-
)
7+
)

lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
1919
lldbHost
2020
lldbInterpreter
2121
lldbTarget
22-
${PYTHON_LIBRARIES}
22+
${Python3_LIBRARIES}
2323
${LLDB_LIBEDIT_LIBS}
2424

2525
LINK_COMPONENTS

lldb/test/API/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function(add_python_test_target name test_script args comment)
22
set(PYTHON_TEST_COMMAND
3-
${PYTHON_EXECUTABLE}
3+
${Python3_EXECUTABLE}
44
${test_script}
55
${args}
66
)

lldb/test/API/lit.site.cfg.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
1919
config.target_triple = "@TARGET_TRIPLE@"
2020
config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
2121
config.lldb_reproducer_directory = os.path.join("@LLDB_TEST_BUILD_DIRECTORY@", "reproducers")
22-
config.python_executable = "@PYTHON_EXECUTABLE@"
22+
config.python_executable = "@Python3_EXECUTABLE@"
2323
config.dotest_path = "@LLDB_SOURCE_DIR@/test/API/dotest.py"
2424
config.dotest_args_str = "@LLDB_DOTEST_ARGS@"
2525
config.lldb_enable_python = @LLDB_ENABLE_PYTHON@

lldb/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ if(LLDB_BUILT_STANDALONE)
234234
if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit)
235235
# LLVM's make_paths_relative uses Python3_EXECUTABLE which isn't set in a
236236
# standalone LLDB build.
237-
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
237+
set(Python3_EXECUTABLE ${Python3_EXECUTABLE})
238238
add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit)
239239
endif()
240240
endif()

lldb/test/Shell/lit.site.cfg.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ config.lldb_tools_dir = "@LLDB_TOOLS_DIR@"
1313
# should not need to be escaped.
1414
config.lldb_lit_tools_dir = r"@LLDB_LIT_TOOLS_DIR@"
1515
config.target_triple = "@TARGET_TRIPLE@"
16-
config.python_executable = "@PYTHON_EXECUTABLE@"
16+
config.python_executable = "@Python3_EXECUTABLE@"
1717
config.swiftc = "@LLDB_SWIFTC@"
1818
config.have_zlib = @LLVM_ENABLE_ZLIB@
1919
config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@

lldb/test/Unit/lit.site.cfg.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
1010
config.lldb_obj_root = "@LLDB_BINARY_DIR@"
1111
config.lldb_src_root = "@LLDB_SOURCE_DIR@"
1212
config.target_triple = "@TARGET_TRIPLE@"
13-
config.python_executable = "@PYTHON_EXECUTABLE@"
13+
config.python_executable = "@Python3_EXECUTABLE@"
1414

1515
# Support substitution of the tools and libs dirs with user parameters. This is
1616
# used when we can't determine the tool dir at configuration time.

lldb/test/lit.site.cfg.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
1010
config.lldb_obj_root = "@LLDB_BINARY_DIR@"
1111
config.lldb_src_root = "@LLDB_SOURCE_DIR@"
1212
config.target_triple = "@TARGET_TRIPLE@"
13-
config.python_executable = "@PYTHON_EXECUTABLE@"
13+
config.python_executable = "@Python3_EXECUTABLE@"
1414

1515
# Support substitution of the tools and libs dirs with user parameters. This is
1616
# used when we can't determine the tool dir at configuration time.

lldb/tools/intel-features/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ add_lldb_library(lldbIntelFeatures SHARED
5656

5757
LINK_LIBS
5858
${FEATURE_LIBS}
59-
${PYTHON_LIBRARY}
59+
${Python3_LIBRARIES}
6060
)
6161

6262
# Add link dependencies for python wrapper

lldb/tools/lldb-test/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ add_lldb_tool(lldb-test
2424
Support
2525
)
2626

27-
if(PYTHON_RPATH)
28-
set_property(TARGET lldb-test APPEND PROPERTY INSTALL_RPATH "${PYTHON_RPATH}")
29-
set_property(TARGET lldb-test APPEND PROPERTY BUILD_RPATH "${PYTHON_RPATH}")
27+
if(Python3_RPATH)
28+
set_property(TARGET lldb-test APPEND PROPERTY INSTALL_RPATH "${Python3_RPATH}")
29+
set_property(TARGET lldb-test APPEND PROPERTY BUILD_RPATH "${Python3_RPATH}")
3030
endif()
3131

3232
target_include_directories(lldb-test PRIVATE ${LLDB_SOURCE_DIR}/source)

lldb/unittests/API/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ add_lldb_unittest(APITests
55
liblldb
66
)
77

8-
if(PYTHON_RPATH)
9-
set_property(TARGET APITests APPEND PROPERTY BUILD_RPATH "${PYTHON_RPATH}")
8+
if(Python3_RPATH)
9+
set_property(TARGET APITests APPEND PROPERTY BUILD_RPATH "${Python3_RPATH}")
1010
endif()

lldb/unittests/Process/Linux/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ add_lldb_unittest(ProcessorTraceTests
55

66
LINK_LIBS
77
lldbPluginProcessLinux
8-
)
8+
)

lldb/unittests/ScriptInterpreter/Lua/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ add_lldb_unittest(ScriptInterpreterLuaTests
99
LLVMTestingSupport
1010
LINK_COMPONENTS
1111
Support
12-
)
12+
)

lldb/unittests/ScriptInterpreter/Python/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ add_lldb_unittest(ScriptInterpreterPythonTests
1010
Support
1111
)
1212

13-
if(PYTHON_RPATH)
14-
set_property(TARGET ScriptInterpreterPythonTests APPEND PROPERTY BUILD_RPATH "${PYTHON_RPATH}")
15-
endif()
13+
if(Python3_RPATH)
14+
set_property(TARGET ScriptInterpreterPythonTests APPEND PROPERTY BUILD_RPATH "${Python3_RPATH}")
15+
endif()

lldb/utils/lldb-dotest/lldb-dotest.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!@PYTHON_EXECUTABLE@
1+
#!@Python3_EXECUTABLE@
22
import subprocess
33
import sys
44

0 commit comments

Comments
 (0)