Author: Jameson Nash Date: 2022-02-16T11:59:09-05:00 New Revision: 9d59cfc67eadbe4b4088d70f8bbc61c96568d2f1
URL: https://github.com/llvm/llvm-project/commit/9d59cfc67eadbe4b4088d70f8bbc61c96568d2f1 DIFF: https://github.com/llvm/llvm-project/commit/9d59cfc67eadbe4b4088d70f8bbc61c96568d2f1.diff LOG: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also The clang-analyzer plugins are not linked to a particular tool, so they can only be compiled if plugins are broadly supported. We could opt instead to decide whether to link them to specifically against clang or with undefined symbols, depending on the value of LLVM_ENABLE_PLUGINS, but we do not currently expect there to be a use case for that rather niche configuration. Differential Revision: https://reviews.llvm.org/D119591 Added: Modified: clang/CMakeLists.txt clang/examples/AnnotateFunctions/CMakeLists.txt clang/examples/Attribute/CMakeLists.txt clang/examples/CMakeLists.txt clang/examples/CallSuperAttribute/CMakeLists.txt clang/examples/PluginsOrder/CMakeLists.txt clang/examples/PrintFunctionNames/CMakeLists.txt clang/lib/Analysis/plugins/CMakeLists.txt clang/test/CMakeLists.txt Removed: ################################################################################ diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 4225c028e1794..937a8467df1d7 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -476,9 +476,14 @@ add_definitions( -D_GNU_SOURCE ) option(CLANG_BUILD_TOOLS "Build the Clang tools. If OFF, just generate build targets." ON) +if(LLVM_ENABLE_PLUGINS OR LLVM_EXPORT_SYMBOLS_FOR_PLUGINS) + set(HAVE_CLANG_PLUGIN_SUPPORT ON) +else() + set(HAVE_CLANG_PLUGIN_SUPPORT OFF) +endif() CMAKE_DEPENDENT_OPTION(CLANG_PLUGIN_SUPPORT "Build clang with plugin support" ON - "LLVM_ENABLE_PLUGINS OR LLVM_EXPORT_SYMBOLS_FOR_PLUGINS" OFF) + "HAVE_CLANG_PLUGIN_SUPPORT" OFF) option(CLANG_ENABLE_ARCMT "Build ARCMT." ON) option(CLANG_ENABLE_STATIC_ANALYZER diff --git a/clang/examples/AnnotateFunctions/CMakeLists.txt b/clang/examples/AnnotateFunctions/CMakeLists.txt index e6541f7cc62a6..827ff79fcc410 100644 --- 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(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN)) +if(WIN32 OR CYGWIN) set(LLVM_LINK_COMPONENTS Support ) diff --git a/clang/examples/Attribute/CMakeLists.txt b/clang/examples/Attribute/CMakeLists.txt index 5392ac0df1703..770fa28364b77 100644 --- 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(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN)) +if(WIN32 OR CYGWIN) target_link_libraries(Attribute PRIVATE clangAST clangBasic diff --git a/clang/examples/CMakeLists.txt b/clang/examples/CMakeLists.txt index 4a677933bb54f..8be327bcdbb9d 100644 --- a/clang/examples/CMakeLists.txt +++ b/clang/examples/CMakeLists.txt @@ -3,8 +3,10 @@ if(NOT CLANG_BUILD_EXAMPLES) set(EXCLUDE_FROM_ALL ON) endif() -add_subdirectory(PrintFunctionNames) -add_subdirectory(AnnotateFunctions) -add_subdirectory(Attribute) -add_subdirectory(CallSuperAttribute) -add_subdirectory(PluginsOrder) +if(CLANG_PLUGIN_SUPPORT) + add_subdirectory(PrintFunctionNames) + add_subdirectory(AnnotateFunctions) + add_subdirectory(Attribute) + add_subdirectory(CallSuperAttribute) + add_subdirectory(PluginsOrder) +endif() diff --git a/clang/examples/CallSuperAttribute/CMakeLists.txt b/clang/examples/CallSuperAttribute/CMakeLists.txt index f4284adf289e3..dc832327c775d 100644 --- 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(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN)) +if(WIN32 OR CYGWIN) set(LLVM_LINK_COMPONENTS Support ) diff --git a/clang/examples/PluginsOrder/CMakeLists.txt b/clang/examples/PluginsOrder/CMakeLists.txt index 612587a6d2fe3..c22b0081ad686 100644 --- 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(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN)) +if(WIN32 OR CYGWIN) set(LLVM_LINK_COMPONENTS Support ) diff --git a/clang/examples/PrintFunctionNames/CMakeLists.txt b/clang/examples/PrintFunctionNames/CMakeLists.txt index 67f1b16744eaf..28da363729f3a 100644 --- a/clang/examples/PrintFunctionNames/CMakeLists.txt +++ b/clang/examples/PrintFunctionNames/CMakeLists.txt @@ -11,7 +11,7 @@ endif() add_llvm_library(PrintFunctionNames MODULE PrintFunctionNames.cpp PLUGIN_TOOL clang) -if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN)) +if(WIN32 OR CYGWIN) set(LLVM_LINK_COMPONENTS Support ) diff --git a/clang/lib/Analysis/plugins/CMakeLists.txt b/clang/lib/Analysis/plugins/CMakeLists.txt index 7b754ea3f2bc9..157be7e4147bc 100644 --- a/clang/lib/Analysis/plugins/CMakeLists.txt +++ b/clang/lib/Analysis/plugins/CMakeLists.txt @@ -1,4 +1,7 @@ -if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT) +# Since these do not specify a specific PLUGIN_TOOL (which could be clang or +# clang-tidy), we cannot compile this unless the platform supports plugins with +# undefined symbols, and cannot use it unless the user has opted for clang plugins). +if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT AND LLVM_ENABLE_PLUGINS) add_subdirectory(SampleAnalyzer) add_subdirectory(CheckerDependencyHandling) add_subdirectory(CheckerOptionHandling) diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt index 057797863f245..15b38478ded3b 100644 --- a/clang/test/CMakeLists.txt +++ b/clang/test/CMakeLists.txt @@ -95,7 +95,7 @@ if (CLANG_ENABLE_ARCMT) ) endif () -if (CLANG_BUILD_EXAMPLES) +if(CLANG_BUILD_EXAMPLES AND CLANG_PLUGIN_SUPPORT) list(APPEND CLANG_TEST_DEPS Attribute AnnotateFunctions @@ -145,8 +145,8 @@ if( NOT CLANG_BUILT_STANDALONE ) endif() endif() -if (CLANG_ENABLE_STATIC_ANALYZER) - if (CLANG_PLUGIN_SUPPORT) +if(CLANG_ENABLE_STATIC_ANALYZER) + if(CLANG_PLUGIN_SUPPORT AND LLVM_ENABLE_PLUGINS) # Determine if we built them list(APPEND CLANG_TEST_DEPS SampleAnalyzerPlugin CheckerDependencyHandlingAnalyzerPlugin _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits