diff --git a/clang-tools-extra/test/CMakeLists.txt b/clang-tools-extra/test/CMakeLists.txt --- a/clang-tools-extra/test/CMakeLists.txt +++ b/clang-tools-extra/test/CMakeLists.txt @@ -17,7 +17,7 @@ llvm_canonicalize_cmake_booleans( CLANG_TIDY_ENABLE_STATIC_ANALYZER - LLVM_ENABLE_PLUGINS + CLANG_PLUGIN_SUPPORT LLVM_INSTALL_TOOLCHAIN_ONLY ) @@ -87,10 +87,19 @@ PLUGIN_TOOL clang-tidy DEPENDS clang-tidy-headers) + if(CLANG_BUILT_STANDALONE) + # LLVMHello library is needed below + if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Transforms/Hello + AND NOT TARGET LLVMHello) + add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Transforms/Hello + lib/Transforms/Hello) + endif() + endif() + if(TARGET CTTestTidyModule) list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule LLVMHello) target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}") - if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) + if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN)) set(LLVM_LINK_COMPONENTS Support ) diff --git a/clang-tools-extra/test/lit.site.cfg.py.in b/clang-tools-extra/test/lit.site.cfg.py.in --- a/clang-tools-extra/test/lit.site.cfg.py.in +++ b/clang-tools-extra/test/lit.site.cfg.py.in @@ -12,7 +12,7 @@ config.python_executable = "@Python3_EXECUTABLE@" config.target_triple = "@TARGET_TRIPLE@" config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@ -config.has_plugins = @LLVM_ENABLE_PLUGINS@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@ +config.has_plugins = @CLANG_PLUGIN_SUPPORT@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@ # Support substitution of the tools and libs dirs with user parameters. This is # used when we can't determine the tool dir at configuration time. diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -476,6 +476,10 @@ option(CLANG_BUILD_TOOLS "Build the Clang tools. If OFF, just generate build targets." ON) +CMAKE_DEPENDENT_OPTION(CLANG_PLUGIN_SUPPORT + "Build clang with plugin support" ON + "LLVM_ENABLE_PLUGINS OR LLVM_EXPORT_SYMBOLS_FOR_PLUGINS" OFF) + option(CLANG_ENABLE_ARCMT "Build ARCMT." ON) option(CLANG_ENABLE_STATIC_ANALYZER "Include static analyzer in clang binary." ON) diff --git a/clang/examples/AnnotateFunctions/CMakeLists.txt b/clang/examples/AnnotateFunctions/CMakeLists.txt --- a/clang/examples/AnnotateFunctions/CMakeLists.txt +++ b/clang/examples/AnnotateFunctions/CMakeLists.txt @@ -1,6 +1,6 @@ add_llvm_library(AnnotateFunctions MODULE AnnotateFunctions.cpp PLUGIN_TOOL clang) -if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) +if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN)) set(LLVM_LINK_COMPONENTS Support ) diff --git a/clang/examples/Attribute/CMakeLists.txt b/clang/examples/Attribute/CMakeLists.txt --- a/clang/examples/Attribute/CMakeLists.txt +++ b/clang/examples/Attribute/CMakeLists.txt @@ -1,6 +1,6 @@ add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang) -if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) +if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN)) target_link_libraries(Attribute PRIVATE clangAST clangBasic diff --git a/clang/examples/CallSuperAttribute/CMakeLists.txt b/clang/examples/CallSuperAttribute/CMakeLists.txt --- a/clang/examples/CallSuperAttribute/CMakeLists.txt +++ b/clang/examples/CallSuperAttribute/CMakeLists.txt @@ -1,6 +1,6 @@ add_llvm_library(CallSuperAttr MODULE CallSuperAttrInfo.cpp PLUGIN_TOOL clang) -if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) +if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN)) set(LLVM_LINK_COMPONENTS Support ) diff --git a/clang/examples/PluginsOrder/CMakeLists.txt b/clang/examples/PluginsOrder/CMakeLists.txt --- a/clang/examples/PluginsOrder/CMakeLists.txt +++ b/clang/examples/PluginsOrder/CMakeLists.txt @@ -1,6 +1,6 @@ add_llvm_library(PluginsOrder MODULE PluginsOrder.cpp PLUGIN_TOOL clang) -if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) +if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN)) set(LLVM_LINK_COMPONENTS Support ) diff --git a/clang/examples/PrintFunctionNames/CMakeLists.txt b/clang/examples/PrintFunctionNames/CMakeLists.txt --- a/clang/examples/PrintFunctionNames/CMakeLists.txt +++ b/clang/examples/PrintFunctionNames/CMakeLists.txt @@ -11,7 +11,7 @@ add_llvm_library(PrintFunctionNames MODULE PrintFunctionNames.cpp PLUGIN_TOOL clang) -if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) +if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN)) set(LLVM_LINK_COMPONENTS Support ) diff --git a/clang/lib/Analysis/plugins/CMakeLists.txt b/clang/lib/Analysis/plugins/CMakeLists.txt --- a/clang/lib/Analysis/plugins/CMakeLists.txt +++ b/clang/lib/Analysis/plugins/CMakeLists.txt @@ -1,4 +1,4 @@ -if(CLANG_ENABLE_STATIC_ANALYZER AND LLVM_ENABLE_PLUGINS) +if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT) add_subdirectory(SampleAnalyzer) add_subdirectory(CheckerDependencyHandling) add_subdirectory(CheckerOptionHandling) diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt --- a/clang/test/CMakeLists.txt +++ b/clang/test/CMakeLists.txt @@ -14,12 +14,12 @@ CLANG_DEFAULT_PIE_ON_LINUX CLANG_ENABLE_ARCMT CLANG_ENABLE_STATIC_ANALYZER + CLANG_PLUGIN_SUPPORT CLANG_SPAWN_CC1 ENABLE_BACKTRACES LLVM_ENABLE_NEW_PASS_MANAGER LLVM_ENABLE_ZLIB LLVM_ENABLE_PER_TARGET_RUNTIME_DIR - LLVM_ENABLE_PLUGINS LLVM_ENABLE_THREADS LLVM_WITH_Z3 ) @@ -146,7 +146,7 @@ endif() if (CLANG_ENABLE_STATIC_ANALYZER) - if (LLVM_ENABLE_PLUGINS) + if (CLANG_PLUGIN_SUPPORT) list(APPEND CLANG_TEST_DEPS SampleAnalyzerPlugin CheckerDependencyHandlingAnalyzerPlugin diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -34,7 +34,7 @@ config.host_arch = "@HOST_ARCH@" config.python_executable = "@Python3_EXECUTABLE@" config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@") -config.has_plugins = @LLVM_ENABLE_PLUGINS@ +config.has_plugins = @CLANG_PLUGIN_SUPPORT@ config.clang_vendor_uti = "@CLANG_VENDOR_UTI@" config.llvm_external_lit = path(r"@LLVM_EXTERNAL_LIT@") diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -17,8 +17,6 @@ Vectorize ) -option(CLANG_PLUGIN_SUPPORT "Build clang with plugin support" ON) - # Support plugins. if(CLANG_PLUGIN_SUPPORT) set(support_plugins SUPPORT_PLUGINS)