[PATCH] D67877: Conditionnaly include clang Analysis examples with cmake.

2019-09-21 Thread Jean-Bapiste Lepesme via Phabricator via cfe-commits
Jiboo created this revision.
Jiboo added a reviewer: chandlerc.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

Without this patch, the clang Analysis plugin examples (in 
clang/lib/Analysis/plugins) are always built and installed even if 
CLANG_BUILD_EXAMPLES is OFF.

When using llvm-toolchain-bionic in http://apt.llvm.org/bionic/ the package 
llvm-10-dev includes a LLVMExports.cmake which includes thus samples. See 
/data/user/lib/llvm-10/lib/cmake/llvm/LLVMExports.cmake in 
http://apt.llvm.org/bionic/pool/main/l/llvm-toolchain-snapshot/llvm-10-dev_10~svn372305-1~exp1%2b0~20190919071908.1206~1.gbp6f40e3_amd64.deb

When trying to use LLVM-10 from travis (with this config 
https://github.com/Jiboo/wembed/blob/54e9664d615313f39e1a4325c1e7f028ce2b72db/.travis.yml),
 I got the error:

CMake Error at /usr/lib/llvm-10/lib/cmake/llvm/LLVMExports.cmake:1341 (message):

  The imported target "SampleAnalyzerPlugin" references the file
 "/usr/lib/llvm-10/lib/SampleAnalyzerPlugin.so"
  but this file does not exist.  Possible reasons include:
  * The file was deleted, renamed, or moved to another location.
  * An install or uninstall procedure did not complete successfully.
  * The installation package was faulty and contained
 "/usr/lib/llvm-10/lib/cmake/llvm/LLVMExports.cmake"
  but not all the files it references.

I couldn't find SampleAnalyzerPlugin.so in any other packages 
(clang-10-examples only has sources), so I tried to replicate the problem 
locally, CLANG_BUILD_EXAMPLES was OFF, although the sample plugins were built 
and installed. Deleting /usr/local/lib/SampleAnalyzerPlugin.so replicated the 
travis error.

This fix looks ok to me, although I'm no CMake expert, particularly in LLVM 
context, and I might cure a symptom and not the cause, but with this patch if 
CLANG_BUILD_EXAMPLES is ON, they appear in LLVMExports.cmake and vice-versa.


Repository:
  rC Clang

https://reviews.llvm.org/D67877

Files:
  clang/lib/Analysis/plugins/CMakeLists.txt
  clang/test/CMakeLists.txt


Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -125,14 +125,12 @@
   endif()
 endif()
 
-if (CLANG_ENABLE_STATIC_ANALYZER)
-  if (LLVM_ENABLE_PLUGINS)
-list(APPEND CLANG_TEST_DEPS
-  SampleAnalyzerPlugin
-  CheckerDependencyHandlingAnalyzerPlugin
-  CheckerOptionHandlingAnalyzerPlugin
-  )
-  endif()
+if (CLANG_ENABLE_STATIC_ANALYZER AND CLANG_BUILD_EXAMPLES AND 
LLVM_ENABLE_PLUGINS)
+  list(APPEND CLANG_TEST_DEPS
+SampleAnalyzerPlugin
+CheckerDependencyHandlingAnalyzerPlugin
+CheckerOptionHandlingAnalyzerPlugin
+)
 endif()
 
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ 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 LLVM_ENABLE_PLUGINS AND 
CLANG_BUILD_EXAMPLES)
   add_subdirectory(SampleAnalyzer)
   add_subdirectory(CheckerDependencyHandling)
   add_subdirectory(CheckerOptionHandling)


Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -125,14 +125,12 @@
   endif()
 endif()
 
-if (CLANG_ENABLE_STATIC_ANALYZER)
-  if (LLVM_ENABLE_PLUGINS)
-list(APPEND CLANG_TEST_DEPS
-  SampleAnalyzerPlugin
-  CheckerDependencyHandlingAnalyzerPlugin
-  CheckerOptionHandlingAnalyzerPlugin
-  )
-  endif()
+if (CLANG_ENABLE_STATIC_ANALYZER AND CLANG_BUILD_EXAMPLES AND LLVM_ENABLE_PLUGINS)
+  list(APPEND CLANG_TEST_DEPS
+SampleAnalyzerPlugin
+CheckerDependencyHandlingAnalyzerPlugin
+CheckerOptionHandlingAnalyzerPlugin
+)
 endif()
 
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ 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 LLVM_ENABLE_PLUGINS AND CLANG_BUILD_EXAMPLES)
   add_subdirectory(SampleAnalyzer)
   add_subdirectory(CheckerDependencyHandling)
   add_subdirectory(CheckerOptionHandling)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67877: Conditionnaly include clang Analysis examples with cmake.

2019-09-21 Thread Jean-Bapiste Lepesme via Phabricator via cfe-commits
Jiboo updated this revision to Diff 221181.
Jiboo marked 3 inline comments as done.
Jiboo added a comment.

Update to add -U99, although dunno why I don't get more context on 
clang/lib/Analysis/plugins/CMakeLists.txt.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67877

Files:
  clang/lib/Analysis/plugins/CMakeLists.txt
  clang/test/CMakeLists.txt


Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -125,14 +125,12 @@
   endif()
 endif()
 
-if (CLANG_ENABLE_STATIC_ANALYZER)
-  if (LLVM_ENABLE_PLUGINS)
-list(APPEND CLANG_TEST_DEPS
-  SampleAnalyzerPlugin
-  CheckerDependencyHandlingAnalyzerPlugin
-  CheckerOptionHandlingAnalyzerPlugin
-  )
-  endif()
+if (CLANG_ENABLE_STATIC_ANALYZER AND CLANG_BUILD_EXAMPLES AND 
LLVM_ENABLE_PLUGINS)
+  list(APPEND CLANG_TEST_DEPS
+SampleAnalyzerPlugin
+CheckerDependencyHandlingAnalyzerPlugin
+CheckerOptionHandlingAnalyzerPlugin
+)
 endif()
 
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ 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 LLVM_ENABLE_PLUGINS AND 
CLANG_BUILD_EXAMPLES)
   add_subdirectory(SampleAnalyzer)
   add_subdirectory(CheckerDependencyHandling)
   add_subdirectory(CheckerOptionHandling)


Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -125,14 +125,12 @@
   endif()
 endif()
 
-if (CLANG_ENABLE_STATIC_ANALYZER)
-  if (LLVM_ENABLE_PLUGINS)
-list(APPEND CLANG_TEST_DEPS
-  SampleAnalyzerPlugin
-  CheckerDependencyHandlingAnalyzerPlugin
-  CheckerOptionHandlingAnalyzerPlugin
-  )
-  endif()
+if (CLANG_ENABLE_STATIC_ANALYZER AND CLANG_BUILD_EXAMPLES AND LLVM_ENABLE_PLUGINS)
+  list(APPEND CLANG_TEST_DEPS
+SampleAnalyzerPlugin
+CheckerDependencyHandlingAnalyzerPlugin
+CheckerOptionHandlingAnalyzerPlugin
+)
 endif()
 
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
Index: clang/lib/Analysis/plugins/CMakeLists.txt
===
--- clang/lib/Analysis/plugins/CMakeLists.txt
+++ 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 LLVM_ENABLE_PLUGINS AND CLANG_BUILD_EXAMPLES)
   add_subdirectory(SampleAnalyzer)
   add_subdirectory(CheckerDependencyHandling)
   add_subdirectory(CheckerOptionHandling)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67877: Conditionnaly include clang Analysis examples with cmake.

2019-09-21 Thread Jean-Bapiste Lepesme via Phabricator via cfe-commits
Jiboo added inline comments.



Comment at: clang/lib/Analysis/plugins/CMakeLists.txt:1-2
-if(CLANG_ENABLE_STATIC_ANALYZER AND LLVM_ENABLE_PLUGINS)
+if(CLANG_ENABLE_STATIC_ANALYZER AND LLVM_ENABLE_PLUGINS AND 
CLANG_BUILD_EXAMPLES)
   add_subdirectory(SampleAnalyzer)
   add_subdirectory(CheckerDependencyHandling)

lebedev.ri wrote:
> Sure it isn't just the `SampleAnalyzer` that should be wrapped into 
> `CLANG_BUILD_EXAMPLES`?
Dunno, I though they were all examples, due to their contents:

CheckerDependencyHandling: 
registry.addDependency("example.DependendentChecker", "example.Dependency");
CheckerOptionHandling: registry.addChecker(registerMyChecker, 
shouldRegisterMyChecker, "example.MyChecker", "Example Description",


Repository:
  rC Clang

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

https://reviews.llvm.org/D67877



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


[PATCH] D67877: [analyzer] Conditionnaly include clang Analysis examples with cmake.

2019-09-21 Thread Jean-Bapiste Lepesme via Phabricator via cfe-commits
Jiboo added a comment.

@Szelethus take your time, I'm surprised to be the first with the problem 
(couldn't find reference on google or llvm bug tracker), I wouldn't be 
surprised if I fucked up somewhere and that this patch isn't really necessary.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67877



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


[PATCH] D67877: [analyzer] Conditionnaly include clang Analysis examples with cmake.

2019-09-24 Thread Jean-Bapiste Lepesme via Phabricator via cfe-commits
Jiboo added a comment.

Here you go: https://bugs.llvm.org/show_bug.cgi?id=43430


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67877



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


[PATCH] D67877: [analyzer] Conditionnaly include clang Analysis examples with cmake.

2019-09-28 Thread Jean-Bapiste Lepesme via Phabricator via cfe-commits
Jiboo added a comment.

@aaronpuchert thanks, that looks like a better fix than mine for PR43430, 
although I'm not sure D68172  obsoletes this 
patch.
@Szelethus could you confirm that thus examples shouldn't be built when 
CLANG_BUILD_EXAMPLES is OFF, and that this patch is still valid?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67877



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


[PATCH] D67877: [analyzer] Conditionnaly include clang Analysis examples with cmake.

2019-09-28 Thread Jean-Bapiste Lepesme via Phabricator via cfe-commits
Jiboo abandoned this revision.
Jiboo added a comment.

Superseded by D68172 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67877



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