[clang] [clang-fuzzer-dictionary] Fix build failure with libfuzzer (PR #99871)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 22 06:12:38 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Raphael Isemann (Teemperor)

<details>
<summary>Changes</summary>

When building Clang with LLVM_USE_SANITIZE_COVERAGE=ON, libfuzzer is linked against the Clang fuzz targets to inject the main fuzzing loop. The clang-fuzzer-dictionary, which also resides in the same source tree as the fuzz targets, is also linked with -fsanitize=fuzzer because of this.

clang-fuzzer-dictionary is however not an actual fuzz target, but instead just a utilty binary that generates a fuzz dictionary. As it already defines a main function, the main function from libfuzzer causes the build to fail because of the duplicate definitions of main.

This patch just uses the fuzzer-no-link flags already used by the other utility binaries in this directory (i.e., the protobuf utils).

---
Full diff: https://github.com/llvm/llvm-project/pull/99871.diff


1 Files Affected:

- (modified) clang/tools/clang-fuzzer/dictionary/CMakeLists.txt (+1) 


``````````diff
diff --git a/clang/tools/clang-fuzzer/dictionary/CMakeLists.txt b/clang/tools/clang-fuzzer/dictionary/CMakeLists.txt
index ee4aa587ea54d..6b72b98f5e1c4 100644
--- a/clang/tools/clang-fuzzer/dictionary/CMakeLists.txt
+++ b/clang/tools/clang-fuzzer/dictionary/CMakeLists.txt
@@ -1,3 +1,4 @@
+set(CMAKE_CXX_FLAGS ${CXX_FLAGS_NOFUZZ})
 add_clang_executable(clang-fuzzer-dictionary
   dictionary.c
   )

``````````

</details>


https://github.com/llvm/llvm-project/pull/99871


More information about the cfe-commits mailing list