Skip to content

Commit ff5982a

Browse files
committed
[test] Fix various module cache bugs and inconsistencies
Currently, lit tests don't set neither the module cache for building inferiors nor the module cache used by lldb when running tests. Furthermore, we have several places where we rely on the path to the module cache being always the same, rather than passing the correct value around. This makes it hard to specify a different module cache path when debugging a a test. This patch reworks how we determine and pass around the module cache paths and fixes the omission on the lit side. It also adds a sanity check to the lit and dotest suites. Differential revision: https://reviews.llvm.org/D66966 llvm-svn: 370394
1 parent 5a43fdd commit ff5982a

File tree

16 files changed

+86
-30
lines changed

16 files changed

+86
-30
lines changed

lldb/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ add_subdirectory(docs)
7171

7272
option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS})
7373
if(LLDB_INCLUDE_TESTS)
74+
set(LLDB_TEST_BUILD_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lldb-test-build.noindex" CACHE PATH "The build root for building tests.")
7475

7576
# Set the path to the default lldb test executable.
7677
set(LLDB_DEFAULT_TEST_EXECUTABLE "${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb${CMAKE_EXECUTABLE_SUFFIX}")

lldb/lit/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ endif()
1515
get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY)
1616
set(dotest_args_replacement ${LLVM_BUILD_MODE})
1717

18+
set(LLDB_TEST_MODULE_CACHE_LLDB "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-lldb" CACHE PATH "The Clang module cache used by the Clang embedded in LLDB while running tests.")
19+
set(LLDB_TEST_MODULE_CACHE_CLANG "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-clang" CACHE PATH "The Clang module cache used by the Clang while building tests.")
20+
1821
if(LLDB_BUILT_STANDALONE)
1922
# In paths to our build-tree, replace CMAKE_CFG_INTDIR with our configuration name placeholder.
2023
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} config_runtime_output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This is a sanity check that verifies that the module cache path is set
2+
# correctly and points inside the default test build directory.
3+
RUN: %lldb -o 'settings show symbols.clang-modules-cache-path' | FileCheck %s
4+
CHECK: lldb-test-build.noindex{{.*}}module-cache-lldb

lldb/lit/Suite/lit.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ if config.dotest_lit_args_str:
6969
if config.llvm_libs_dir:
7070
dotest_cmd += ['--env', 'LLVM_LIBS_DIR=' + config.llvm_libs_dir]
7171

72+
if config.lldb_build_directory:
73+
dotest_cmd += ['--build-dir', config.lldb_build_directory]
74+
75+
if config.lldb_module_cache:
76+
dotest_cmd += ['--module-cache-dir', config.lldb_module_cache]
77+
7278
# Load LLDB test format.
7379
sys.path.append(os.path.join(config.lldb_src_root, "lit", "Suite"))
7480
import lldbtest

lldb/lit/Suite/lit.site.cfg.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ config.host_os = "@HOST_OS@"
1515
config.host_triple = "@LLVM_HOST_TRIPLE@"
1616
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
1717
config.target_triple = "@TARGET_TRIPLE@"
18+
config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
19+
config.lldb_module_cache = "@LLDB_TEST_MODULE_CACHE_LLDB@"
20+
config.clang_module_cache = "@LLDB_TEST_MODULE_CACHE_CLANG@"
1821
config.python_executable = "@PYTHON_EXECUTABLE@"
1922
config.dotest_path = "@LLDB_SOURCE_DIR@/test/dotest.py"
2023
config.dotest_args_str = "@LLDB_DOTEST_ARGS@"

lldb/lit/helper/toolchain.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ def use_support_substitutions(config):
104104
flags += ['-L' + config.llvm_libs_dir,
105105
'-Wl,-rpath,' + config.llvm_libs_dir]
106106

107+
# The clang module cache is used for building inferiors.
108+
flags += ['-fmodules-cache-path={}'.format(config.clang_module_cache)]
109+
107110
additional_tool_dirs=[]
108111
if config.lldb_lit_tools_dir:
109112
additional_tool_dirs.append(config.lldb_lit_tools_dir)

lldb/lit/lit-lldb-init.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
settings set symbols.enable-external-lookup false
33
settings set plugin.process.gdb-remote.packet-timeout 60
44
settings set interpreter.echo-comment-commands false
5+
settings set symbols.clang-modules-cache-path "@LLDB_TEST_MODULE_CACHE_LLDB@"

lldb/lit/lit.cfg.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,10 @@ def calculate_arch_features(arch_string):
6464
('--targets-built', calculate_arch_features)
6565
])
6666

67-
# Clean the module caches in the test build directory. This is
68-
# necessary in an incremental build whenever clang changes underneath,
69-
# so doing it once per lit.py invocation is close enough.
70-
71-
for i in ['module-cache-clang', 'module-cache-lldb']:
72-
cachedir = os.path.join(config.lldb_libs_dir, '..',
73-
'lldb-test-build.noindex', i)
67+
# Clean the module caches in the test build directory. This is necessary in an
68+
# incremental build whenever clang changes underneath, so doing it once per
69+
# lit.py invocation is close enough.
70+
for cachedir in [config.clang_module_cache, config.lldb_module_cache]:
7471
if os.path.isdir(cachedir):
7572
print("Deleting module cache at %s."%cachedir)
7673
shutil.rmtree(cachedir)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ config.have_zlib = @LLVM_ENABLE_ZLIB@
1818
config.host_triple = "@LLVM_HOST_TRIPLE@"
1919
config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
2020
config.lldb_disable_python = @LLDB_DISABLE_PYTHON@
21+
config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
22+
config.lldb_module_cache = "@LLDB_TEST_MODULE_CACHE_LLDB@"
23+
config.clang_module_cache = "@LLDB_TEST_MODULE_CACHE_CLANG@"
2124

2225
# Support substitution of the tools and libs dirs with user parameters. This is
2326
# used when we can't determine the tool dir at configuration time.

lldb/packages/Python/lldbsuite/test/configuration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@
106106
# The base directory in which the tests are being built.
107107
test_build_dir = None
108108

109+
# The clang module cache directory used by lldb.
110+
module_cache_dir = None
111+
109112
# The only directory to scan for tests. If multiple test directories are
110113
# specified, and an exclusive test subdirectory is specified, the latter option
111114
# takes precedence.

0 commit comments

Comments
 (0)