[build] Autoconfiscate simd support

The default is to enable (and autodetect based on lscpu) simd support,
or the mode can be specified via --enable-simd=mode. --disable-simd
disables the support but ensures gcc will still compile the float vector
types.
This commit is contained in:
Bill Currie 2021-06-29 15:39:15 +09:00
parent a3aebc983b
commit c554dee0f8
3 changed files with 26 additions and 8 deletions

View file

@ -81,13 +81,30 @@ AC_ARG_ENABLE(optimize,
optimize=yes
)
dnl QF_CC_OPTION(-Wno-psabi)
dnl QF_CC_OPTION(-msse2)
dnl QF_CC_OPTION(-Wno-psabi)
QF_CC_OPTION(-mavx2)
dnl fma is not used as it is the equivalent of turning on
dnl -funsafe-math-optimizations
dnl QF_CC_OPTION(-mfma)
AC_ARG_ENABLE(simd,
[ --enable-simd[=arg] Enable SIMD support (default auto)],
[],
[enable_simd=yes]
)
case "$enable_simd" in
no)
QF_CC_OPTION(-Wno-psabi)
simd=no
;;
sse|sse2|avx|avx2)
QF_CC_OPTION(-m$enable_simd)
simd=$enable_simd
;;
yes)
for simd in avx2 avx sse2 sse; do
if lscpu | grep -q -w $simd; then
QF_CC_OPTION(-m$simd)
break
fi
done
;;
esac
AC_MSG_CHECKING(for optimization)
if test "x$optimize" = xyes -a "x$leave_cflags_alone" != "xyes"; then

View file

@ -12,6 +12,7 @@ AC_MSG_RESULT([
HTTP support : ${CURL:-no}
Compiler version : $CCVER
Compiler flags : $CFLAGS
SIMD Support : $simd
qfcc cpp invocation: $CPP_NAME
Shared game data directory : $sharepath

View file

@ -74,7 +74,7 @@ dnl Checks for system type
dnl ==================================================================
dnl Checks for which system driver to use
echo ${host}
AC_MSG_CHECKING(for system driver)
case "${host}" in
i?86-*-mingw32*|x86_64-w64-mingw32*)