Add C++ bitness test in SAH_SELECT_BITNESS

This commit is contained in:
Jia Yuan Lo 2021-01-22 00:01:20 +08:00 committed by GitHub
parent 6e46649c21
commit b94e1c934c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 0 deletions

View File

@ -59,6 +59,25 @@ AC_DEFUN([SAH_SELECT_BITNESS],[
AC_MSG_RESULT([ok use $1])
AC_LANG_POP([C])
AC_LANG_PUSH([C++])
AC_MSG_CHECKING([if C++ compiler can use -m$1])
if test "$1" != "${COMPILER_MODEL_BITS}"; then
echo "int main() { return 0; }" >conftest.$ac_ext
AC_REQUIRE_CPP
${CXX} ${CXXFLAGS} ${CPPFLAGS} -m$1 -fno-lto -c conftest.$ac_ext 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD
if test -f conftest.${OBJEXT}; then
if test -n "$(file conftest.${OBJEXT} | grep -i ${1}-bit)"; then
CXXFLAGS="${CXXFLAGS} -m$1"
AC_MSG_RESULT([ok use $1])
else
AC_MSG_ERROR([failed still $COMPILER_MODEL_BITS])
fi
fi
/bin/rm conftest.$ac_ext conftest.${OBJEXT}
fi
AC_MSG_RESULT([ok use $1])
AC_LANG_POP([C++])
COMPILER_MODEL_BITS=$1
])