summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-02-14 06:34:00 -0800
committerKaz Kylheku <kaz@kylheku.com>2022-02-14 06:34:00 -0800
commitc2b2f22392e77fa98a3f71daf915ebe1a5239e99 (patch)
tree94713a38142acb64dce55ce611ffa9831a0c19a4 /configure
parentdb69c993b1b3de0509a06d80ddd6d5e88baedfd8 (diff)
downloadtxr-c2b2f22392e77fa98a3f71daf915ebe1a5239e99.tar.gz
txr-c2b2f22392e77fa98a3f71daf915ebe1a5239e99.tar.bz2
txr-c2b2f22392e77fa98a3f71daf915ebe1a5239e99.zip
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.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure21
1 files changed, 21 insertions, 0 deletions
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 <<!
+#include <stdio.h>
+
+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.
#