Add ability to override fuzzing engine
OSS-fuzz compiles its fuzz engine from source and then links it
in manually, so does *not* want us to set `-fsanitize=fuzzer` or
we'll have conflicting symbols when they build and link centipede.
We want the default to be true because Skia engineers want an
"out of the box" solution.
```
Step #21 - "compile-centipede-none-x86_64": clang++ -fsanitize=fuzzer -rdynamic -Wl,-rpath,\$ORIGIN -Wl,--gc-sections /usr/lib/libFuzzingEngine.a -O1 -fno-omit-frame-pointer -gline-tables-only -Wno-error=incompatible-function-pointer-types -Wno-error=int-conversion -Wno-error=deprecated-declarations -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=unknown-warning-option -Wno-error=vla-cxx-extension -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fno-builtin -fsanitize-coverage=trace-pc-guard,pc-table,trace-cmp -O2 -gline-tables-only -Wno-unused-command-line-argument -Wl,-ldl -Wl,-lrt -Wl,-lpthread -Wl,/src/fuzztest/centipede/weak.o -stdlib=libc++ -Wno-zero-as-null-pointer-constant -Wno-unused-template -Wno-cast-qual -I/src/skia/third_party/externals/swiftshader/include -fno-sanitize=vptr -DSK_BUILD_FOR_LIBFUZZER -D SK_BUILD_FOR_FUZZER -L/workspace/out/centipede-none-x86_64 -fuse-ld=lld -Wl,--start-group @./animated_image_decode.rsp -Wl,--end-group -lpthread -ldl -o ./animated_image_decode
Step #21 - "compile-centipede-none-x86_64": ld.lld: error: duplicate symbol: memcmp
Step #21 - "compile-centipede-none-x86_64": >>> defined at FuzzerInterceptors.cpp:160 (/src/llvm-project/compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp:160)
Step #21 - "compile-centipede-none-x86_64": >>> fuzzer_interceptors.o:(memcmp) in archive /usr/local/lib/clang/22/lib/x86_64-unknown-linux-gnu/libclang_rt.fuzzer_interceptors.a
Step #21 - "compile-centipede-none-x86_64": >>> defined at runner_interceptors.cc
Step #21 - "compile-centipede-none-x86_64": >>> runner_interceptors.pic.o:(.text.memcmp+0x0) in archive /usr/lib/libFuzzingEngine.a
Step #21 - "compile-centipede-none-x86_64":
```
Change-Id: Iec3c978ca61facdac576f3ac6bc11518676d040f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1092737
Reviewed-by: Eric Boren <borenet@google.com>
Auto-Submit: Kaylee Lubick <kjlubick@google.com>
Commit-Queue: Eric Boren <borenet@google.com>
Commit-Queue: Kaylee Lubick <kjlubick@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 692f850..5e50746 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -3321,8 +3321,13 @@
":tool_utils",
]
defines = [ "SK_BUILD_FOR_LIBFUZZER" ]
- cflags = [ "-fsanitize=fuzzer" ]
- ldflags = [ "-fsanitize=fuzzer" ]
+
+ # oss-fuzz will set this engine itself when building and we don't want a
+ # conflict (e.g. both libfuzzer and centipede)
+ if (skia_provide_default_fuzz_engine) {
+ cflags = [ "-fsanitize=fuzzer" ]
+ ldflags = [ "-fsanitize=fuzzer" ]
+ }
testonly = true
}
}
diff --git a/gn/skia.gni b/gn/skia.gni
index d56a235..ee62fca 100644
--- a/gn/skia.gni
+++ b/gn/skia.gni
@@ -118,6 +118,7 @@
skia_use_vulkan = false
skia_build_fuzzers = false
+ skia_provide_default_fuzz_engine = true
}
declare_args() {