[PATCH] D20558: [LibFuzzer] Start cleaning up the CMakeLists.txt files.

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Mon May 23 22:34:00 PDT 2016


kcc added a comment.

In http://reviews.llvm.org/D20558#437483, @delcypher wrote:

> @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


Why did you have to "find" it? 
It's documented: http://llvm.org/docs/LibFuzzer.html#fuzzing-components-of-llvm

>   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.


-fsanitize-coverage flags are allowed only in combination with one of the sanitizers. 
besides, some of the libfuzzer tests actually expect asan

> 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.


Yes, that's intentional.

> 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?


Dunno. I like the current way of doing things.
Remind me, what problem are you trying to solve? (Other than allowing the non-Release build with libFuzzer)?

> 

> 

> 3. The CMakeLists files use flags that gcc doesn't understand. Is that intentional?


gcc does not have this flags, so yes, libFuzzer tests won't work with gcc.


http://reviews.llvm.org/D20558





More information about the llvm-commits mailing list