oss-fuzz: link AFL++ compiler runtime for AFL builds (#296) The OSS-Fuzz AFL build failed during linking with unresolved AFL++ symbols, including: ``` undefined symbol: __afl_manual_init undefined symbol: __afl_fuzz_ptr undefined symbol: __afl_persistent_loop ``` These symbols are referenced by `aflpp_driver.o` in the OSS-Fuzz fuzzing engine archive. When `FUZZING_ENGINE=afl`, add `/src/aflplusplus/afl-compiler-rt.o` to Bazel's link options so the AFL++ runtime definitions are included in the final link. Signed-off-by: xingyaner <longfor2025@gmail.com>
diff --git a/fuzzing/private/oss_fuzz/repository.bzl b/fuzzing/private/oss_fuzz/repository.bzl index 0f81811..57b93b9 100644 --- a/fuzzing/private/oss_fuzz/repository.bzl +++ b/fuzzing/private/oss_fuzz/repository.bzl
@@ -28,6 +28,9 @@ instrum_conlyopts = [] instrum_cxxopts = [] + if repository_ctx.os.environ.get("FUZZING_ENGINE") == "afl": + stub_linkopts.append("/src/aflplusplus/afl-compiler-rt.o") + if sanitizer == "undefined": # Bazel uses clang, not clang++, as the linker, which does not link the # C++ UBSan runtime library by default, but can be instructed to do so