[llvm] e9b4113 - Add a flag that controls if clang-tidy and clang-include-fixer are built into libclang.
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Fri May 8 08:41:56 PDT 2020
Author: Nico Weber
Date: 2020-05-08T11:41:45-04:00
New Revision: e9b4113902850667e4e96b0aabe158b87670d051
URL: https://github.com/llvm/llvm-project/commit/e9b4113902850667e4e96b0aabe158b87670d051
DIFF: https://github.com/llvm/llvm-project/commit/e9b4113902850667e4e96b0aabe158b87670d051.diff
LOG: Add a flag that controls if clang-tidy and clang-include-fixer are built into libclang.
Based on the discussion on D55415, also make the flag default to false.
Having libclang depend on clang-tools-extra means check-clang builds all
of clang-tools-extra, which besides being a layering violation takes
quite some time, since clang-tools-extra has many files that are slow
to compile.
Longer term, we likely will want to remove this flag completely. If
people need this functionality, maybe there could be a
libclang-tools-extra that's libclang + clang-tidy and
clang-includes-fixer linked in.
Differential Revision: https://reviews.llvm.org/D79599
Added:
Modified:
clang/docs/ReleaseNotes.rst
clang/tools/libclang/CMakeLists.txt
llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a35c966a8b4f..20d2240a6078 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -240,7 +240,11 @@ Build System Changes
These are major changes to the build system that have happened since the 10.0.0
release of Clang. Users of the build system should adjust accordingly.
-- ...
+- clang-tidy and clang-include-fixer are no longer compiled into libclang by
+ default. You can set ``LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA=ON`` to undo that,
+ but it's expected that that setting will go away eventually. If this is
+ something you need, please reach out to the mailing list to discuss possible
+ ways forward.
AST Matchers
------------
diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt
index 4f0eec9e6016..ba286b672772 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -50,13 +50,20 @@ if (CLANG_ENABLE_ARCMT)
list(APPEND LIBS clangARCMigrate)
endif ()
-if (TARGET clangTidyPlugin)
- add_definitions(-DCLANG_TOOL_EXTRA_BUILD)
- list(APPEND LIBS clangTidyPlugin)
- list(APPEND LIBS clangIncludeFixerPlugin)
- if(LLVM_ENABLE_MODULES)
- list(APPEND LLVM_COMPILE_FLAGS "-fmodules-ignore-macro=CLANG_TOOL_EXTRA_BUILD")
- endif()
+option(LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA
+ "Include code from clang-tools-extra in libclang." OFF)
+
+if (LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA)
+ if (TARGET clangTidyPlugin)
+ add_definitions(-DCLANG_TOOL_EXTRA_BUILD)
+ list(APPEND LIBS clangTidyPlugin)
+ list(APPEND LIBS clangIncludeFixerPlugin)
+ if(LLVM_ENABLE_MODULES)
+ list(APPEND LLVM_COMPILE_FLAGS "-fmodules-ignore-macro=CLANG_TOOL_EXTRA_BUILD")
+ endif()
+ else ()
+ message(FATAL_ERROR "LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA needs clang-tools-extra in LLVM_ENABLE_PROJECTS")
+ endif ()
endif ()
find_library(DL_LIBRARY_PATH dl)
diff --git a/llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn b/llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn
index 42f4945cf85c..04c82ebdba29 100644
--- a/llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn
@@ -9,6 +9,11 @@ import("//llvm/version.gni")
# in the CMake build), so libclang is always a static library on linux
# - the GN build doesn't have LIBCLANG_BUILD_STATIC
+declare_args() {
+ # Whether to include code from clang-tools-extra in libclang.
+ libclang_include_clang_tools_extra = false
+}
+
libclang_target_type = "shared_library"
if (host_os != "win" && host_os != "mac") {
# ELF targets need -fPIC to build shared libs but they aren't on by default.
@@ -41,9 +46,7 @@ target(libclang_target_type, "libclang") {
# FIXME: Once the GN build has a way to select which bits to build,
# only include this dependency if clang-tools-extra is part of the build.
- # FIXME: libclang depending on anything in clang-tools-extra seems like
- # a layering violation.
- if (true) {
+ if (libclang_include_clang_tools_extra) {
defines += [ "CLANG_TOOL_EXTRA_BUILD" ]
deps += [
"//clang-tools-extra/clang-include-fixer/plugin",
More information about the llvm-commits
mailing list