1 dnl Sanitization-related configure macro for GDB
2 dnl Copyright (C) 2018-2020 Free Software Foundation, Inc.
4 dnl This file is part of GDB.
6 dnl This program is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 3 of the License, or
9 dnl (at your option) any later version.
11 dnl This program is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 dnl GNU General Public License for more details.
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
19 AC_DEFUN([AM_GDB_UBSAN],[
21 AS_HELP_STRING([--enable-ubsan],
22 [enable undefined behavior sanitizer (auto/yes/no)]),
24 if test "x$enable_ubsan" = xauto; then
30 if 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_TRY_LINK([],[],enable_ubsan=yes,enable_ubsan=no)
38 CXXFLAGS="$saved_CXXFLAGS"
39 AC_MSG_RESULT($enable_ubsan)
40 if test "x$enable_ubsan" = xyes; then
41 WARN_CFLAGS="$WARN_CFLAGS -fsanitize=undefined -fno-sanitize-recover=undefined"
42 CONFIG_LDFLAGS="$CONFIG_LDFLAGS -fsanitize=undefined"