-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb] make lit use the same PYTHONHOME for building and testing #143183
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
[lldb] make lit use the same PYTHONHOME for building and testing #143183
Conversation
@llvm/pr-subscribers-lldb Author: Charles Zablit (charles-zablit) ChangesWhen testing LLDB, we want to make sure to use the same Python as the one we used to build it. This patch used the CMake variable Please see swiftlang/swift#82063 for the original issue. Full diff: https://github.com/llvm/llvm-project/pull/143183.diff 5 Files Affected:
diff --git a/compiler-rt/test/lit.common.configured.in b/compiler-rt/test/lit.common.configured.in
index 04d1a4df5a54f..8ca47a8df5aed 100644
--- a/compiler-rt/test/lit.common.configured.in
+++ b/compiler-rt/test/lit.common.configured.in
@@ -25,6 +25,7 @@ set_default("gold_executable", "@GOLD_EXECUTABLE@")
set_default("clang", "@COMPILER_RT_RESOLVED_TEST_COMPILER@")
set_default("compiler_id", "@COMPILER_RT_TEST_COMPILER_ID@")
set_default("python_executable", "@Python3_EXECUTABLE@")
+set_default("python_root_dir", "@Python3_ROOT_DIR@")
set_default("compiler_rt_debug", @COMPILER_RT_DEBUG_PYBOOL@)
set_default("compiler_rt_intercept_libdispatch", @COMPILER_RT_INTERCEPT_LIBDISPATCH_PYBOOL@)
set_default("compiler_rt_output_dir", "@COMPILER_RT_RESOLVED_OUTPUT_DIR@")
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 193639667db5b..ab6113767187a 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -198,3 +198,8 @@ def calculate_arch_features(arch_string):
config.available_features.add("ld_new-bug")
except:
pass
+
+# Some shell tests dynamically link with python.dll and need to know the
+# location of the Python libraries. This ensures that we use the same
+# version of Python that was used to build lldb to run our tests.
+config.environment["PYTHONHOME"] = config.python_root_dir
diff --git a/lldb/test/Shell/lit.site.cfg.py.in b/lldb/test/Shell/lit.site.cfg.py.in
index 7e03938b12b23..5be5359217769 100644
--- a/lldb/test/Shell/lit.site.cfg.py.in
+++ b/lldb/test/Shell/lit.site.cfg.py.in
@@ -21,6 +21,7 @@ config.enable_remote = not @LLDB_TEST_SHELL_DISABLE_REMOTE@
config.libcxx_libs_dir = "@LIBCXX_LIBRARY_DIR@"
config.target_triple = "@LLVM_TARGET_TRIPLE@"
config.python_executable = "@Python3_EXECUTABLE@"
+config.python_root_dir = "@Python3_ROOT_DIR@"
config.have_zlib = @LLVM_ENABLE_ZLIB@
config.objc_gnustep_dir = "@LLDB_TEST_OBJC_GNUSTEP_DIR@"
config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@
diff --git a/lldb/test/Unit/lit.cfg.py b/lldb/test/Unit/lit.cfg.py
index 8d711f17d858e..681e3b19dce34 100644
--- a/lldb/test/Unit/lit.cfg.py
+++ b/lldb/test/Unit/lit.cfg.py
@@ -33,6 +33,7 @@
]
)
llvm_config.with_environment("PATH", os.path.dirname(sys.executable), append_path=True)
+config.environment["PYTHONHOME"] = config.python_root_dir
# Enable sanitizer runtime flags.
if config.llvm_use_sanitizer:
diff --git a/lldb/test/Unit/lit.site.cfg.py.in b/lldb/test/Unit/lit.site.cfg.py.in
index 2748be229cf1c..fb94797bcd7de 100644
--- a/lldb/test/Unit/lit.site.cfg.py.in
+++ b/lldb/test/Unit/lit.site.cfg.py.in
@@ -11,6 +11,7 @@ config.lldb_src_root = "@LLDB_SOURCE_DIR@"
config.target_triple = "@LLVM_TARGET_TRIPLE@"
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
config.python_executable = "@Python3_EXECUTABLE@"
+config.python_root_dir = "@Python3_ROOT_DIR@"
import lit.llvm
lit.llvm.initialize(lit_config, config)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Merging based on Jonas's approval (@charles-zablit doesn't have commit access yet) |
…m#143183) When testing LLDB, we want to make sure to use the same Python as the one we used to build it. This patch used the CMake variable `Python3_ROOT_DIR` to set the `PYTHONHOME` env variable in LLDB lit tests, in order to ensure of this. Please see swiftlang/swift#82063 for the original issue.
…m#143183) When testing LLDB, we want to make sure to use the same Python as the one we used to build it. This patch used the CMake variable `Python3_ROOT_DIR` to set the `PYTHONHOME` env variable in LLDB lit tests, in order to ensure of this. Please see swiftlang/swift#82063 for the original issue.
In #143183 was mistakenly added a default value to `python_root_dir` in lit tests of compiler-rt. This is unused by the lit tests of compiler-rt, as it was meant to be used by `lldb`. This patch removes this change.
…ts (#143738) In llvm/llvm-project#143183 was mistakenly added a default value to `python_root_dir` in lit tests of compiler-rt. This is unused by the lit tests of compiler-rt, as it was meant to be used by `lldb`. This patch removes this change.
…m#143183) When testing LLDB, we want to make sure to use the same Python as the one we used to build it. This patch used the CMake variable `Python3_ROOT_DIR` to set the `PYTHONHOME` env variable in LLDB lit tests, in order to ensure of this. Please see swiftlang/swift#82063 for the original issue.
…3738) In llvm#143183 was mistakenly added a default value to `python_root_dir` in lit tests of compiler-rt. This is unused by the lit tests of compiler-rt, as it was meant to be used by `lldb`. This patch removes this change.
…m#143183) When testing LLDB, we want to make sure to use the same Python as the one we used to build it. This patch used the CMake variable `Python3_ROOT_DIR` to set the `PYTHONHOME` env variable in LLDB lit tests, in order to ensure of this. Please see swiftlang/swift#82063 for the original issue.
…3738) In llvm#143183 was mistakenly added a default value to `python_root_dir` in lit tests of compiler-rt. This is unused by the lit tests of compiler-rt, as it was meant to be used by `lldb`. This patch removes this change.
…on-pythonhome-to-6.2 🍒 [lldb] make lit use the same PYTHONHOME for building and testing (llvm#143183)
…3738) In llvm#143183 was mistakenly added a default value to `python_root_dir` in lit tests of compiler-rt. This is unused by the lit tests of compiler-rt, as it was meant to be used by `lldb`. This patch removes this change.
When testing LLDB, we want to make sure to use the same Python as the one we used to build it.
This patch used the CMake variable
Python3_ROOT_DIR
to set thePYTHONHOME
env variable in LLDB lit tests, in order to ensure of this.Please see swiftlang/swift#82063 for the original issue.