[PATCH 001/150] oss-fuzz/build: remove LIB_FUZZING_ENGINE

Paolo Bonzini posted 150 patches 5 years, 5 months ago
Maintainers: Jiaxun Yang <jiaxun.yang@flygoat.com>, Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>, Stefano Stabellini <sstabellini@kernel.org>, David Gibson <david@gibson.dropbear.id.au>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, Alex Williamson <alex.williamson@redhat.com>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Artyom Tarasenko <atar4qemu@gmail.com>, Hannes Reinecke <hare@suse.com>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Andrzej Zaborowski <balrogg@gmail.com>, Laszlo Ersek <lersek@redhat.com>, Aurelien Jarno <aurelien@aurel32.net>, Stefan Berger <stefanb@linux.ibm.com>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Juan Quintela <quintela@redhat.com>, Raphael Norwitz <raphael.norwitz@nutanix.com>, Yoshinori Sato <ysato@users.sourceforge.jp>, Palmer Dabbelt <palmer@dabbelt.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Thomas Huth <thuth@redhat.com>, Michael Roth <mdroth@linux.vnet.ibm.com>, Kevin Wolf <kwolf@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Eric Blake <eblake@redhat.com>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, Michael Rolnik <mrolnik@gmail.com>, Joel Stanley <joel@jms.id.au>, Laurent Vivier <lvivier@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, Jason Wang <jasowang@redhat.com>, Halil Pasic <pasic@linux.ibm.com>, Richard Henderson <rth@twiddle.net>, Anthony Perard <anthony.perard@citrix.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Alexander Bulekov <alxndr@bu.edu>, Huacai Chen <chenhc@lemote.com>, Greg Kurz <groug@kaod.org>, Sagar Karandikar <sagark@eecs.berkeley.edu>, John Snow <jsnow@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paul Durrant <paul@xen.org>, Markus Armbruster <armbru@redhat.com>, Dmitry Fleytman <dmitry.fleytman@gmail.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Riku Voipio <riku.voipio@iki.fi>, Keith Busch <kbusch@kernel.org>, "Alex Bennée" <alex.bennee@linaro.org>, Stefan Hajnoczi <stefanha@redhat.com>, Christian Schoenebeck <qemu_oss@crudebyte.com>, Peter Maydell <peter.maydell@linaro.org>, Cornelia Huck <cohuck@redhat.com>, Laurent Vivier <laurent@vivier.eu>, Sarah Harris <S.E.Harris@kent.ac.uk>, "Cédric Le Goater" <clg@kaod.org>, Stefan Weil <sw@weilnetz.de>, Helge Deller <deller@gmx.de>, David Hildenbrand <david@redhat.com>, Max Reitz <mreitz@redhat.com>, Alistair Francis <Alistair.Francis@wdc.com>, Christian Borntraeger <borntraeger@de.ibm.com>, Cleber Rosa <crosa@redhat.com>, Yuval Shaia <yuval.shaia.ml@gmail.com>, Stafford Horne <shorne@gmail.com>, Fam Zheng <fam@euphon.net>, Amit Shah <amit@kernel.org>, Bandan Das <bsd@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, Max Filippov <jcmvbkbc@gmail.com>, "Michael S. Tsirkin" <mst@redhat.com>, Ben Warren <ben@skyportsystems.com>, Su Hang <suhang16@mails.ucas.ac.cn>
There is a newer version of this series
[PATCH 001/150] oss-fuzz/build: remove LIB_FUZZING_ENGINE
Posted by Paolo Bonzini 5 years, 5 months ago
Meson build scripts will only include qemu-fuzz-TARGET rules if configured
with --enable-fuzzing, and that takes care of adding -fsanitize=fuzzer.
Therefore we can just specify the configure option and stop modifying
the CFLAGS and CONFIG_FUZZ options in the "make" invocation.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/oss-fuzz/build.sh | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/scripts/oss-fuzz/build.sh b/scripts/oss-fuzz/build.sh
index a07b3022e8..52430cb620 100755
--- a/scripts/oss-fuzz/build.sh
+++ b/scripts/oss-fuzz/build.sh
@@ -20,7 +20,7 @@
 # e.g.
 # $CXX $CXXFLAGS -std=c++11 -Iinclude \
 #     /path/to/name_of_fuzzer.cc -o $OUT/name_of_fuzzer \
-#     $LIB_FUZZING_ENGINE /path/to/library.a
+#     -fsanitize=fuzzer /path/to/library.a
 
 fatal () {
     echo "Error : ${*}, exiting."
@@ -54,10 +54,6 @@ mkdir -p $OSS_FUZZ_BUILD_DIR || fatal "mkdir $OSS_FUZZ_BUILD_DIR failed"
 cd $OSS_FUZZ_BUILD_DIR || fatal "cd $OSS_FUZZ_BUILD_DIR failed"
 
 
-if [ -z ${LIB_FUZZING_ENGINE+x} ]; then
-    LIB_FUZZING_ENGINE="-fsanitize=fuzzer"
-fi
-
 if [ -z ${OUT+x} ]; then
     DEST_DIR=$(realpath "./DEST_DIR")
 else
@@ -67,14 +63,12 @@ fi
 mkdir -p "$DEST_DIR/lib/"  # Copy the shared libraries here
 
 # Build once to get the list of dynamic lib paths, and copy them over
-../configure --disable-werror --cc="$CC" --cxx="$CXX" \
+../configure --disable-werror --cc="$CC" --cxx="$CXX" --enable-fuzzing \
     --extra-cflags="$EXTRA_CFLAGS" --target-list="i386-softmmu"
 
-if ! make CONFIG_FUZZ=y CFLAGS="$LIB_FUZZING_ENGINE" "-j$(nproc)" \
-    i386-softmmu/fuzz; then
+if ! make "-j$(nproc)" i386-softmmu/fuzz; then
     fatal "Build failed. Please specify a compiler with fuzzing support"\
-          "using the \$CC and \$CXX environemnt variables, or specify a"\
-          "\$LIB_FUZZING_ENGINE compatible with your compiler"\
+          "using the \$CC and \$CXX environemnt variables"\
           "\nFor example: CC=clang CXX=clang++ $0"
 fi
 
@@ -87,7 +81,7 @@ rm ./i386-softmmu/qemu-fuzz-i386
 ../configure --bindir="$DEST_DIR" --datadir="$DEST_DIR/data/" --disable-werror \
     --cc="$CC" --cxx="$CXX" --extra-cflags="$EXTRA_CFLAGS" \
     --extra-ldflags="-Wl,-rpath,'\$\$ORIGIN/lib'"
-make CONFIG_FUZZ=y CFLAGS="$LIB_FUZZING_ENGINE" "-j$(nproc)" i386-softmmu/fuzz
+make "-j$(nproc)" i386-softmmu/fuzz
 
 # Copy over the datadir
 cp  -r ../pc-bios/ "$DEST_DIR/pc-bios"
-- 
2.26.2