[vlc-commits] configure: add --with-libfuzzer

Thomas Guillem git at videolan.org
Sat Nov 11 15:46:51 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Sat Oct 14 16:46:52 2017 -0700| [2c2eb4d06ced5e4c5e629fedf40ddfeac0d5d073] | committer: Thomas Guillem

configure: add --with-libfuzzer

DIR is the dir path of the libFuzzer.a static library.

When used, it forces a static build without vlc binary and enable sanitize
coverage.

How to fetch and build libFuzzer.a from llvm.org:
$ git clone https://git.llvm.org/git/compiler-rt
$ cd compiler-rt/lib/fuzzer

for gcc:
$ CXX=g++ ./build.sh

for clang:
$ ./build.sh

This a partial merge of the work done by Shaleen during GSOC 2017. See
https://code.videolan.org/GSoC2017/shalzz/vlc.git

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2c2eb4d06ced5e4c5e629fedf40ddfeac0d5d073
---

 configure.ac     | 31 +++++++++++++++++++++++++++++++
 test/Makefile.am |  2 +-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index b6ca0617bc..1653c67867 100644
--- a/configure.ac
+++ b/configure.ac
@@ -786,6 +786,17 @@ AS_IF([test "${SYS}" = "mingw32"], [
   have_dynamic_objects="yes" #assume we can use shared objects
 ])
 
+AC_ARG_WITH([libfuzzer],
+    [AS_HELP_STRING([--with-libfuzzer=DIR],
+        [use libFuzzer library from DIR and triggers sanitize coverage (default disabled)])],
+     [],
+     [with_libfuzzer=no])
+AS_VAR_IF(with_libfuzzer, no, [], [
+    enable_shared=no
+    enable_static=yes
+    enable_vlc=no
+])
+
 AS_IF([test "${enable_shared}" = "no"], [
   have_dynamic_objects=no
 ])
@@ -4194,6 +4205,26 @@ AC_ARG_ENABLE(vlc,
 AM_CONDITIONAL(BUILD_VLC, [test "${enable_vlc}" != "no"])
 
 dnl
+dnl Fuzzer (at the end in order to don't mess dependencies FLAGS)
+dnl
+AS_VAR_IF(with_libfuzzer, no, [], [
+    LIBS="-lstdc++ ${LIBM} ${LIBPTHREAD} -L${with_libfuzzer} -lFuzzer"
+    AX_CHECK_COMPILE_FLAG(-fsanitize-coverage=trace-pc-guard, [
+        AX_APPEND_FLAG([-fsanitize-coverage=trace-pc-guard])
+        AX_APPEND_FLAG([-fsanitize-coverage=trace-pc-guard], [CXXFLAGS])
+        AX_APPEND_COMPILE_FLAGS([-fsanitize-coverage=trace-cmp])
+        AX_APPEND_COMPILE_FLAGS([-fsanitize-coverage=trace-cmp], [CXXFLAGS])
+    ], [
+        AX_CHECK_COMPILE_FLAG(-fsanitize-coverage=trace-pc, [
+            AX_APPEND_FLAG([-fsanitize-coverage=trace-pc])
+            AX_APPEND_FLAG([-fsanitize-coverage=trace-pc], [CXXFLAGS])
+        ], [
+            AC_MSG_ERROR([Sanitizer coverage not supported by your compiler])
+        ])
+    ])
+])
+
+dnl
 dnl  Stuff used by the program
 dnl
 VERSION_MESSAGE="${VERSION} ${CODENAME}"
diff --git a/test/Makefile.am b/test/Makefile.am
index c61f811926..1d2f30a3b7 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -204,5 +204,5 @@ vlc_demux_run_LDADD = libvlc_demux_run.la
 EXTRA_PROGRAMS += vlc-demux-run
 
 vlc_demux_libfuzzer_CPPFLAGS = $(vlc_static_CPPFLAGS)
-vlc_demux_libfuzzer_LDADD = -lFuzzer libvlc_demux_run.la
+vlc_demux_libfuzzer_LDADD = libvlc_demux_run.la
 EXTRA_PROGRAMS += vlc-demux-libfuzzer



More information about the vlc-commits mailing list