[MPlayer-dev-eng] [Patch] Runtime cpu detection bug fix
Fredrik Kuivinen
freku045 at student.liu.se
Tue Mar 19 16:59:19 CET 2002
Hi
The current runtime cpu detection code in configure sets -march to something
the processor the configure script is running on would like. However the
executables produced with, for example, gcc -march=i686 won't work on older
processors.
The current configure don't force compilation of mmx, sse etc if runtime
cpu detection is used. The patch fixes that too.
/ Fredrik Kuivinen
-------------- next part --------------
Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.409
diff -u -3 -p -r1.409 configure
--- configure 18 Mar 2002 23:30:04 -0000 1.409
+++ configure 19 Mar 2002 16:05:03 -0000
@@ -221,6 +221,7 @@ done # for parm in ...
# 1st pass checking for vital options
_cc=gcc
+_runtime_cpudetection=yes
test "$CC" && _cc="$CC"
_as=auto
_enable_xp=no
@@ -262,6 +263,12 @@ for ac_option do
--with-extralibdir=*)
_ld_extra=-L`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -L,g'`
;;
+ --enable-runtime-cpudetection)
+ _runtime_cpudetection=yes
+ ;;
+ --disable-runtime-cpudetection)
+ _runtime_cpudetection=no
+ ;;
esac
done
@@ -495,9 +502,17 @@ if x86 ; then
echocheck "CPU type"
echores "$pname"
+ if test "$_runtime_cpudetection" = yes ; then
+ _mmx=yes
+ _3dnow=yes
+ _3dnowex=yes
+ _mmx2=yes
+ _sse=yes
+ _sse2=yes
+ _mtrr=yes
+ fi
fi
-
if [ "$host_arch" = alpha ]; then
echocheck "CPU type"
cat > $TMPC << EOF
@@ -571,40 +586,47 @@ cat > $TMPC << EOF
int main(void) { return 0; }
EOF
- if test "$proc" = "k7" ; then
- cc_check -march=$proc -mcpu=$proc || proc=athlon
- fi
- if test "$proc" = "athlon" ; then
- cc_check -march=$proc -mcpu=$proc || proc=pentiumpro
- fi
- if test "$proc" = "k6" ; then
- cc_check -march=$proc -mcpu=$proc || proc=k5
- fi
- if test "$proc" = "k5" ; then
- cc_check -march=$proc -mcpu=$proc || proc=pentium
- fi
- if test "$proc" = "i686" ; then
- cc_check -march=$proc -mcpu=$proc || proc=pentiumpro
- fi
- if test "$proc" = "pentiumpro" ; then
- cc_check -march=$proc -mcpu=$proc || proc=pentium
- fi
- if test "$proc" = "pentium" ; then
- cc_check -march=$proc -mcpu=$proc || proc=i486
- fi
- if test "$proc" = "i486" ; then
- cc_check -march=$proc -mcpu=$proc || proc=i386
- fi
- if test "$proc" = "i386" ; then
- cc_check -march=$proc -mcpu=$proc || proc=error
- fi
- if test "$proc" = "error" ; then
- die "Your $_cc does not support even \"i386\" for '-march' and '-mcpu'."
+ if test "_$runtime_cpudetection" = "no" ; then
+ if test "$proc" = "k7" ; then
+ cc_check -march=$proc -mcpu=$proc || proc=athlon
+ fi
+ if test "$proc" = "athlon" ; then
+ cc_check -march=$proc -mcpu=$proc || proc=pentiumpro
+ fi
+ if test "$proc" = "k6" ; then
+ cc_check -march=$proc -mcpu=$proc || proc=k5
+ fi
+ if test "$proc" = "k5" ; then
+ cc_check -march=$proc -mcpu=$proc || proc=pentium
+ fi
+ if test "$proc" = "i686" ; then
+ cc_check -march=$proc -mcpu=$proc || proc=pentiumpro
+ fi
+ if test "$proc" = "pentiumpro" ; then
+ cc_check -march=$proc -mcpu=$proc || proc=pentium
+ fi
+ if test "$proc" = "pentium" ; then
+ cc_check -march=$proc -mcpu=$proc || proc=i486
+ fi
+ if test "$proc" = "i486" ; then
+ cc_check -march=$proc -mcpu=$proc || proc=i386
+ fi
+ if test "$proc" = "i386" ; then
+ cc_check -march=$proc -mcpu=$proc || proc=error
+ fi
+ if test "$proc" = "error" ; then
+ die "Your $_cc does not support even \"i386\" for '-march' and '-mcpu'."
+ fi
+
+ _march="-march=$proc"
+ _mcpu="-mcpu=$proc"
+ else
+ # i686 is probably the most common cpu
+ _mcpu="-mcpu=i686"
+ _march=""
+ cc_check -mcpu=i686 || _mcpu=""
fi
- _march="-march=$proc"
- _mcpu="-mcpu=$proc"
-
## Gabucino : --target takes effect here (hopefully...) by overwriting
## autodetected mcpu/march parameters
if test "$_target" ; then
@@ -694,7 +716,7 @@ _binutils=no
$_as libac3/downmix/downmix_i386.S -o $TMPO > /dev/null 2>&1 && _binutils=yes
echores "$_binutils"
-if x86 ; then
+if x86 && test "$_runtime_cpudetection" == "no" ; then
extcheck() {
if test "$1" = yes ; then
echocheck "kernel support of $2"
@@ -797,7 +819,6 @@ _language=en
_shm=auto
_linux_devfs=no
_i18n=no
-_runtime_cpudetection=yes
for ac_option do
case "$ac_option" in
@@ -811,15 +832,14 @@ for ac_option do
--disable-static*) ;;
--with-extraincdir=*) ;;
--with-extralibdir=*) ;;
-
+ --enable-runtime-cpudetection) ;;
+ --disable-runtime-cpudetection) ;;
# Real 2nd pass
--enable-mencoder) _mencoder=yes ;;
--disable-mencoder) _mencoder=no ;;
--enable-i18n) _i18n=yes ;;
--disable-i18n) _i18n=no ;;
- --enable-runtime-cpudetection) _runtime_cpudetection=yes ;;
- --disable-runtime-cpudetection) _runtime_cpudetection=no ;;
--enable-x11) _x11=yes ;;
--disable-x11) _x11=no ;;
--enable-xv) _xv=yes ;;
More information about the MPlayer-dev-eng
mailing list