From b045529c40c83601909dca7b76a53498e9a70f33 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 21:05:44 +0200 Subject: Adding upstream version 3.3.4. Signed-off-by: Daniel Baumann --- m4/sanitizer.m4 | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 m4/sanitizer.m4 (limited to 'm4/sanitizer.m4') diff --git a/m4/sanitizer.m4 b/m4/sanitizer.m4 new file mode 100644 index 0000000..439d441 --- /dev/null +++ b/m4/sanitizer.m4 @@ -0,0 +1,76 @@ +# Copyright (C) 2018 CZ.NIC, z.s.p.o. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . + +# +# Processes --with-sanitizer, --with-fuzzer, and --with-oss-fuzz flags, checks +# if the options are supported by the compiler, and sets the following +# variables accordingly: +# +# - sanitizer_CFLAGS -fsanitize=... +# - fuzzer_CLAGS -fsanitize=... +# - fuzzer_LDLAGS -fsanitize=... +# + +AC_DEFUN([AX_SANITIZER], [ + + # Configure options + AC_ARG_WITH([sanitizer], + [AS_HELP_STRING([--with-sanitizer], [Compile with sanitizer [default=no]])], + [], + [with_sanitizer=no] + ) + AC_ARG_WITH([fuzzer], + [AS_HELP_STRING([--with-fuzzer], [Compile with libfuzzer [default=no]])], + [], + [with_fuzzer=no] + ) + AC_ARG_WITH([oss-fuzz], + [AS_HELP_STRING([--with-oss-fuzz], [Link for oss-fuzz environment [default=no]])], + [], + [with_oss_fuzz=no] + ) + + # Default values + AS_IF([test "$with_sanitizer" = "yes"], [ with_sanitizer=address,undefined ]) + AS_IF([test "$with_fuzzer" = "yes"], [ with_fuzzer=fuzzer ]) + + # Construct output variables + sanitizer_CFLAGS= + fuzzer_CFLAGS= + fuzzer_LDFLAGS= + AS_IF([test "$with_sanitizer" != "no"], [ + sanitizer_CFLAGS="-fsanitize=${with_sanitizer}" + ]) + AS_IF([test "$with_fuzzer" != "no"], [ + fuzzer_CFLAGS="-fsanitize=${with_fuzzer}" + fuzzer_LDFLAGS="-fsanitize=${with_fuzzer}" + ]) + AC_SUBST(fuzzer_CFLAGS) + AC_SUBST(fuzzer_LDFLAGS) + + # Test compiler support + AS_IF([test -n "$sanitizer_CFLAGS" -o -n "$fuzzer_CFLAGS"], [ + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $sanitizer_CFLAGS $fuzzer_CFLAGS" + AC_MSG_CHECKING([whether compiler accepts '${sanitizer_CFLAGS} ${fuzzer_CFLAGS}']) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ + AC_MSG_RESULT([yes]) + ], [ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([Options are not supported.]) + ]) + CFLAGS="$save_CFLAGS" + ]) + +]) # AX_SANITIZER -- cgit v1.2.3