diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index 85514cc7547a9..8c3b9c289f91a 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -186,6 +186,9 @@ cmake_dependent_option(LIBCXX_INSTALL_STATIC_LIBRARY cmake_dependent_option(LIBCXX_INSTALL_SHARED_LIBRARY "Install the shared libc++ library." ON "LIBCXX_ENABLE_SHARED;LIBCXX_INSTALL_LIBRARY" OFF) +set(LIBCXX_BUILD_CLANG_TIDY_PLUGIN_WITH_STDLIB "" CACHE STRING + "Builds the clang-tidy plugin with the specified standard library implementation. Must either be blank (use compiler default), 'libc++', or 'libstdc++'. + This should only be set when the clang-tidy binary is built with a different standard library implementation to the compiler's default choice.") option(LIBCXX_ABI_UNSTABLE "Use the unstable ABI of libc++. This is equivalent to specifying LIBCXX_ABI_VERSION=n, where n is the not-yet-stable version." OFF) if (LIBCXX_ABI_UNSTABLE) diff --git a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt index 521a60c0fc498..73f4264abee40 100644 --- a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt +++ b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt @@ -103,6 +103,17 @@ set(SOURCES ) add_library(cxx-tidy MODULE ${SOURCES}) +if(LIBCXX_BUILD_CLANG_TIDY_PLUGIN_WITH_STDLIB) + if(LIBCXX_BUILD_CLANG_TIDY_PLUGIN_WITH_STDLIB STREQUAL "libc++" OR LIBCXX_BUILD_CLANG_TIDY_PLUGIN_WITH_STDLIB STREQUAL "libstdc++") + if(CMAKE_CXX_COMPILER_ID MATCHES Clang) + target_compile_options(cxx-tidy PUBLIC -stdlib=${LIBCXX_BUILD_CLANG_TIDY_PLUGIN_WITH_STDLIB}) + else() + message(ERROR "LIBCXX_BUILD_CLANG_TIDY_PLUGIN_WITH_STDLIB can only be set with Clang or AppleClang (currently using ${CMAKE_CXX_COMPILER_ID}).") + endif() + else() + message(ERROR "LIBCXX_BUILD_CLANG_TIDY_PLUGIN_WITH_STDLIB must either be empty, 'libc++', or 'libstdc++' (got '${LIBCXX_BUILD_CLANG_TIDY_PLUGIN_WITH_STDLIB}').") + endif() +endif() target_link_libraries(cxx-tidy clangTidy) set_target_properties(cxx-tidy PROPERTIES diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot index 57ecf1e49dbf2..6a34b26ad42c5 100755 --- a/libcxx/utils/ci/run-buildbot +++ b/libcxx/utils/ci/run-buildbot @@ -20,25 +20,34 @@ cat < -[-h|--help] Display this help and exit. +[-h|--help] Display this help and exit. ---llvm-root Path to the root of the LLVM monorepo. By default, we try - to figure it out based on the current working directory. +--llvm-root Path to the root of the LLVM monorepo. By default, we try + to figure it out based on the current working directory. ---build-dir The directory to use for building the library. By default, - this is '/build/'. +--build-dir The directory to use for building the library. By default, + this is '/build/'. + +--clang-tidy-stdlib Builds the clang-tidy plugin with the specified standard + library implementation. By default, this is empty. Valid + options are empty, 'libc++', and 'libstdc++'. You should + only set this option when clang-tidy needs to be linked + against a different standard library implementation to + the compiler's default choice. + + This option only works for Clang. Environment variables -CC The C compiler to use, this value is used by CMake. This - variable is optional. +CC The C compiler to use, this value is used by CMake. This + variable is optional. -CXX The C++ compiler to use, this value is used by CMake. This - variable is optional. +CXX The C++ compiler to use, this value is used by CMake. This + variable is optional. -CMAKE The CMake binary to use. This variable is optional. +CMAKE The CMake binary to use. This variable is optional. -CLANG_FORMAT The clang-format binary to use when generating the format - ignore list. +CLANG_FORMAT The clang-format binary to use when generating the format + ignore list. EOF } @@ -62,6 +71,10 @@ while [[ $# -gt 0 ]]; do BUILD_DIR="${2}" shift; shift ;; + --clang-tidy-stdlib) + BUILD_CLANG_TIDY_PLUGIN_WITH_STDLIB="${2}" + shift; shift + ;; *) BUILDER="${1}" shift @@ -136,6 +149,7 @@ function generate-cmake-base() { -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ -DLIBCXX_ENABLE_WERROR=YES \ + -DLIBCXX_BUILD_CLANG_TIDY_PLUGIN_WITH_STDLIB="${BUILD_CLANG_TIDY_PLUGIN_WITH_STDLIB}" \ -DLIBCXXABI_ENABLE_WERROR=YES \ -DLIBUNWIND_ENABLE_WERROR=YES \ -DCMAKE_INSTALL_MESSAGE=NEVER \