Important compiler safety options are only used if CFLAGS isn't set
Brought to you by:
amadvance
dnl Code was written when compilers where not aggressively optimizing undefined behaviour about aliasing
dnl WARNING! At present disabled to maximize performance
dnl AC_CHECK_CC_OPT([-fno-strict-aliasing], [CFLAGS="$CFLAGS -fno-strict-aliasing"], [])
dnl Code was written when compilers where not aggressively optimizing undefined behaviour about overflow in signed integers
dnl WARNING! At present disabled to maximize performance
dnl AC_CHECK_CC_OPT([-fno-strict-overflow], [CFLAGS="$CFLAGS -fno-strict-overflow"], [])
dnl Code was written on Intel where char is signed
AC_CHECK_CC_OPT([-fsigned-char], [CFLAGS="$CFLAGS -fsigned-char"], [])
This is inside of if test $ac_auto_cflags = yes; then which is unfortunate since if the software is going to segfault due to compiler optimizations then the flags to stop the compiler from aggressively optimizing based on UB should not be ignored just because the user put -march=native or-g or -fdiagnostics-color=always -frecord-gcc-switches into $CFLAGS. It should simply always be set.
P.S. Is there any timeline for getting the code rewritten? Using
CFLAGS="-Werror=strict-aliasing"finds a bunch of issues, and could be incrementally fixed.