Skip to content

Commit 3a2c6ff

Browse files
rupprechtweliveindetail
authored andcommitted
[lldb][test][NFC] Add option to exclude third_party packages (llvm#83191)
The goal here is to remove the third_party/Python/module tree, which LLDB tests only use to `import pexpect`. This package is available on `pip`, and I believe should not be hard to obtain. However, in case it isn't easily available, deleting the tree right now could cause disruption. This introduces a `LLDB_TEST_USE_VENDOR_PACKAGES` cmake param that can be enabled, and the tests will continue loading that tree. By default, it is enabled, meaning there's really no change here. A followup change will disable it by default once all known build bots are updated to include this package. When disabled, an eager cmake check runs that makes sure `pexpect` is available before waiting for the test to fail in an obscure way. Later, this option will go away, and when it does, we can delete the tree too. Ideally this is not disruptive, and we can remove it in a week or two.
1 parent a678a0e commit 3a2c6ff

File tree

7 files changed

+31
-2
lines changed

7 files changed

+31
-2
lines changed

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ option(LLDB_SKIP_STRIP "Whether to skip stripping of binaries when installing ll
8484
option(LLDB_SKIP_DSYM "Whether to skip generating a dSYM when installing lldb." OFF)
8585
option(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS
8686
"Fail to configure if certain requirements are not met for testing." OFF)
87+
option(LLDB_TEST_USE_VENDOR_PACKAGES
88+
"Use packages from lldb/third_party/Python/module instead of system deps." ON)
8789

8890
# BEGIN SWIFT MOD
8991
option(LLDB_ENABLE_WERROR "Fail and stop if a warning is triggered." ${LLVM_ENABLE_WERROR})

lldb/test/API/lit.cfg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,3 +341,6 @@ def delete_module_cache(path):
341341
# Propagate XDG_CACHE_HOME
342342
if "XDG_CACHE_HOME" in os.environ:
343343
config.environment["XDG_CACHE_HOME"] = os.environ["XDG_CACHE_HOME"]
344+
345+
if is_configured("use_vendor_packages"):
346+
config.environment["LLDB_TEST_USE_VENDOR_PACKAGES"] = "1"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ config.libcxx_include_target_dir = "@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@"
3939
# The API tests use their own module caches.
4040
config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-api")
4141
config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-api")
42+
config.use_vendor_packages = @LLDB_TEST_USE_VENDOR_PACKAGES@
4243
config.swift_libs_dir = '@LLDB_SWIFT_LIBS@'
4344

4445
# Plugins

lldb/test/CMakeLists.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
2626
endforeach()
2727
endif()
2828

29+
# The "pexpect" package should come from the system environment, not from the
30+
# LLDB tree. However, we delay the deletion of it from the tree in case
31+
# users/buildbots don't have the package yet and need some time to install it.
32+
if (NOT LLDB_TEST_USE_VENDOR_PACKAGES)
33+
lldb_find_python_module(pexpect)
34+
if (NOT PY_pexpect_FOUND)
35+
message(FATAL_ERROR
36+
"Python module 'pexpect' not found. Please install it via pip or via "
37+
"your operating system's package manager. For a temporary workaround, "
38+
"use a version from the LLDB tree with "
39+
"`LLDB_TEST_USE_VENDOR_PACKAGES=ON`")
40+
endif()
41+
endif()
42+
2943
if(LLDB_BUILT_STANDALONE)
3044
# In order to run check-lldb-* we need the correct map_config directives in
3145
# llvm-lit. Because this is a standalone build, LLVM doesn't know about LLDB,
@@ -248,7 +262,8 @@ llvm_canonicalize_cmake_booleans(
248262
LLDB_HAS_LIBCXX
249263
LLDB_TOOL_LLDB_SERVER_BUILD
250264
LLDB_USE_SYSTEM_DEBUGSERVER
251-
LLDB_IS_64_BITS)
265+
LLDB_IS_64_BITS
266+
LLDB_TEST_USE_VENDOR_PACKAGES)
252267

253268
# BEGIN SWIFT
254269
llvm_canonicalize_cmake_booleans(

lldb/use_lldb_suite_root.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ def add_lldbsuite_packages_dir(lldb_root):
2121

2222
lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
2323

24-
add_third_party_module_dirs(lldb_root)
24+
# Use environment variables to avoid plumbing flags, lit configs, etc.
25+
if os.getenv("LLDB_TEST_USE_VENDOR_PACKAGES"):
26+
add_third_party_module_dirs(lldb_root)
2527
add_lldbsuite_packages_dir(lldb_root)

lldb/utils/lldb-dotest/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ set(LLDB_LIBS_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
1010
llvm_canonicalize_cmake_booleans(
1111
LLDB_BUILD_INTEL_PT
1212
LLDB_HAS_LIBCXX
13+
LLDB_TEST_USE_VENDOR_PACKAGES
1314
)
1415

1516
if ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!@Python3_EXECUTABLE@
2+
import os
23
import subprocess
34
import sys
45

@@ -19,9 +20,13 @@ has_libcxx = @LLDB_HAS_LIBCXX@
1920
libcxx_libs_dir = "@LIBCXX_LIBRARY_DIR@"
2021
libcxx_include_dir = "@LIBCXX_GENERATED_INCLUDE_DIR@"
2122
libcxx_include_target_dir = "@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@"
23+
use_vendor_packages = @LLDB_TEST_USE_VENDOR_PACKAGES@
2224
swift_libs_dir = '@LLDB_SWIFT_LIBS@'
2325

2426
if __name__ == '__main__':
27+
if use_vendor_packages:
28+
os.putenv("LLDB_TEST_USE_VENDOR_PACKAGES", "1")
29+
2530
wrapper_args = sys.argv[1:]
2631
dotest_args = []
2732
# split on an empty string will produce [''] and if you

0 commit comments

Comments
 (0)