Debian Codegraph @

build-aux/m4/zw_detect_asan.m4

raw
1 dnl Written by Zack Weinberg <zackw at panix.com> in 2021.
2 dnl To the extent possible under law, Zack Weinberg has waived all
3 dnl copyright and related or neighboring rights to this work.
4 dnl
5 dnl See https://creativecommons.org/publicdomain/zero/1.0/ for further
6 dnl details.
7 dnl
8 dnl Detect whether the active compiler compiles programs with ASan
9 dnl instrumentation. If so, execute ACTIONS-IF-TRUE, otherwise
10 dnl ACTIONS-IF-FALSE.
11 dnl
12 dnl Implementation note: with clang one can use __has_feature(address_sanitizer)
13 dnl to detect ASan, but gcc does not support that. Instead we look
14 dnl for ASan symbols in the linked executable. This requires a helper
15 dnl macro shipped with libtool.
16 dnl
17 dnl zw_ASAN_IFELSE(actions-if-true[, actions-if-false])
18 AC_DEFUN([zw_ASAN_IFELSE],
19 [AC_REQUIRE([AC_PROG_EGREP])]dnl
20 [AC_REQUIRE([LT_PATH_NM])]dnl
21 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
22 [AS_IF([$NM conftest$EXEEXT | $EGREP _asan_ > /dev/null 2>&1],
23 [$1], [$2])],
24 [AC_MSG_ERROR([cannot link a trivial test program])])])