Web lists-archives.com

[MPlayer-dev-eng] [PATCH] Support compiling without CPU optimization




Those who have configured their gcc to already compile CPU specific,
optimized code don't want any automatic optimization by the use of
-march/-mtune/-mcpu.

Add an option to disable optimization.

Ingo
--- a/configure	2015-05-28 01:11:34.000000000 +0200
+++ b/configure	2015-05-28 18:46:00.000000000 +0200
@@ -544,6 +544,7 @@
 
 Miscellaneous options:
   --enable-runtime-cpudetection    enable runtime CPU detection [disable]
+  --disable-optimization disable compile time CPU code optimization [enable]
   --enable-cross-compile enable cross-compilation [autodetect]
   --cc=COMPILER          C compiler to build MPlayer [gcc]
   --host-cc=COMPILER     C compiler for tools needed while building [gcc]
@@ -656,6 +657,7 @@
 _nm=auto
 _yasm=yasm
 _runtime_cpudetection=no
+_optimization=yes
 _cross_compile=auto
 _prefix="/usr/local"
 ffmpeg_a=auto
@@ -1004,6 +1006,8 @@
     ;;
   --enable-runtime-cpudetection)    _runtime_cpudetection=yes   ;;
   --disable-runtime-cpudetection)   _runtime_cpudetection=no    ;;
+  --enable-optimization)            _optimization=yes           ;;
+  --disable-optimization)           _optimization=no            ;;
   --enable-cross-compile)           _cross_compile=yes          ;;
   --disable-cross-compile)          _cross_compile=no           ;;
   --enable-mencoder)    _mencoder=yes   ;;
@@ -2170,9 +2174,11 @@
         cpuopt=-mcpu
     fi
 
-    echocheck "GCC & CPU optimization abilities"
+  test "$_optimization" = "no" && proc=none
+
+  echocheck "GCC & CPU optimization"
   if test "$_runtime_cpudetection" = no ; then
-    if test $cc_vendor != "intel" && test $cc_vendor != "clang" ; then
+    if test "$_optimization" = "yes" && test $cc_vendor != "intel" && test $cc_vendor != "clang" ; then
       cflag_check -march=native && proc=native
     fi
     if test "$proc" = "amdfam10"; then
@@ -2218,13 +2224,13 @@
       cflag_check -march=$proc $cpuopt=$proc  || proc=i386
     fi
     if test "$proc" = "i386" ; then
-      cflag_check -march=$proc $cpuopt=$proc  || proc=error
+      cflag_check -march=$proc $cpuopt=$proc  || proc=none
     fi
-    if test "$proc" = "error" ; then
-        echores "CPU optimization disabled. CPU not recognized or your compiler is too old."
+    if test "$proc" = "none" ; then
+      test "$_optimization" = "yes" && echores "CPU optimization disabled. CPU not recognized or your compiler is too old."
       _mcpu=""
       _march=""
-      _optimizing=""
+      _optimizing="$proc"
     elif test "$proc" = "i586-i686"; then
       _march="-march=i586"
       _mcpu="$cpuopt=i686"
@@ -2332,14 +2338,16 @@
         esac
         ;;
       *)
-        proc=error;;
+        proc=none;;
       esac
     fi # test "$_runtime_cpudetection" = no
 
-    echocheck "GCC & CPU optimization abilities"
+    test "$_optimization" = "no" && proc=none
+
+    echocheck "GCC & CPU optimization"
     # This is a stripped-down version of the i386 fallback.
     if test "$_runtime_cpudetection" = no ; then
-      if test $cc_vendor != "intel" && test $cc_vendor != "clang" ; then
+      if test "$_optimization" = "yes" && test $cc_vendor != "intel" && test $cc_vendor != "clang" ; then
         cflag_check -march=native && proc=native
       fi
       # --- AMD processors ---
@@ -2353,7 +2361,7 @@
       # versions don't really support 64-bit on amd64.
       # Is this a valid assumption? -Corey
       if test "$proc" = "athlon-xp"; then
-        cflag_check -march=$proc $cpuopt=$proc || proc=error
+        cflag_check -march=$proc $cpuopt=$proc || proc=none
       fi
       # --- Intel processors ---
       if test "$proc" = "atom" || test "$proc" = "corei7-avx" || test "$proc" = "corei7"; then
@@ -2369,13 +2377,13 @@
         cflag_check -march=$proc $cpuopt=$proc || proc=pentium4
       fi
       if test "$proc" = "pentium4"; then
-        cflag_check -march=$proc $cpuopt=$proc || proc=error
+        cflag_check -march=$proc $cpuopt=$proc || proc=none
       fi
 
       _march="-march=$proc"
       _mcpu="$cpuopt=$proc"
-      if test "$proc" = "error" ; then
-        echores "CPU optimization disabled. CPU not recognized or your compiler is too old."
+      if test "$proc" = "none" ; then
+        test "$_optimization" = "yes" && echores "CPU optimization disabled. CPU not recognized or your compiler is too old."
         _mcpu=""
         _march=""
       fi
@@ -2503,7 +2511,9 @@
         echores "$proc"
     fi
 
-    echocheck "GCC & CPU optimization abilities"
+    test "$_optimization" = "no" && proc=none
+
+    echocheck "GCC & CPU optimization"
 
     if test -n "$proc"; then
         case "$proc" in
@@ -2596,14 +2606,16 @@
     esac
     echores "$proc"
 
-    echocheck "GCC & CPU optimization abilities"
+    test "$_optimization" = "no" && proc=none
+
+    echocheck "GCC & CPU optimization"
     if test "$proc" = "ev68" ; then
       cc_check -mcpu=$proc || proc=ev67
     fi
     if test "$proc" = "ev67" ; then
       cc_check -mcpu=$proc || proc=ev6
     fi
-    _mcpu="-mcpu=$proc"
+    test "$_optimization" = "yes" && _mcpu="-mcpu=$proc"
     echores "$proc"
 
     test $_fast_clz = "auto" && _fast_clz=yes
_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng