llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Charles Zablit (charles-zablit) <details> <summary>Changes</summary> 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 https://github.com/swiftlang/swift/pull/82063 for the original issue. --- Full diff: https://github.com/llvm/llvm-project/pull/143183.diff 5 Files Affected: - (modified) compiler-rt/test/lit.common.configured.in (+1) - (modified) lldb/test/Shell/lit.cfg.py (+5) - (modified) lldb/test/Shell/lit.site.cfg.py.in (+1) - (modified) lldb/test/Unit/lit.cfg.py (+1) - (modified) lldb/test/Unit/lit.site.cfg.py.in (+1) ``````````diff 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) `````````` </details> https://github.com/llvm/llvm-project/pull/143183 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits