Skip to content

Commit 8c3c90e

Browse files
committed
[lldb][cmake] Allow specifying custom libcxx for tests in standalone builds
Standalone builds currently do not set the `LLDB_HAS_LIBCXX`, `LIBCXX_LIBRARY_DIR`, `LIBCXX_GENERATED_INCLUDE_DIR`. These are necessary for API tests with `USE_LIBCPP` to run against a custom built libcxx. Thus on all buildbots using standalone builds (most notably the public swift-ci), the API tests always run against the libcxx headers in the system SDK. This patch introduces a new cmake variable `LLDB_TEST_LIBCXX_ROOT_DIR` that allows us to point the tests in standalone builds to a custom libcxx directory. Since the user can control the libcxx location we can hard error if no such custom libcxx build exists. Differential Revision: https://reviews.llvm.org/D150954 (cherry picked from commit 2901ce3ac24799dacda21be3903d6d8294b70ea0)
1 parent e90aea6 commit 8c3c90e

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
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/test/CMakeLists.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,18 @@ if(TARGET clang)
142142
# FIXME: Standalone builds should import the cxx target as well.
143143
if(LLDB_BUILT_STANDALONE)
144144
# For now check that the include directory exists.
145-
set(cxx_dir "${LLVM_BINARY_DIR}/include/c++")
146-
if(NOT EXISTS ${cxx_dir})
147-
message(WARNING "LLDB test suite requires libc++ in llvm/projects/libcxx or an existing build symlinked to ${cxx_dir}")
145+
set(cxx_dir "${LLDB_TEST_LIBCXX_ROOT_DIR}/include/c++")
146+
if(EXISTS ${cxx_dir})
147+
# These variables make sure the API tests can run against a custom
148+
# build of libcxx even for standalone builds.
149+
set(LLDB_HAS_LIBCXX ON)
150+
set(LIBCXX_LIBRARY_DIR "${LLDB_TEST_LIBCXX_ROOT_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}")
151+
set(LIBCXX_GENERATED_INCLUDE_DIR "${LLDB_TEST_LIBCXX_ROOT_DIR}/include/c++/v1")
152+
else()
153+
message(FATAL_ERROR
154+
"Couldn't find libcxx build in '${LLDB_TEST_LIBCXX_ROOT_DIR}'. To run the "
155+
"test-suite for a standalone LLDB build please build libcxx and point "
156+
"LLDB_TEST_LIBCXX_ROOT_DIR to it.")
148157
endif()
149158
else()
150159
# We require libcxx for the test suite, so if we aren't building it,

0 commit comments

Comments
 (0)