1dnl Sanitization-related configure macro for GDB 2dnl Copyright (C) 2018-2023 Free Software Foundation, Inc. 3dnl 4dnl This file is part of GDB. 5dnl 6dnl This program is free software; you can redistribute it and/or modify 7dnl it under the terms of the GNU General Public License as published by 8dnl the Free Software Foundation; either version 3 of the License, or 9dnl (at your option) any later version. 10dnl 11dnl This program is distributed in the hope that it will be useful, 12dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14dnl GNU General Public License for more details. 15dnl 16dnl You should have received a copy of the GNU General Public License 17dnl along with this program. If not, see <http://www.gnu.org/licenses/>. 18 19AC_DEFUN([AM_GDB_UBSAN],[ 20AC_ARG_ENABLE(ubsan, 21 AS_HELP_STRING([--enable-ubsan], 22 [enable undefined behavior sanitizer (auto/yes/no)]), 23 [],enable_ubsan=no) 24if test "x$enable_ubsan" = xauto; then 25 if $development; then 26 enable_ubsan=yes 27 fi 28fi 29AC_LANG_PUSH([C++]) 30if test "x$enable_ubsan" = xyes; then 31 AC_MSG_CHECKING(whether -fsanitize=undefined is accepted) 32 saved_CXXFLAGS="$CXXFLAGS" 33 CXXFLAGS="$CXXFLAGS -fsanitize=undefined -fno-sanitize-recover=undefined" 34 dnl A link check is required because it is possible to install gcc 35 dnl without libubsan, leading to link failures when compiling with 36 dnl -fsanitize=undefined. 37 AC_LINK_IFELSE( 38 [AC_LANG_PROGRAM([], [])], 39 [enable_ubsan=yes], 40 [enable_ubsan=no] 41 ) 42 CXXFLAGS="$saved_CXXFLAGS" 43 AC_MSG_RESULT($enable_ubsan) 44 if test "x$enable_ubsan" = xyes; then 45 WARN_CFLAGS="$WARN_CFLAGS -fsanitize=undefined -fno-sanitize-recover=undefined" 46 CONFIG_LDFLAGS="$CONFIG_LDFLAGS -fsanitize=undefined" 47 fi 48fi 49AC_LANG_POP([C++]) 50]) 51