[Lldb-commits] [lldb] 215a311 - Revert "Allow customized relative PYTHONHOME"
Stella Stamenova via lldb-commits
lldb-commits at lists.llvm.org
Fri Feb 21 14:58:32 PST 2020
Author: Stella Stamenova
Date: 2020-02-21T14:57:00-08:00
New Revision: 215a31115f89c851331a822e67aa4528ba5c21e6
URL: https://github.com/llvm/llvm-project/commit/215a31115f89c851331a822e67aa4528ba5c21e6
DIFF: https://github.com/llvm/llvm-project/commit/215a31115f89c851331a822e67aa4528ba5c21e6.diff
LOG: Revert "Allow customized relative PYTHONHOME"
This reverts commit 0bb90628b5f7c170689d2d3f019af773772fc649 since it is causing failures on the Windows LLDB buildbot:
http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/14048
Added:
Modified:
lldb/cmake/modules/LLDBConfig.cmake
lldb/include/lldb/Host/Config.h.cmake
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
Removed:
################################################################################
diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake
index 6b10f73eff19..fb4512a87998 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -59,6 +59,7 @@ add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" L
add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml2 LIBXML2_FOUND VERSION 2.8)
+option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to locate Python." OFF)
option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install a copy of it" OFF)
option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
@@ -139,20 +140,10 @@ if (LLDB_ENABLE_LIBEDIT)
endif()
if (LLDB_ENABLE_PYTHON)
- if(CMAKE_SYSTEM_NAME MATCHES "Windows")
- set(default_embed_python_home ON)
- else()
- set(default_embed_python_home OFF)
- endif()
- option(LLDB_EMBED_PYTHON_HOME
- "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})
- if (LLDB_EMBED_PYTHON_HOME)
+ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND NOT LLDB_RELOCATABLE_PYTHON)
get_filename_component(PYTHON_HOME "${PYTHON_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.")
+ file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
endif()
endif()
diff --git a/lldb/include/lldb/Host/Config.h.cmake b/lldb/include/lldb/Host/Config.h.cmake
index 42f4ca1a26c6..e9065ed04caa 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -46,8 +46,6 @@
#cmakedefine01 LLDB_ENABLE_PYTHON
-#cmakedefine01 LLDB_EMBED_PYTHON_HOME
-
#cmakedefine LLDB_PYTHON_HOME "${LLDB_PYTHON_HOME}"
#define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index f046bcfd18eb..722af713ba43 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -277,36 +277,14 @@ struct InitializePythonRAII {
private:
void InitializePythonHome() {
-#if LLDB_EMBED_PYTHON_HOME
+#if defined(LLDB_PYTHON_HOME)
#if PY_MAJOR_VERSION >= 3
- typedef const wchar_t* str_type;
+ size_t size = 0;
+ static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
#else
- typedef char* str_type;
+ static char g_python_home[] = LLDB_PYTHON_HOME;
#endif
- static str_type g_python_home = []() -> str_type {
- const char *lldb_python_home = LLDB_PYTHON_HOME;
- const char *absolute_python_home = nullptr;
- llvm::SmallString<64> path;
- if (llvm::sys::path::is_absolute(lldb_python_home)) {
- absolute_python_home = lldb_python_home;
- } else {
- FileSpec spec = HostInfo::GetShlibDir();
- if (!spec)
- return nullptr;
- spec.GetPath(path);
- llvm::sys::path::append(path, lldb_python_home);
- absolute_python_home = path.c_str();
- }
-#if PY_MAJOR_VERSION >= 3
- size_t size = 0;
- return Py_DecodeLocale(absolute_python_home, &size);
-#else
- return strdup(absolute_python_home);
-#endif
- }();
- if (g_python_home != nullptr) {
- Py_SetPythonHome(g_python_home);
- }
+ Py_SetPythonHome(g_python_home);
#else
#if defined(__APPLE__) && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 7
// For Darwin, the only Python version supported is the one shipped in the
More information about the lldb-commits
mailing list