]> git.proxmox.com Git - mirror_zfs.git/blame - config/always-compiler-options.m4
compile with -fno-omit-frame-pointer
[mirror_zfs.git] / config / always-compiler-options.m4
CommitLineData
fed90353
BB
1dnl #
2dnl # Enabled -fsanitize=address if supported by gcc.
3dnl #
4dnl # LDFLAGS needs -fsanitize=address at all times so libraries compiled with
5dnl # it will be linked successfully. CFLAGS will vary by binary being built.
6dnl #
7dnl # The ASAN_OPTIONS environment variable can be used to further control
8dnl # the behavior of binaries and libraries build with -fsanitize=address.
9dnl #
10AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_ASAN], [
11 AC_MSG_CHECKING([whether to build with -fsanitize=address support])
12 AC_ARG_ENABLE([asan],
13 [AS_HELP_STRING([--enable-asan],
14 [Enable -fsanitize=address support @<:@default=no@:>@])],
15 [],
16 [enable_asan=no])
17
18 AM_CONDITIONAL([ASAN_ENABLED], [test x$enable_asan = xyes])
19 AC_SUBST([ASAN_ENABLED], [$enable_asan])
20 AC_MSG_RESULT($enable_asan)
21
22 AS_IF([ test "$enable_asan" = "yes" ], [
23 AC_MSG_CHECKING([whether $CC supports -fsanitize=address])
24 saved_cflags="$CFLAGS"
25 CFLAGS="$CFLAGS -fsanitize=address"
26 AC_LINK_IFELSE([
27 AC_LANG_SOURCE([[ int main() { return 0; } ]])
28 ], [
29 ASAN_CFLAGS="-fsanitize=address"
30 ASAN_LDFLAGS="-fsanitize=address"
31 ASAN_ZFS="_with_asan"
32 AC_MSG_RESULT([yes])
33 ], [
34 AC_MSG_ERROR([$CC does not support -fsanitize=address])
35 ])
36 CFLAGS="$saved_cflags"
37 ], [
38 ASAN_CFLAGS=""
39 ASAN_LDFLAGS=""
40 ASAN_ZFS="_without_asan"
41 ])
42
43 AC_SUBST([ASAN_CFLAGS])
44 AC_SUBST([ASAN_LDFLAGS])
45 AC_SUBST([ASAN_ZFS])
46])
47
48dnl #
49dnl # Check if gcc supports -Wframe-larger-than=<size> option.
50dnl #
51AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_FRAME_LARGER_THAN], [
52 AC_MSG_CHECKING([whether $CC supports -Wframe-larger-than=<size>])
53
54 saved_flags="$CFLAGS"
55 CFLAGS="$CFLAGS -Wframe-larger-than=4096"
56
57 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
58 FRAME_LARGER_THAN="-Wframe-larger-than=4096"
59 AC_MSG_RESULT([yes])
60 ], [
61 FRAME_LARGER_THAN=""
62 AC_MSG_RESULT([no])
63 ])
64
65 CFLAGS="$saved_flags"
66 AC_SUBST([FRAME_LARGER_THAN])
67])
68
69dnl #
70dnl # Check if gcc supports -Wno-format-truncation option.
71dnl #
72AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_TRUNCATION], [
73 AC_MSG_CHECKING([whether $CC supports -Wno-format-truncation])
74
75 saved_flags="$CFLAGS"
76 CFLAGS="$CFLAGS -Wno-format-truncation"
77
78 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
79 NO_FORMAT_TRUNCATION=-Wno-format-truncation
80 AC_MSG_RESULT([yes])
81 ], [
82 NO_FORMAT_TRUNCATION=
83 AC_MSG_RESULT([no])
84 ])
85
86 CFLAGS="$saved_flags"
87 AC_SUBST([NO_FORMAT_TRUNCATION])
88])
89
90
91dnl #
92dnl # Check if gcc supports -Wno-bool-compare option.
93dnl #
94dnl # We actually invoke gcc with the -Wbool-compare option
95dnl # and infer the 'no-' version does or doesn't exist based upon
96dnl # the results. This is required because when checking any of
97dnl # no- prefixed options gcc always returns success.
98dnl #
99AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_BOOL_COMPARE], [
100 AC_MSG_CHECKING([whether $CC supports -Wno-bool-compare])
101
102 saved_flags="$CFLAGS"
103 CFLAGS="$CFLAGS -Wbool-compare"
104
105 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
106 NO_BOOL_COMPARE=-Wno-bool-compare
107 AC_MSG_RESULT([yes])
108 ], [
109 NO_BOOL_COMPARE=
110 AC_MSG_RESULT([no])
111 ])
112
113 CFLAGS="$saved_flags"
114 AC_SUBST([NO_BOOL_COMPARE])
115])
116
117dnl #
118dnl # Check if gcc supports -Wno-unused-but-set-variable option.
119dnl #
120dnl # We actually invoke gcc with the -Wunused-but-set-variable option
121dnl # and infer the 'no-' version does or doesn't exist based upon
122dnl # the results. This is required because when checking any of
123dnl # no- prefixed options gcc always returns success.
124dnl #
125AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_UNUSED_BUT_SET_VARIABLE], [
126 AC_MSG_CHECKING([whether $CC supports -Wno-unused-but-set-variable])
127
128 saved_flags="$CFLAGS"
129 CFLAGS="$CFLAGS -Wunused-but-set-variable"
130
131 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
132 NO_UNUSED_BUT_SET_VARIABLE=-Wno-unused-but-set-variable
133 AC_MSG_RESULT([yes])
134 ], [
135 NO_UNUSED_BUT_SET_VARIABLE=
136 AC_MSG_RESULT([no])
137 ])
138
139 CFLAGS="$saved_flags"
140 AC_SUBST([NO_UNUSED_BUT_SET_VARIABLE])
141])
d5d2ef2b
RE
142
143dnl #
144dnl # Check if gcc supports -fno-omit-frame-pointer option.
145dnl #
146AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_OMIT_FRAME_POINTER], [
147 AC_MSG_CHECKING([whether $CC supports -fno-omit-frame-pointer])
148
149 saved_flags="$CFLAGS"
150 CFLAGS="$CFLAGS -fno-omit-frame-pointer"
151
152 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
153 NO_OMIT_FRAME_POINTER=-fno-omit-frame-pointer
154 AC_MSG_RESULT([yes])
155 ], [
156 NO_OMIT_FRAME_POINTER=
157 AC_MSG_RESULT([no])
158 ])
159
160 CFLAGS="$saved_flags"
161 AC_SUBST([NO_OMIT_FRAME_POINTER])
162])