1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
AC_DEFUN([PDNS_ENABLE_SANITIZERS], [
PDNS_ENABLE_ASAN
PDNS_ENABLE_MSAN
PDNS_ENABLE_TSAN
PDNS_ENABLE_LSAN
PDNS_ENABLE_UBSAN
AS_IF([test "x$enable_asan" != "xno" -a "x$enable_tsan" != "xno"],[
AC_MSG_ERROR([Address Sanitizer is not compatible with Thread Sanitizer])
])
AS_IF([test "x$enable_msan" != "xno" -a "x$enable_asan" != "xno"],[
AC_MSG_ERROR([Memory Sanitizer is not compatible with Address Sanitizer])
])
AS_IF([test "x$enable_msan" != "xno" -a "x$enable_lsan" != "xno"],[
AC_MSG_ERROR([Memory Sanitizer is not compatible with Leak Sanitizer])
])
AS_IF([test "x$enable_msan" != "xno" -a "x$enable_tsan" != "xno"],[
AC_MSG_ERROR([Memory Sanitizer is not compatible with Thread Sanitizer])
])
AS_IF([test "x$enable_asan" != "xno" -o "x$enable_tsan" != "xno" -o "x$enable_lsan" != "xno" -o "x$enable_ubsan" != "xno" -o "x$enable_msan" != "xno"], [
gl_WARN_ADD([-fno-omit-frame-pointer])
])
])
AC_DEFUN([PDNS_ENABLE_ASAN], [
AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS])
AC_MSG_CHECKING([whether to enable AddressSanitizer])
AC_ARG_ENABLE([asan],
AS_HELP_STRING([--enable-asan],
[enable AddressSanitizer @<:@default=no@:>@]),
[enable_asan=$enableval],
[enable_asan=no]
)
AC_MSG_RESULT([$enable_asan])
AS_IF([test "x$enable_asan" != "xno"], [
gl_COMPILER_OPTION_IF([-fsanitize=address],
[
[SANITIZER_FLAGS="-fsanitize=address $SANITIZER_FLAGS"]
AC_CHECK_HEADERS([sanitizer/common_interface_defs.h], asan_headers=yes, asan_headers=no)
AS_IF([test x"$asan_headers" = "xyes" ],
[AC_CHECK_DECL(__sanitizer_start_switch_fiber,
[
AC_MSG_CHECKING([for the exact signature of __sanitizer_finish_switch_fiber])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[#include <sanitizer/common_interface_defs.h>],
[
__sanitizer_finish_switch_fiber(nullptr);
])
], [
AC_MSG_RESULT([a single pointer])
AC_DEFINE([HAVE_FIBER_SANITIZER], [1], [Define if ASAN fiber annotation interface is available.])
AC_DEFINE(HAVE_SANITIZER_FINISH_SWITCH_FIBER_SINGLE_PTR, [1], [Define to 1 if __sanitizer_finish_switch_fiber takes only a pointer])
], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[#include <sanitizer/common_interface_defs.h>],
[
__sanitizer_finish_switch_fiber(nullptr, nullptr, nullptr);
])
], [
AC_MSG_RESULT([three pointers])
AC_DEFINE([HAVE_FIBER_SANITIZER], [1], [Define if ASAN fiber annotation interface is available.])
AC_DEFINE(HAVE_SANITIZER_FINISH_SWITCH_FIBER_THREE_PTRS, [1], [Define to 1 if __sanitizer_finish_switch_fiber takes three pointers])
], [
AC_MSG_RESULT([unknown])
AC_MSG_NOTICE([ASAN fiber switching is not available due to an unknown API version])
])
])
], [
AC_MSG_NOTICE([ASAN fiber switching is not available])
],
[#include <sanitizer/common_interface_defs.h>]
)]
)
],
[AC_MSG_ERROR([Cannot enable AddressSanitizer])]
)
])
AC_SUBST([SANITIZER_FLAGS])
])
AC_DEFUN([PDNS_ENABLE_TSAN], [
AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS])
AC_MSG_CHECKING([whether to enable ThreadSanitizer])
AC_ARG_ENABLE([tsan],
AS_HELP_STRING([--enable-tsan],
[enable ThreadSanitizer @<:@default=no@:>@]),
[enable_tsan=$enableval],
[enable_tsan=no]
)
AC_MSG_RESULT([$enable_tsan])
AS_IF([test "x$enable_tsan" != "xno"], [
gl_COMPILER_OPTION_IF([-fsanitize=thread],
[SANITIZER_FLAGS="-fsanitize=thread $SANITIZER_FLAGS"],
[AC_MSG_ERROR([Cannot enable ThreadSanitizer])]
)
])
AC_SUBST([SANITIZER_FLAGS])
])
AC_DEFUN([PDNS_ENABLE_LSAN], [
AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS])
AC_MSG_CHECKING([whether to enable LeakSanitizer])
AC_ARG_ENABLE([lsan],
AS_HELP_STRING([--enable-lsan],
[enable LeakSanitizer @<:@default=no@:>@]),
[enable_lsan=$enableval],
[enable_lsan=no]
)
AC_MSG_RESULT([$enable_lsan])
AS_IF([test "x$enable_lsan" != "xno"], [
gl_COMPILER_OPTION_IF([-fsanitize=leak],
[SANITIZER_FLAGS="-fsanitize=leak $SANITIZER_FLAGS"],
[AC_MSG_ERROR([Cannot enable LeakSanitizer])]
)
])
AC_SUBST([SANITIZER_FLAGS])
])
AC_DEFUN([PDNS_ENABLE_UBSAN], [
AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS])
AC_MSG_CHECKING([whether to enable Undefined Behaviour Sanitizer])
AC_ARG_ENABLE([ubsan],
AS_HELP_STRING([--enable-ubsan],
[enable Undefined Behaviour Sanitizer @<:@default=no@:>@]),
[enable_ubsan=$enableval],
[enable_ubsan=no]
)
AC_MSG_RESULT([$enable_ubsan])
AS_IF([test "x$enable_ubsan" != "xno"], [
gl_COMPILER_OPTION_IF([-fsanitize=undefined],
[SANITIZER_FLAGS="-fsanitize=undefined $SANITIZER_FLAGS"],
[AC_MSG_ERROR([Cannot enable Undefined Behaviour Sanitizer])]
)
])
AC_SUBST([SANITIZER_FLAGS])
])
AC_DEFUN([PDNS_ENABLE_MSAN], [
AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS])
AC_MSG_CHECKING([whether to enable MemorySanitizer])
AC_ARG_ENABLE([msan],
AS_HELP_STRING([--enable-msan],
[enable MemorySanitizer @<:@default=no@:>@]),
[enable_msan=$enableval],
[enable_msan=no]
)
AC_MSG_RESULT([$enable_msan])
AS_IF([test "x$enable_msan" != "xno"], [
gl_COMPILER_OPTION_IF([-fsanitize=memory],
[SANITIZER_FLAGS="-fsanitize=memory $SANITIZER_FLAGS"],
[AC_MSG_ERROR([Cannot enable MemorySanitizer])]
)
])
AC_SUBST([SANITIZER_FLAGS])
])
|