summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorPete Zaitcev <zaitcev@kotori.zaitcev.us>2017-05-24 14:35:15 -0600
committerPete Zaitcev <zaitcev@kotori.zaitcev.us>2017-05-24 14:42:36 -0600
commit0962144c51421a39be921876328bcecb912c7674 (patch)
treefe473286b7ad52dfc12c62fac4afd5a41129cefd /configure.ac
parentde984f59e7a6cca8c1f3cf1d93b87ff144a2b974 (diff)
downloadliberasurecode-0962144c51421a39be921876328bcecb912c7674.tar.gz
Allow to disable optimizations for portability
We're having trouble on Fedora when the build system runs on Intel CPUs. The ./configure detects AVX instructions and builds liberasurecode with them. The resulting library crashes with SIGILL when users run it on ADM CPUs without AVX. See the details here: https://bugzilla.redhat.com/show_bug.cgi?id=1454543 The patch allows to disable the optimizations, so that distro packaging then can invoke this options and build portable libraries. For the record, "make test" runs about 16% slower on an Intel CPU if optimizations are disabled. So, there's a measurable performance impact. However, operators intersted in outright performance might want to consider Erasure Coding implementations other than the one built-in into liberasurecode. The library supports other back-ends that are significantly faster than even optimized built-in code. Change-Id: I09603b97ceeb833ba582cf3217e0be51c019d645
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac133
1 files changed, 73 insertions, 60 deletions
diff --git a/configure.ac b/configure.ac
index c3509d2..69df9a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -151,68 +151,81 @@ AC_SUBST(ac_aux_dir)
AC_SUBST(OBJECTS)
dnl Do CPUID and associated compiler flag checks
+dnl but allow to disable all of this in order to build portable binaries
-SUPPORTED_FLAGS=""
-$CC - -E -mmmx </dev/null >/dev/null 2>&1
-if [[ $? == "0" ]]; then
- SUPPORTED_FLAGS="-mmmx"
- AC_MSG_RESULT([$CC supports -mmmx])
-fi
-$CC - -E -msse </dev/null >/dev/null 2>&1
-if [[ $? == "0" ]]; then
- SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse"
- AC_MSG_RESULT([$CC supports -msse])
-fi
-$CC - -E -msse2 </dev/null >/dev/null 2>&1
-if [[ $? == "0" ]]; then
- SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse2"
- AC_MSG_RESULT([$CC supports -msse2])
-fi
-$CC - -E -msse3 </dev/null >/dev/null 2>&1
-if [[ $? == "0" ]]; then
- SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse3"
- AC_MSG_RESULT([$CC supports -msse3])
-fi
-$CC - -E -mssse3 </dev/null >/dev/null 2>&1
-if [[ $? == "0" ]]; then
- SUPPORTED_FLAGS="$SUPPORTED_FLAGS -mssse3"
- AC_MSG_RESULT([$CC supports -mssse3])
-fi
-$CC - -E -msse4.1 </dev/null >/dev/null 2>&1
-if [[ $? == "0" ]]; then
- SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse4.1"
- AC_MSG_RESULT([$CC supports -msse4.1])
-fi
-$CC - -E -msse4.2 </dev/null >/dev/null 2>&1
-if [[ $? == "0" ]]; then
- SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse4.2"
- AC_MSG_RESULT([$CC supports -msse4.2])
-fi
-$CC - -E -mavx </dev/null >/dev/null 2>&1
-if [[ $? == "0" ]]; then
- SUPPORTED_FLAGS="$SUPPORTED_FLAGS -mavx"
- AC_MSG_RESULT([$CC supports -mavx])
-fi
+AC_ARG_ENABLE([mmi], [ --disable-mmi do not use host-specific instructions],
+[case "${enableval}" in
+ yes) mmi=true ;;
+ no) mmi=false ;;
+ *) AC_MSG_ERROR([bad value ${enableval} for --disable-mmi]) ;;
+esac],[mmi=true])
+
+if test x$mmi = xtrue ; then
+
+ SUPPORTED_FLAGS=""
+ $CC - -E -mmmx </dev/null >/dev/null 2>&1
+ if [[ $? == "0" ]]; then
+ SUPPORTED_FLAGS="-mmmx"
+ AC_MSG_RESULT([$CC supports -mmmx])
+ fi
+ $CC - -E -msse </dev/null >/dev/null 2>&1
+ if [[ $? == "0" ]]; then
+ SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse"
+ AC_MSG_RESULT([$CC supports -msse])
+ fi
+ $CC - -E -msse2 </dev/null >/dev/null 2>&1
+ if [[ $? == "0" ]]; then
+ SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse2"
+ AC_MSG_RESULT([$CC supports -msse2])
+ fi
+ $CC - -E -msse3 </dev/null >/dev/null 2>&1
+ if [[ $? == "0" ]]; then
+ SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse3"
+ AC_MSG_RESULT([$CC supports -msse3])
+ fi
+ $CC - -E -mssse3 </dev/null >/dev/null 2>&1
+ if [[ $? == "0" ]]; then
+ SUPPORTED_FLAGS="$SUPPORTED_FLAGS -mssse3"
+ AC_MSG_RESULT([$CC supports -mssse3])
+ fi
+ $CC - -E -msse4.1 </dev/null >/dev/null 2>&1
+ if [[ $? == "0" ]]; then
+ SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse4.1"
+ AC_MSG_RESULT([$CC supports -msse4.1])
+ fi
+ $CC - -E -msse4.2 </dev/null >/dev/null 2>&1
+ if [[ $? == "0" ]]; then
+ SUPPORTED_FLAGS="$SUPPORTED_FLAGS -msse4.2"
+ AC_MSG_RESULT([$CC supports -msse4.2])
+ fi
+ $CC - -E -mavx </dev/null >/dev/null 2>&1
+ if [[ $? == "0" ]]; then
+ SUPPORTED_FLAGS="$SUPPORTED_FLAGS -mavx"
+ AC_MSG_RESULT([$CC supports -mavx])
+ fi
-# Detect the SIMD features supported by both the compiler and the CPU
-SIMD_FLAGS=""
-cat "$srcdir/get_flags_from_cpuid.c" \
- | sed "s/FLAGSFROMAUTOCONF/${SUPPORTED_FLAGS}/" \
- | $CC -x c -g - -o get_flags_from_cpuid
-if [[ -e ./get_flags_from_cpuid ]]; then
- chmod 755 get_flags_from_cpuid; ./get_flags_from_cpuid; rm ./get_flags_from_cpuid
- if [[ -e compiler_flags ]]; then
- SIMD_FLAGS=`cat compiler_flags`
- rm -f compiler_flags
- else
- AC_MSG_WARN([Could not run the CPUID detection program])
- fi
-else
- AC_MSG_WARN([Could not compile the CPUID detection program])
-fi
+ # Detect the SIMD features supported by both the compiler and the CPU
+ SIMD_FLAGS=""
+ cat "$srcdir/get_flags_from_cpuid.c" \
+ | sed "s/FLAGSFROMAUTOCONF/${SUPPORTED_FLAGS}/" \
+ | $CC -x c -g - -o get_flags_from_cpuid
+ if [[ -e ./get_flags_from_cpuid ]]; then
+ chmod 755 get_flags_from_cpuid
+ ./get_flags_from_cpuid
+ rm ./get_flags_from_cpuid
+ if [[ -e compiler_flags ]]; then
+ SIMD_FLAGS=`cat compiler_flags`
+ rm -f compiler_flags
+ else
+ AC_MSG_WARN([Could not run the CPUID detection program])
+ fi
+ else
+ AC_MSG_WARN([Could not compile the CPUID detection program])
+ fi
-AC_MSG_RESULT([Generating with SIMD flags: $SIMD_FLAGS])
-CFLAGS="$CFLAGS $SIMD_FLAGS"
+ AC_MSG_RESULT([Generating with SIMD flags: $SIMD_FLAGS])
+ CFLAGS="$CFLAGS $SIMD_FLAGS"
+fi
# Certain code may be dependent on 32 vs. 64-bit arch, so add a
# flag for 64-bit
@@ -231,7 +244,7 @@ AM_CONDITIONAL(HAVE_DOXYGEN, $DOXYGEN)
AC_SUBST(HAVE_DOXYGEN)
dnl Let people disable the doxygen stuff.
-AC_ARG_ENABLE(doxygen, [ --enable-doxygen Use doxygen to build documentation (default=auto)],
+AC_ARG_ENABLE(doxygen, [ --enable-doxygen use doxygen to build documentation (default=auto)],
enable_doxygen="$enableval",
enable_doxygen=auto)