configure: force enable-sanitizers together with enable-fuzzing
PATCH 1/1 configure: force enable-sanitizers together with enable-fuzzing
If we execute configure with --enable-fuzzing but without --enable-sanitizers, we will have a lot of 'undefined reference' build error such as following:
clang-10 -o subprojects/libvhost-user/link-test subprojects/libvhost-user/link-test.p/link-test.c.o -Wl,--as-needed -Wl,--no-undefined -pie -Wl,--whole-archive -Wl,--start-group subprojects/libvhost-user/libvhost-user.a -Wl,--end-group -Wl,--no-whole-archive -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -m64 -fstack-protector-strong -pthread /usr/bin/ld: subprojects/libvhost-user/link-test.p/link-test.c.o: in function `main':/home/test/qemu/build/../subprojects/libvhost-user/link-test.c:34: undefined reference to `__sancov_lowest_stack'/usr/bin/ld: /home/test/qemu/build/../subprojects/libvhost-user/link-test.c:(.text.main[main]+0x55): undefined reference to `__sancov_lowest_stack'/usr/bin/ld: /home/test/qemu/build/../subprojects/libvhost-user/link-test.c:41: undefined reference to `__sanitizer_cov_trace_const_cmp4'/usr/bin/ld: subprojects/libvhost-user/link-test.p/link-test.c.o: in function `sancov.module_ctor_8bit_counters':
link-test.c:(.text.sancov.module_ctor_8bit_counters[sancov.module_ctor_8bit_counters]+0x16): undefined reference to `__sanitizer_cov_8bit_counters_init'/usr/bin/ld: link-test.c:(.text.sancov.module_ctor_8bit_counters[sancov.module_ctor_8bit_counters]+0x2f): undefined reference to `__sanitizer_cov_pcs_init'/usr/bin/ld: subprojects/libvhost-user/libvhost-user.a(libvhost-user.c.o): in function `vu_gpa_to_va':/home/test/qemu/build/../subprojects/libvhost-user/libvhost-user.c:182: undefined reference to `__sanitizer_cov_trace_const_cmp8'/usr/bin/ld: /home/test/qemu/build/../subprojects/libvhost-user/libvhost-user.c:187: undefined reference to `__sanitizer_cov_trace_cmp4'/usr/bin/ld: /home/test/qemu/build/../subprojects/libvhost-user/libvhost-user.c:190: undefined reference to `__sanitizer_cov_trace_cmp8'/usr/bin/ld: /home/test/qemu/build/../subprojects/libvhost-user/libvhost-user.c:190: undefined reference to `__sanitizer_cov_trace_cmp8'/usr/bin/ld: /home/test/qemu/build/../subprojects/libvhost-user/libvhost-user.c:191: undefined reference to `__sanitizer_cov_trace_cmp8'
Let's avoid this error by enforcing fuzzing and sanitizers together.
--- configure | 3 +++ 1 file changed, 3 insertions(+)
configure +3 -0
@@ -6083,6 +6083,9 @@ if test "$have_mlockall" = "yes" ; then echo "HAVE_MLOCKALL=y" >> $config_host_mak fi if test "$fuzzing" = "yes" ; then + if test "$sanitizers" = "no"; then + error_exit "enable-fuzzing also needs enable-sanitizers" + fi # If LIB_FUZZING_ENGINE is set, assume we are running on OSS-Fuzz, and the # needed CFLAGS have already been provided if test -z "${LIB_FUZZING_ENGINE+xxx}" ; then
Signature · 1 line
2.25.1
Quoted 19 lines · Li Qiang
If we execute configure with --enable-fuzzing but without --enable-sanitizers, we will have a lot of 'undefined reference' build error such as following:
clang-10 -o subprojects/libvhost-user/link-test
subprojects/libvhost-user/link-test.p/link-test.c.o-Wl,--as-needed -Wl,--no-undefined -pie -Wl,--whole-archive -Wl,--start-group subprojects/libvhost-user/libvhost-user.a -Wl,--end-group -Wl,--no-whole-archive -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -m64 -fstack-protector-strong -pthread/usr/bin/ld:subprojects/libvhost-user/link-test.p/link-test.c.o: in function `main':/home/test/qemu/build/../subprojects/libvhost-user/link-test.c:34: undefined reference to `__sancov_lowest_stack'/usr/bin/ld: /home/test/qemu/build/../subprojects/libvhost-user/link-test.c:(.text.main[main]+0x55): undefined reference to `__sancov_lowest_stack'/usr/bin/ld:/home/test/qemu/build/../subprojects/libvhost-user/link-test.c:41: undefined reference to `__sanitizer_cov_trace_const_cmp4'/usr/bin/ld:subprojects/libvhost-user/link-test.p/link-test.c.o: in function `sancov.module_ctor_8bit_counters':
link-test.c:(.text.sancov.module_ctor_8bit_counters[sancov.module_ctor_8bit_counters]+0x16): undefined reference to `__sanitizer_cov_8bit_counters_init'/usr/bin/ld: link-test.c:(.text.sancov.module_ctor_8bit_counters[sancov.module_ctor_8bit_counters]+0x2f): undefined reference to `__sanitizer_cov_pcs_init'/usr/bin/ld: subprojects/libvhost-user/libvhost-user.a(libvhost-user.c.o): in function `vu_gpa_to_va':/home/test/qemu/build/../subprojects/libvhost-user/libvhost-user.c:182: undefined reference to `__sanitizer_cov_trace_const_cmp8'/usr/bin/ld:/home/test/qemu/build/../subprojects/libvhost-user/libvhost-user.c:187: undefined reference to `__sanitizer_cov_trace_cmp4'/usr/bin/ld:/home/test/qemu/build/../subprojects/libvhost-user/libvhost-user.c:190: undefined reference to `__sanitizer_cov_trace_cmp8'/usr/bin/ld:/home/test/qemu/build/../subprojects/libvhost-user/libvhost-user.c:190: undefined reference to `__sanitizer_cov_trace_cmp8'/usr/bin/ld:/home/test/qemu/build/../subprojects/libvhost-user/libvhost-user.c:191: undefined reference to `__sanitizer_cov_trace_cmp8'
Quoted 3 lines
Let's avoid this error by enforcing fuzzing and sanitizers together.
Signed-off-by Li Qiang <[email protected]>
I usually build using something like "ninja qemu-fuzz-i386", so I missed this failure. CI missed it because we only build-test --enable-fuzzing --enable-sanitizers.
I'll send an alternate patch, which should hopefully fix the failure, without requiring enable-sanitizers. ASAN can add 5-10x overhead to fuzzing, so it is often useful to fuzz without ASAN for a while, before switching it on.