diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt index 0a1ca5cf391ef..c3711aac4a75c 100644 --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -26,6 +26,7 @@ endif() include(GNUInstallDirs) option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS}) +option(LLDB_ENABLE_LIBCXX_TESTS "Set to OFF to acknowledge that libc++ is intentionally not built in-tree and silence the missing-libc++ warning." ON) if(LLDB_BUILT_STANDALONE) set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to") diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index f1abc4b63db0e..888d980e398d3 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -802,9 +802,14 @@ def canRunLibcxxTests(): platform = lldbplatformutil.getPlatform() - if lldbplatformutil.target_is_android() or lldbplatformutil.platformIsDarwin(): + if lldbplatformutil.target_is_android(): return True, "libc++ always present" + if lldbplatformutil.platformIsDarwin(): + if not configuration.libcxx_include_dir or not configuration.libcxx_library_dir: + return False, "libc++ tests require a locally built libc++" + return True, "libc++ present" + if platform == "linux": if not configuration.libcxx_include_dir or not configuration.libcxx_library_dir: return False, "API tests require a locally built libc++." diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt index d5e4377648da8..0a5c3b99f0cc5 100644 --- a/lldb/test/CMakeLists.txt +++ b/lldb/test/CMakeLists.txt @@ -205,13 +205,15 @@ if(TARGET clang) "LLDB_TEST_LIBCXX_ROOT_DIR to it.") endif() else() - # We require libcxx for the test suite, so if we aren't building it, - # provide a helpful error about how to resolve the situation. - if(NOT LLDB_HAS_LIBCXX) - message(SEND_ERROR - "LLDB test suite requires libc++, but it is currently disabled. " - "Please add `libcxx` to `LLVM_ENABLE_RUNTIMES` or disable tests via " - "`LLDB_INCLUDE_TESTS=OFF`.") + # The LLDB test suite uses libc++ for many tests. If it isn't being + # built in-tree, tests in the "libc++" category will be skipped + # (same behavior as Linux). + if(NOT LLDB_HAS_LIBCXX AND LLDB_ENABLE_LIBCXX_TESTS) + message(WARNING + "LLDB's libc++ specific tests will be skipped. Add `libcxx` to " + "`LLVM_ENABLE_RUNTIMES` to get full coverage, set " + "`LLDB_ENABLE_LIBCXX_TESTS=OFF` to silence this warning, or disable " + "all tests with `LLDB_INCLUDE_TESTS=OFF`.") endif() endif() endif()