[PATCH] osmo-trx[master]: buildenv: Make build CPU invariant

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Thu Mar 16 18:00:02 UTC 2017


Review at  https://gerrit.osmocom.org/2102

buildenv: Make build CPU invariant

Currently the build environment checks which extension the current
CPU supports and picks the compiler flags accordingly.

If the build is happening on a machine that does not support the
extensions we need (SSE3, SSE4.1), the binary will lack those
extensions, even if its intended to be used on a more powerful
machine that would support the extensions.

This commit removes the CPU tests from the build process.

Change-Id: Ic913aa13c23c348ae62e78c9dfd6ed8b0a62798c
---
M config/ax_ext.m4
1 file changed, 20 insertions(+), 96 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/02/2102/1

diff --git a/config/ax_ext.m4 b/config/ax_ext.m4
index fbd10cc..f453b2e 100644
--- a/config/ax_ext.m4
+++ b/config/ax_ext.m4
@@ -44,95 +44,19 @@
       AC_REQUIRE([AX_GCC_X86_AVX_XGETBV])
 
       AX_GCC_X86_CPUID(0x00000001)
-      ecx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 3`
-      edx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 4`
 
-      AC_CACHE_CHECK([whether mmx is supported], [ax_cv_have_mmx_ext],
-      [
-        ax_cv_have_mmx_ext=no
-        if test "$((0x$edx>>23&0x01))" = 1; then
-          ax_cv_have_mmx_ext=yes
-        fi
-      ])
-
-      AC_CACHE_CHECK([whether sse is supported], [ax_cv_have_sse_ext],
-      [
-        ax_cv_have_sse_ext=no
-        if test "$((0x$edx>>25&0x01))" = 1; then
-          ax_cv_have_sse_ext=yes
-        fi
-      ])
-
-      AC_CACHE_CHECK([whether sse2 is supported], [ax_cv_have_sse2_ext],
-      [
-        ax_cv_have_sse2_ext=no
-        if test "$((0x$edx>>26&0x01))" = 1; then
-          ax_cv_have_sse2_ext=yes
-        fi
-      ])
-
-      AC_CACHE_CHECK([whether sse3 is supported], [ax_cv_have_sse3_ext],
-      [
-        ax_cv_have_sse3_ext=no
-        if test "$((0x$ecx&0x01))" = 1; then
-          ax_cv_have_sse3_ext=yes
-        fi
-      ])
-
-      AC_CACHE_CHECK([whether ssse3 is supported], [ax_cv_have_ssse3_ext],
-      [
-        ax_cv_have_ssse3_ext=no
-        if test "$((0x$ecx>>9&0x01))" = 1; then
-          ax_cv_have_ssse3_ext=yes
-        fi
-      ])
-
-      AC_CACHE_CHECK([whether sse4.1 is supported], [ax_cv_have_sse41_ext],
-      [
-        ax_cv_have_sse41_ext=no
-        if test "$((0x$ecx>>19&0x01))" = 1; then
-          ax_cv_have_sse41_ext=yes
-        fi
-      ])
-
-      AC_CACHE_CHECK([whether sse4.2 is supported], [ax_cv_have_sse42_ext],
-      [
+	# NOTE: The CPU architecture is detected during runtime, and the
+	# implementation is optimized towards certain CPU extensions. Here
+	# we explicitly select the extensions we use within the code
+	ax_cv_have_mmx_ext=no
+	ax_cv_have_sse_ext=no
+	ax_cv_have_sse2_ext=no
+        ax_cv_have_sse3_ext=yes
+	ax_cv_have_ssse3_ext=no
+        ax_cv_have_sse41_ext=yes
         ax_cv_have_sse42_ext=no
-        if test "$((0x$ecx>>20&0x01))" = 1; then
-          ax_cv_have_sse42_ext=yes
-        fi
-      ])
-
-      AC_CACHE_CHECK([whether avx is supported by processor], [ax_cv_have_avx_cpu_ext],
-      [
         ax_cv_have_avx_cpu_ext=no
-        if test "$((0x$ecx>>28&0x01))" = 1; then
-          ax_cv_have_avx_cpu_ext=yes
-        fi
-      ])
-
-      if test x"$ax_cv_have_avx_cpu_ext" = x"yes"; then
-        AX_GCC_X86_AVX_XGETBV(0x00000000)
-
-        xgetbv_eax="0"
-        if test x"$ax_cv_gcc_x86_avx_xgetbv_0x00000000" != x"unknown"; then
-          xgetbv_eax=`echo $ax_cv_gcc_x86_avx_xgetbv_0x00000000 | cut -d ":" -f 1`
-        fi
-
-        AC_CACHE_CHECK([whether avx is supported by operating system], [ax_cv_have_avx_ext],
-        [
-          ax_cv_have_avx_ext=no
-
-          if test "$((0x$ecx>>27&0x01))" = 1; then
-            if test "$((0x$xgetbv_eax&0x6))" = 6; then
-              ax_cv_have_avx_ext=yes
-            fi
-          fi
-        ])
-        if test x"$ax_cv_have_avx_ext" = x"no"; then
-          AC_MSG_WARN([Your processor supports AVX, but your operating system doesn't])
-        fi
-      fi
+	ax_cv_have_avx_ext=no
 
       if test "$ax_cv_have_mmx_ext" = yes; then
         AX_CHECK_COMPILE_FLAG(-mmmx, ax_cv_support_mmx_ext=yes, [])
@@ -140,7 +64,7 @@
           SIMD_FLAGS="$SIMD_FLAGS -mmmx"
           AC_DEFINE(HAVE_MMX,,[Support mmx instructions])
         else
-          AC_MSG_WARN([Your processor supports mmx instructions but not your compiler, can you try another compiler?])
+          AC_MSG_WARN([Your compiler does not support mmx instructions, can you try another compiler?])
         fi
       fi
 
@@ -150,7 +74,7 @@
           SIMD_FLAGS="$SIMD_FLAGS -msse"
           AC_DEFINE(HAVE_SSE,,[Support SSE (Streaming SIMD Extensions) instructions])
         else
-          AC_MSG_WARN([Your processor supports sse instructions but not your compiler, can you try another compiler?])
+          AC_MSG_WARN([Your compiler does not support sse instructions, can you try another compiler?])
         fi
       fi
 
@@ -160,7 +84,7 @@
           SIMD_FLAGS="$SIMD_FLAGS -msse2"
           AC_DEFINE(HAVE_SSE2,,[Support SSE2 (Streaming SIMD Extensions 2) instructions])
         else
-          AC_MSG_WARN([Your processor supports sse2 instructions but not your compiler, can you try another compiler?])
+          AC_MSG_WARN([Your compiler does not support sse2 instructions, can you try another compiler?])
         fi
       fi
 
@@ -170,7 +94,7 @@
           SIMD_FLAGS="$SIMD_FLAGS -msse3"
           AC_DEFINE(HAVE_SSE3,,[Support SSE3 (Streaming SIMD Extensions 3) instructions])
         else
-          AC_MSG_WARN([Your processor supports sse3 instructions but not your compiler, can you try another compiler?])
+          AC_MSG_WARN([Your compiler does not support sse3 instructions, can you try another compiler?])
         fi
       fi
 
@@ -180,7 +104,7 @@
           SIMD_FLAGS="$SIMD_FLAGS -mssse3"
           AC_DEFINE(HAVE_SSSE3,,[Support SSSE3 (Supplemental Streaming SIMD Extensions 3) instructions])
         else
-          AC_MSG_WARN([Your processor supports ssse3 instructions but not your compiler, can you try another compiler?])
+          AC_MSG_WARN([Your compiler does not support ssse3 instructions, can you try another compiler?])
         fi
       fi
 
@@ -188,9 +112,9 @@
         AX_CHECK_COMPILE_FLAG(-msse4.1, ax_cv_support_sse41_ext=yes, [])
         if test x"$ax_cv_support_sse41_ext" = x"yes"; then
           SIMD_FLAGS="$SIMD_FLAGS -msse4.1"
-          AC_DEFINE(HAVE_SSE4_1,,[Support SSSE4.1 (Streaming SIMD Extensions 4.1) instructions])
+          AC_DEFINE(HAVE_SSE4_1,,[Support SSE4.1 (Streaming SIMD Extensions 4.1) instructions])
         else
-          AC_MSG_WARN([Your processor supports sse4.1 instructions but not your compiler, can you try another compiler?])
+          AC_MSG_WARN([Your compiler does not support sse4.1 instructions, can you try another compiler?])
         fi
       fi
 
@@ -198,9 +122,9 @@
         AX_CHECK_COMPILE_FLAG(-msse4.2, ax_cv_support_sse42_ext=yes, [])
         if test x"$ax_cv_support_sse42_ext" = x"yes"; then
           SIMD_FLAGS="$SIMD_FLAGS -msse4.2"
-          AC_DEFINE(HAVE_SSE4_2,,[Support SSSE4.2 (Streaming SIMD Extensions 4.2) instructions])
+          AC_DEFINE(HAVE_SSE4_2,,[Support SSE4.2 (Streaming SIMD Extensions 4.2) instructions])
         else
-          AC_MSG_WARN([Your processor supports sse4.2 instructions but not your compiler, can you try another compiler?])
+          AC_MSG_WARN([Your compiler does not support sse4.2 instructions, can you try another compiler?])
         fi
       fi
 
@@ -210,7 +134,7 @@
           SIMD_FLAGS="$SIMD_FLAGS -mavx"
           AC_DEFINE(HAVE_AVX,,[Support AVX (Advanced Vector Extensions) instructions])
         else
-          AC_MSG_WARN([Your processor supports avx instructions but not your compiler, can you try another compiler?])
+          AC_MSG_WARN([Your compiler does not support avx instructions, can you try another compiler?])
         fi
       fi
 

-- 
To view, visit https://gerrit.osmocom.org/2102
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic913aa13c23c348ae62e78c9dfd6ed8b0a62798c
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list