[PATCH] D20558: [LibFuzzer] Start cleaning up the CMakeLists.txt files.
Dan Liew via llvm-commits
llvm-commits at lists.llvm.org
Mon May 23 22:07:26 PDT 2016
delcypher added a comment.
@kcc : This probably isn't ready to go quite yet as I have some questions whose answers will change this patch.
1. How is CMake supposed to be configured when the intention is to build libFuzzer and its tests? In the end I found doing
CC=/path/to/recent/clang CXX=/path/to/recent/clang++ cmake -DLLVM_USE_SANITIZE_COVERAGE=ON -DLLVM_USE_SANITIZER=Address /path/to/llvm/src/root
seemed to work and the tests would pass under Linux with this patch. Is that the intended way of configuring/building?
2. It is possible to build libFuzzer and the tests **without** `-DLLVM_USE_SANITIZER=Address` being passed to CMake but when I do that the additional flags `-fsanitize-coverage=edge,indirect-calls,8bit-counters,trace-cmp` (from `HandleLLVMOptions.cmake`) don't get given put in `CMAKE_CXX_FLAGS`. It looks like the previous CMake code implicitly assumed those flags were set. This cause a great deal of confusion for me as I tried configuring without `-DLLVM_USE_SANITIZER=Address` when writing the patch hence some of the `FIXME`s. The reason it's so confusing is that in some places `-fsanitize-coverage=` gets explicitly set (i.e in `/lib/Fuzzer/CMakeLists.txt`) but in other places it is implicitly assumed that `-fsanitize-coverage=` has been set.
This patch hasn't tried to fix this but I think we need to. We either need to disallow building libFuzzer without `LLVM_USE_SANITIZER` being set appropriately (not my preferred approach), or we need to make setting the `-fsanitize-coverage=` flag always explicit in the LibFuzzer and tests `CMakeLists.txt` files.
Another thing worth considering is that without `-fsanitize=address` using `-fsanitize-coverage=` does absolutely nothing and clang just emits a warning that the flag is unused. This won't cause a build failure but the tests will obviously fail.
Considering the above may I should do both, i.e. be explicit about what `-fsanitize-coverage=` is being set to and also deny building LibFuzzer without a sanitizer being enabled. Thoughts?
3. The CMakeLists files use flags that gcc doesn't understand. Is that intentional?
http://reviews.llvm.org/D20558
More information about the llvm-commits
mailing list