From c2b2f22392e77fa98a3f71daf915ebe1a5239e99 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 14 Feb 2022 06:34:00 -0800 Subject: configure: detect ubsan compilation. * configure: detect that the compiler is generating undefined behavior sanitizer code, a feature supported in GCC and Clang. The tell-tale sign of this is that "ubsan" occurs in the executable. If so, we deposit #define HAVE_UBSAN 1 into config.h. --- configure | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'configure') diff --git a/configure b/configure index 88dca391..bd6d7a58 100755 --- a/configure +++ b/configure @@ -1210,6 +1210,27 @@ else printf "done\n" fi +printf "Checking for undefined behavior sanitizer (\"ubsan\") being in effect ... " + +cat > conftest.c < + +int main(void) +{ + return 0; +} +! +if conftest ; then + if strings conftest | grep -q -i ubsan ; then + printf "yes\n" + printf "#define HAVE_UBSAN 1\n" >> config.h + else + printf "no\n" + fi +else + printf "failed\n" +fi + # # Detect Apple environment. We need _DARWIN_C_SOURCE. # -- cgit v1.2.3