[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-16 Thread Jameson Nash via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9d59cfc67ead: clang-analyzer plugins require 
LLVM_ENABLE_PLUGINS also (authored by vtjnash).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119591/new/

https://reviews.llvm.org/D119591

Files:
  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

Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -95,7 +95,7 @@
   )
 endif ()
 
-if (CLANG_BUILD_EXAMPLES)
+if(CLANG_BUILD_EXAMPLES AND CLANG_PLUGIN_SUPPORT)
   list(APPEND CLANG_TEST_DEPS
 Attribute
 AnnotateFunctions
@@ -145,8 +145,8 @@
   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
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ 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)
Index: clang/examples/PrintFunctionNames/CMakeLists.txt
===
--- clang/examples/PrintFunctionNames/CMakeLists.txt
+++ clang/examples/PrintFunctionNames/CMakeLists.txt
@@ -11,7 +11,7 @@
 
 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
   )
Index: clang/examples/PluginsOrder/CMakeLists.txt
===
--- clang/examples/PluginsOrder/CMakeLists.txt
+++ 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
   )
Index: clang/examples/CallSuperAttribute/CMakeLists.txt
===
--- clang/examples/CallSuperAttribute/CMakeLists.txt
+++ 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
   )
Index: clang/examples/CMakeLists.txt
===
--- clang/examples/CMakeLists.txt
+++ clang/examples/CMakeLists.txt
@@ -3,8 +3,10 @@
   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()
Index: clang/examples/Attribute/CMakeLists.txt
===
--- clang/examples/Attribute/CMakeLists.txt
+++ 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
Index: clang/examples/AnnotateFunctions/CMakeLists.txt
===
--- clang/examples/AnnotateFunctions/CMakeLists.txt
+++ 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
   )
Index: clang/CMakeLists.txt

[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-16 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham accepted this revision.
simon_tatham added a comment.
This revision is now accepted and ready to land.

LGTM this time. Thanks very much for the rework!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119591/new/

https://reviews.llvm.org/D119591

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-16 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

Okay, this should work now for those cases! Sorry, I kept thinking it was 
clang/examples that was broken, and missed that it was clang/test that was 
failing, so I failed to see what I needed to fix there too, so that we were not 
trying to build the tests in configurations where the functionality is disabled.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119591/new/

https://reviews.llvm.org/D119591

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-16 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 409241.
vtjnash added a comment.

add one more missing case to check


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119591/new/

https://reviews.llvm.org/D119591

Files:
  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

Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -95,7 +95,7 @@
   )
 endif ()
 
-if (CLANG_BUILD_EXAMPLES)
+if(CLANG_BUILD_EXAMPLES AND CLANG_PLUGIN_SUPPORT)
   list(APPEND CLANG_TEST_DEPS
 Attribute
 AnnotateFunctions
@@ -145,8 +145,8 @@
   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
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ 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)
Index: clang/examples/PrintFunctionNames/CMakeLists.txt
===
--- clang/examples/PrintFunctionNames/CMakeLists.txt
+++ clang/examples/PrintFunctionNames/CMakeLists.txt
@@ -11,7 +11,7 @@
 
 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
   )
Index: clang/examples/PluginsOrder/CMakeLists.txt
===
--- clang/examples/PluginsOrder/CMakeLists.txt
+++ 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
   )
Index: clang/examples/CallSuperAttribute/CMakeLists.txt
===
--- clang/examples/CallSuperAttribute/CMakeLists.txt
+++ 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
   )
Index: clang/examples/CMakeLists.txt
===
--- clang/examples/CMakeLists.txt
+++ clang/examples/CMakeLists.txt
@@ -3,8 +3,10 @@
   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()
Index: clang/examples/Attribute/CMakeLists.txt
===
--- clang/examples/Attribute/CMakeLists.txt
+++ 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
Index: clang/examples/AnnotateFunctions/CMakeLists.txt
===
--- clang/examples/AnnotateFunctions/CMakeLists.txt
+++ 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
   )
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ 

[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-15 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

I ran another test of this patch, by trying the cross product of the following 
cmake configuration choices (on a build targeting Windows, with 
`LLVM_ENABLE_PROJECTS=clang`):

- `LLVM_EXPORT_SYMBOLS_FOR_PLUGINS` set to each of `ON` and `OFF`
- `CLANG_BUILD_EXAMPLES` set to each of `ON` and `OFF`
- `CLANG_PLUGIN_SUPPORT` set to each of `ON` and `OFF`

3 of those 8 cases failed.

- export-symbols OFF, build-examples ON, plugin-support OFF
- export-symbols OFF, build-examples ON, plugin-support ON
- export-symbols ON, build-examples ON, plugin-support OFF (which is the 
configuration we're currently using downstream)

In all three cases, I saw errors such as this (suggesting that a plugin is 
being added to the list of things to test even though it wasn't built):

  CMake Error at cmake/modules/AddLLVM.cmake:1821 (add_dependencies):
The dependency target "AnnotateFunctions" of target "check-all" does not
exist.
  Call Stack (most recent call first):
CMakeLists.txt:1134 (add_lit_target)

Perhaps not all of the 8 configurations in this cross product are actually 
sensible? But if one of them is not sensible, it would be better to get a clear 
error message saying why, than to have to debug things like the above.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119591/new/

https://reviews.llvm.org/D119591

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-14 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 408498.
vtjnash added a comment.

fixup


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119591/new/

https://reviews.llvm.org/D119591

Files:
  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

Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -145,8 +145,8 @@
   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
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ 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)
Index: clang/examples/PrintFunctionNames/CMakeLists.txt
===
--- clang/examples/PrintFunctionNames/CMakeLists.txt
+++ clang/examples/PrintFunctionNames/CMakeLists.txt
@@ -11,7 +11,7 @@
 
 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
   )
Index: clang/examples/PluginsOrder/CMakeLists.txt
===
--- clang/examples/PluginsOrder/CMakeLists.txt
+++ 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
   )
Index: clang/examples/CallSuperAttribute/CMakeLists.txt
===
--- clang/examples/CallSuperAttribute/CMakeLists.txt
+++ 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
   )
Index: clang/examples/CMakeLists.txt
===
--- clang/examples/CMakeLists.txt
+++ clang/examples/CMakeLists.txt
@@ -3,8 +3,10 @@
   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()
Index: clang/examples/Attribute/CMakeLists.txt
===
--- clang/examples/Attribute/CMakeLists.txt
+++ 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
Index: clang/examples/AnnotateFunctions/CMakeLists.txt
===
--- clang/examples/AnnotateFunctions/CMakeLists.txt
+++ 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
   )
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -476,9 +476,14 @@
 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)

[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-14 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

We are not going to start exporting plugin support if the user explicitly 
disabled it with CLANG_PLUGIN_SUPPORT=OFF, but why is it trying to read that 
directory at all, when it should be disallowed by this PR unless 
CLANG_PLUGIN_SUPPORT=ON


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119591/new/

https://reviews.llvm.org/D119591

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-14 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 408491.
vtjnash added a comment.

cleanup


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119591/new/

https://reviews.llvm.org/D119591

Files:
  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

Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -145,8 +145,8 @@
   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
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ 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)
Index: clang/examples/PrintFunctionNames/CMakeLists.txt
===
--- clang/examples/PrintFunctionNames/CMakeLists.txt
+++ clang/examples/PrintFunctionNames/CMakeLists.txt
@@ -11,7 +11,7 @@
 
 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
   )
Index: clang/examples/PluginsOrder/CMakeLists.txt
===
--- clang/examples/PluginsOrder/CMakeLists.txt
+++ 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
   )
Index: clang/examples/CallSuperAttribute/CMakeLists.txt
===
--- clang/examples/CallSuperAttribute/CMakeLists.txt
+++ 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
   )
Index: clang/examples/CMakeLists.txt
===
--- clang/examples/CMakeLists.txt
+++ clang/examples/CMakeLists.txt
@@ -3,8 +3,10 @@
   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()
Index: clang/examples/Attribute/CMakeLists.txt
===
--- clang/examples/Attribute/CMakeLists.txt
+++ 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
Index: clang/examples/AnnotateFunctions/CMakeLists.txt
===
--- clang/examples/AnnotateFunctions/CMakeLists.txt
+++ 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
   )
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -476,9 +476,10 @@
 option(CLANG_BUILD_TOOLS
   "Build the Clang tools. If OFF, just generate build targets." ON)
 
+set(HAVE_CLANG_PLUGIN_SUPPORT LLVM_ENABLE_PLUGINS OR LLVM_EXPORT_SYMBOLS_FOR_PLUGINS)
 

[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-14 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

I gave this patch a test against our downstream code, and found that it doesn't 
stop me needing the change I suggested in D119199 
: in `clang/tools/driver/CMakeLists.txt`, I 
had to change

  if(CLANG_PLUGIN_SUPPORT)
export_executable_symbols_for_plugins(clang)
  endif()
  ``` so that the if statement reads
  ```if(CLANG_PLUGIN_SUPPORT OR LLVM_EXPORT_SYMBOLS_FOR_PLUGINS)

because otherwise, the clang/examples builds will still try to link against the 
clang executable target, which needs its symbols to have been exported.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119591/new/

https://reviews.llvm.org/D119591

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119591: clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-11 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash created this revision.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware, mgorny.
vtjnash requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119591

Files:
  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

Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -145,8 +145,8 @@
   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
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ 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)
Index: clang/examples/PrintFunctionNames/CMakeLists.txt
===
--- clang/examples/PrintFunctionNames/CMakeLists.txt
+++ clang/examples/PrintFunctionNames/CMakeLists.txt
@@ -11,7 +11,7 @@
 
 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
   )
Index: clang/examples/PluginsOrder/CMakeLists.txt
===
--- clang/examples/PluginsOrder/CMakeLists.txt
+++ 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
   )
Index: clang/examples/CallSuperAttribute/CMakeLists.txt
===
--- clang/examples/CallSuperAttribute/CMakeLists.txt
+++ 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
   )
Index: clang/examples/CMakeLists.txt
===
--- clang/examples/CMakeLists.txt
+++ clang/examples/CMakeLists.txt
@@ -3,8 +3,10 @@
   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()
Index: clang/examples/Attribute/CMakeLists.txt
===
--- clang/examples/Attribute/CMakeLists.txt
+++ 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
Index: clang/examples/AnnotateFunctions/CMakeLists.txt
===
--- clang/examples/AnnotateFunctions/CMakeLists.txt
+++ clang/examples/AnnotateFunctions/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(AnnotateFunctions MODULE AnnotateFunctions.cpp PLUGIN_TOOL clang)