Skip to content

Commit 116b307

Browse files
Merge pull request #6900 from apple/bugfix/test-presets
[cherry-pick][swift/release/5.9] [lldb][cmake] Allow specifying custom libcxx for tests in standalone builds
2 parents a93e6b3 + dbd0474 commit 116b307

File tree

13 files changed

+84
-19
lines changed

13 files changed

+84
-19
lines changed

lldb/cmake/modules/LLDBStandalone.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR} CACHE PATH "Path to LLVM source
2525
set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
2626
set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR} CACHE PATH "Path to LLVM build tree")
2727

28+
set(LLDB_TEST_LIBCXX_ROOT_DIR "${LLVM_BINARY_DIR}" CACHE PATH
29+
"The build root for libcxx. Used in standalone builds to point the API tests to a custom build of libcxx.")
30+
2831
set(LLVM_LIT_ARGS "-sv" CACHE STRING "Default options for lit")
2932

3033
set(lit_file_name "llvm-lit")

lldb/packages/Python/lldbsuite/test/builders/builder.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,12 @@ def getModuleCacheSpec(self):
135135

136136
def getLibCxxArgs(self):
137137
if configuration.libcxx_include_dir and configuration.libcxx_library_dir:
138-
return ["LIBCPP_INCLUDE_DIR={}".format(configuration.libcxx_include_dir),
139-
"LIBCPP_LIBRARY_DIR={}".format(configuration.libcxx_library_dir)]
138+
libcpp_args = ["LIBCPP_INCLUDE_DIR={}".format(configuration.libcxx_include_dir),
139+
"LIBCPP_LIBRARY_DIR={}".format(configuration.libcxx_library_dir)]
140+
if configuration.libcxx_include_target_dir:
141+
libcpp_args.append("LIBCPP_INCLUDE_TARGET_DIR={}".format(
142+
configuration.libcxx_include_target_dir))
143+
return libcpp_args
140144
return []
141145

142146
def getLLDBSwiftLibs(self):

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
lldb_libs_dir = None
132132

133133
libcxx_include_dir = None
134+
libcxx_include_target_dir = None
134135
libcxx_library_dir = None
135136

136137
# A plugin whose tests will be enabled, like intel-pt.

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,17 +280,15 @@ def parseOptionsAndInitTestdirs():
280280
logging.warning('No valid FileCheck executable; some tests may fail...')
281281
logging.warning('(Double-check the --llvm-tools-dir argument to dotest.py)')
282282

283-
configuration.libcxx_include_dir = args.libcxx_include_dir
284-
configuration.libcxx_library_dir = args.libcxx_library_dir
285283
if args.libcxx_include_dir or args.libcxx_library_dir:
286284
if args.lldb_platform_name:
287285
logging.warning('Custom libc++ is not supported for remote runs: ignoring --libcxx arguments')
288-
elif args.libcxx_include_dir and args.libcxx_library_dir:
289-
configuration.libcxx_include_dir = args.libcxx_include_dir
290-
configuration.libcxx_library_dir = args.libcxx_library_dir
291-
else:
286+
elif not (args.libcxx_include_dir and args.libcxx_library_dir):
292287
logging.error('Custom libc++ requires both --libcxx-include-dir and --libcxx-library-dir')
293288
sys.exit(-1)
289+
configuration.libcxx_include_dir = args.libcxx_include_dir
290+
configuration.libcxx_include_target_dir = args.libcxx_include_target_dir
291+
configuration.libcxx_library_dir = args.libcxx_library_dir
294292

295293
if args.channels:
296294
lldbtest_config.channels = args.channels

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ def create_parser():
4747
if sys.platform == 'darwin':
4848
group.add_argument('--apple-sdk', metavar='apple_sdk', dest='apple_sdk', default="", help=textwrap.dedent(
4949
'''Specify the name of the Apple SDK (macosx, macosx.internal, iphoneos, iphoneos.internal, or path to SDK) and use the appropriate tools from that SDK's toolchain.'''))
50-
group.add_argument('--libcxx-include-dir', help=textwrap.dedent('Specify the path to a custom libc++ include directory. Must be used in conjunction with --libcxx-library-dir.'))
51-
group.add_argument('--libcxx-library-dir', help=textwrap.dedent('Specify the path to a custom libc++ library directory. Must be used in conjunction with --libcxx-include-dir.'))
50+
group.add_argument('--libcxx-include-dir', help=textwrap.dedent(
51+
'Specify the path to a custom libc++ include directory. Must be used in conjunction with --libcxx-library-dir.'))
52+
group.add_argument('--libcxx-include-target-dir', help=textwrap.dedent(
53+
'Specify the path to a custom libc++ include target directory to use in addition to --libcxx-include-dir. Optional.'))
54+
group.add_argument('--libcxx-library-dir', help=textwrap.dedent(
55+
'Specify the path to a custom libc++ library directory. Must be used in conjunction with --libcxx-include-dir.'))
5256
# FIXME? This won't work for different extra flags according to each arch.
5357
group.add_argument(
5458
'-E',

lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,10 @@ endif
482482
ifeq (1,$(USE_LIBCPP))
483483
ifneq ($(and $(LIBCPP_INCLUDE_DIR), $(LIBCPP_LIBRARY_DIR)),)
484484
CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(LIBCPP_INCLUDE_DIR)
485-
LDFLAGS += -L$(LLVM_LIBS_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++
485+
ifneq "$(LIBCPP_INCLUDE_TARGET_DIR)" ""
486+
CXXFLAGS += -cxx-isystem $(LIBCPP_INCLUDE_TARGET_DIR)
487+
endif
488+
LDFLAGS += -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++
486489
else
487490
ifeq "$(OS)" "Android"
488491
# Nothing to do, this is already handled in
@@ -504,7 +507,10 @@ endif
504507
ifeq ($(or $(USE_LIBSTDCPP), $(USE_LIBCPP), $(USE_SYSTEM_STDLIB)),)
505508
ifneq ($(and $(LIBCPP_INCLUDE_DIR), $(LIBCPP_LIBRARY_DIR)),)
506509
CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(LIBCPP_INCLUDE_DIR)
507-
LDFLAGS += -L$(LLVM_LIBS_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++
510+
ifneq "$(LIBCPP_INCLUDE_TARGET_DIR)" ""
511+
CXXFLAGS += -cxx-isystem $(LIBCPP_INCLUDE_TARGET_DIR)
512+
endif
513+
LDFLAGS += -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++
508514
endif
509515
endif
510516

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def check_foo(self):
2828
children=self.check_string_vec_children())
2929

3030
@add_test_categories(["libc++"])
31-
@skipIf(bugnumber="rdar://109455906") # The standalone build of LLDB doesn't test against custom libcxx builds
3231
def test_with_run_command(self):
3332
"""Test that std::ranges::ref_view is formatted correctly when printed.
3433
"""

lldb/test/API/lang/cpp/std-function-step-into-callable/TestStdFunctionStepIntoCallable.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class LibCxxFunctionSteppingIntoCallableTestCase(TestBase):
1414

1515
NO_DEBUG_INFO_TESTCASE = True
1616

17+
@skipIfDarwin
1718
@add_test_categories(["libc++"])
1819
def test(self):
1920
"""Test that std::function as defined by libc++ is correctly printed by LLDB"""

lldb/test/API/lit.cfg.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,11 @@ def delete_module_cache(path):
181181
# If we have a just-built libcxx, prefer it over the system one.
182182
if is_configured('has_libcxx') and config.has_libcxx:
183183
if platform.system() != 'Windows':
184-
if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
185-
dotest_cmd += ['--libcxx-include-dir', os.path.join(config.llvm_include_dir, 'c++', 'v1')]
186-
dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
184+
if is_configured('libcxx_include_dir') and is_configured('libcxx_libs_dir'):
185+
dotest_cmd += ['--libcxx-include-dir', config.libcxx_include_dir]
186+
if is_configured('libcxx_include_target_dir'):
187+
dotest_cmd += ['--libcxx-include-target-dir', config.libcxx_include_target_dir]
188+
dotest_cmd += ['--libcxx-library-dir', config.libcxx_libs_dir]
187189

188190
# Forward ASan-specific environment variables to tests, as a test may load an
189191
# ASan-ified dylib.

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ config.test_compiler = lit_config.substitute('@LLDB_TEST_COMPILER@')
3333
config.test_swift_compiler = lit_config.substitute('@LLDB_SWIFTC@')
3434
config.dsymutil = lit_config.substitute('@LLDB_TEST_DSYMUTIL@')
3535
config.has_libcxx = @LLDB_HAS_LIBCXX@
36+
config.libcxx_libs_dir = "@LIBCXX_LIBRARY_DIR@"
37+
config.libcxx_include_dir = "@LIBCXX_GENERATED_INCLUDE_DIR@"
38+
config.libcxx_include_target_dir = "@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@"
3639
# The API tests use their own module caches.
3740
config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-api")
3841
config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-api")

0 commit comments

Comments
 (0)