Skip to content

Commit f1286f1

Browse files
committed
config/options: add support for using sanitizer in debug builds
This allows enabling eg the address or leak sanitizer. Usually both CFLAGS and LDFLAGS need to be set to the same value and often it's advisable to set additions options like -fstack-protector-strong or -fno-omit-frame-pointer. DEBUG_SANITIZER_FLAGS sets both DEBUG_SANITIZER_CFLAGS and DEBUG_SANITIZER_LDFLAGS to the same value. Signed-off-by: Matthias Reichl <hias@horus.com>
1 parent b32f076 commit f1286f1

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

config/options

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,24 @@ if [ -z "${CONFIG_SHELL}" ] && [ -x "/bin/dash" ]; then
149149
export CONFIG_SHELL="/bin/dash"
150150
fi
151151

152+
# enable gcc sanitizer support in debug builds
153+
# DEBUG_SANITIZER_FLAGS sets both CFLAGS and LDFLAGS
154+
if [ "${DEBUG:-no}" != "no" ]; then
155+
if [ -n "${DEBUG_SANITIZER_FLAGS}" ]; then
156+
DEBUG_SANITIZER_CFLAGS="${DEBUG_SANITIZER_FLAGS}"
157+
DEBUG_SANITIZER_LDFLAGS="${DEBUG_SANITIZER_FLAGS}"
158+
fi
159+
if [ -n "${DEBUG_SANITIZER_CFLAGS}" ] || [ -n "${DEBUG_SANITIZER_LDFLAGS}" ]; then
160+
SANITIZER_SUPPORT="yes"
161+
else
162+
SANITIZER_SUPPORT="no"
163+
fi
164+
else
165+
SANITIZER_SUPPORT="no"
166+
DEBUG_SANITIZER_CFLAGS=""
167+
DEBUG_SANITIZER_LDFLAGS=""
168+
fi
169+
152170
check_config
153171

154172
. config/graphic

0 commit comments

Comments
 (0)