[all-commits] [llvm/llvm-project] fb1582: [libc++] Disable coverage with sanitize-coverage=0

bungeman via All-commits all-commits at lists.llvm.org
Fri Jan 7 17:53:38 PST 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fb1582f6c54422995c6fb61ba4c55126b357f64e
  Author: Ben Wagner <bungeman at chromium.org>
  Date:   2022-01-07 (Fri, 07 Jan 2022)

  Changed paths:
    M compiler-rt/lib/fuzzer/CMakeLists.txt
    M libcxx/cmake/config-ix.cmake
    M libcxxabi/cmake/config-ix.cmake
    M libunwind/cmake/config-ix.cmake

  Log Message:
  [libc++] Disable coverage with sanitize-coverage=0

When building libcxx, libcxxabi, and libunwind the build environment may
specify any number of sanitizers. For some build feature tests these
sanitizers must be disabled to prevent spurious linking errors. With
-fsanitize= this is straight forward with -fno-sanitize=all. With
-fsanitize-coverage= there is no -fno-sanitize-coverage=all, but there
is the equivalent undocumented but tested -fsanitize-coverage=0.

The current build rules fail to disable 'trace-pc-guard'. By disabling
all sanitize-coverage flags, including 'trace-pc-guard', possible
spurious linker errors are prevented. In particular, this allows libcxx,
libcxxabi, and libunwind to be built with HonggFuzz.

CMAKE_REQUIRED_FLAGS is extra compile flags when running CMake build
configuration steps (like check_cxx_compiler_flag). It does not affect
the compile flags for the actual build of the project (unless of course
these flags change whether or not a given source compiles and links or
not). So libcxx, libcxxabi, and libunwind will still be built with any
specified sanitize-coverage as before. The build configuration steps
(which are mostly checking to see if certain compiler flags are
available) will not try to compile and link "int main() { return 0;}"
(or other specified source) with sanitize-coverage (which can fail to
link at this stage in building, since the final compile flags required
are yet to be determined).

The change to LIBFUZZER_CFLAGS was done to keep it consistent with the
obvious intention of disabling all sanitize-coverage. This appears to
be intentional, preventing the fuzzer driver itself from showing up in
any coverage calculations.

Reviewed By: #libunwind, #libc, #libc_abi, ldionne, phosek

Differential Revision: https://reviews.llvm.org/D116050

More information about the All-commits mailing list