Provide main(...)
function in fuzzer. Allow building uninstrumented harnesses with only --enable-fuzz
.
This PR restores the behaviour to how things worked prior to #18008. #18008 worked around an macOS specific issue but did it in a way which unnecessarily affected platforms not in need of the workaround :)
Before this patch:
0# Build uninstrumented fuzzing harness (no libFuzzer/AFL/other-fuzzer-instrumentation)
1$ ./configure --enable-fuzz
2$ make
3 CXXLD test/fuzz/span
4/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
5(.text+0x20): undefined reference to `main'
6collect2: error: ld returned 1 exit status
7Makefile:7244: recipe for target 'test/fuzz/span' failed
8make[2]: *** [test/fuzz/span] Error 1
9make[2]: *** Waiting for unfinished jobs....
10$
After this patch:
0# Build uninstrumented fuzzing harness (no libFuzzer/AFL/other-fuzzer-instrumentation)
1$ ./configure --enable-fuzz
2$ make
3$ echo foo | src/test/fuzz/span
4$
The examples above show the change in non-macOS functionality. macOS functionality is unaffected by this patch.