Skip to content

Commit f63bfdb

Browse files
[lldb] make lit use the same PYTHONHOME for building and testing (llvm#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.
1 parent aaa0733 commit f63bfdb

File tree

5 files changed

+9
-0
lines changed

5 files changed

+9
-0
lines changed

compiler-rt/test/lit.common.configured.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ set_default("gold_executable", "@GOLD_EXECUTABLE@")
2525
set_default("clang", "@COMPILER_RT_RESOLVED_TEST_COMPILER@")
2626
set_default("compiler_id", "@COMPILER_RT_TEST_COMPILER_ID@")
2727
set_default("python_executable", "@Python3_EXECUTABLE@")
28+
set_default("python_root_dir", "@Python3_ROOT_DIR@")
2829
set_default("compiler_rt_debug", @COMPILER_RT_DEBUG_PYBOOL@)
2930
set_default("compiler_rt_intercept_libdispatch", @COMPILER_RT_INTERCEPT_LIBDISPATCH_PYBOOL@)
3031
set_default("compiler_rt_output_dir", "@COMPILER_RT_RESOLVED_OUTPUT_DIR@")

lldb/test/Shell/lit.cfg.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,8 @@ def calculate_arch_features(arch_string):
219219
config.available_features.add("ld_new-bug")
220220
except:
221221
pass
222+
223+
# Some shell tests dynamically link with python.dll and need to know the
224+
# location of the Python libraries. This ensures that we use the same
225+
# version of Python that was used to build lldb to run our tests.
226+
config.environment["PYTHONHOME"] = config.python_root_dir

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ config.python_executable = "@Python3_EXECUTABLE@"
1919
config.swiftc = "@LLDB_SWIFTC@"
2020
config.swift_libs_dir = '@LLDB_SWIFT_LIBS@'
2121
config.lldb_enable_swift = @LLDB_ENABLE_SWIFT_SUPPORT@
22+
config.python_root_dir = "@Python3_ROOT_DIR@"
2223
config.have_zlib = @LLVM_ENABLE_ZLIB@
2324
config.objc_gnustep_dir = "@LLDB_TEST_OBJC_GNUSTEP_DIR@"
2425
config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@

lldb/test/Unit/lit.cfg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
]
3434
)
3535
llvm_config.with_environment("PATH", os.path.dirname(sys.executable), append_path=True)
36+
config.environment["PYTHONHOME"] = config.python_root_dir
3637

3738
# Enable sanitizer runtime flags.
3839
config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ config.lldb_obj_root = "@LLDB_BINARY_DIR@"
1010
config.lldb_src_root = "@LLDB_SOURCE_DIR@"
1111
config.target_triple = "@LLVM_TARGET_TRIPLE@"
1212
config.python_executable = "@Python3_EXECUTABLE@"
13+
config.python_root_dir = "@Python3_ROOT_DIR@"
1314

1415
import lit.llvm
1516
lit.llvm.initialize(lit_config, config)

0 commit comments

Comments
 (0)