[compiler-rt] r369823 - Fix stack_trace_compressor builds for Clang < 6.0

Mitch Phillips via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 23 16:13:18 PDT 2019


Author: hctim
Date: Fri Aug 23 16:13:18 2019
New Revision: 369823

URL: http://llvm.org/viewvc/llvm-project?rev=369823&view=rev
Log:
Fix stack_trace_compressor builds for Clang < 6.0

Summary:
Clang 4.* doesn't supply -fsanitize=fuzzer, and Clang 5.* doesn't supply
-fsanitize=fuzzer-no-link. Generally, in LLVM, fuzz targets are added through
the add_llvm_fuzzer build rule, which can't be used in compiler-rt (as it has
to be able to be standalone built).

Instead of adding tooling to add a dummy main (which kind of defeats the
purpose of these fuzz targets), we instead build the fuzz target only when the
Clang version is >= 6.*.

Reviewers: tejohnson

Subscribers: mgorny, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

Modified:
    compiler-rt/trunk/lib/gwp_asan/CMakeLists.txt

Modified: compiler-rt/trunk/lib/gwp_asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/gwp_asan/CMakeLists.txt?rev=369823&r1=369822&r2=369823&view=diff
==============================================================================
--- compiler-rt/trunk/lib/gwp_asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/gwp_asan/CMakeLists.txt Fri Aug 23 16:13:18 2019
@@ -99,9 +99,15 @@ if (COMPILER_RT_HAS_GWP_ASAN)
       ADDITIONAL_HEADERS ${GWP_ASAN_BACKTRACE_HEADERS}
       CFLAGS ${GWP_ASAN_CFLAGS} ${SANITIZER_COMMON_CFLAGS})
 
-  # Build the stack trace compressor fuzzer.
-  if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND
-      COMPILER_RT_BUILD_LIBFUZZER)
+  # Build the stack trace compressor fuzzer. Note that clang versions 4.* did
+  # not have -fsanitize=fuzzer, and Clang versions 5.* didn't have
+  # -fsanitize=fuzzer-no-link. In general, the way we build fuzz targets in LLVM
+  # core is to link it against a dummy main when DLLVM_USE_SANITIZE_COVERAGE
+  # isn't specified. Instead, here we only build fuzz targets if clang version
+  # is >= 6.0.
+  if (COMPILER_RT_BUILD_LIBFUZZER AND
+      "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND
+      CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
     add_executable(stack_trace_compressor_fuzzer
         stack_trace_compressor_fuzzer.cpp
         ${GWP_ASAN_SOURCES}




More information about the llvm-commits mailing list