diff mbox

powerpc: Automatically guess --with-cpu value

Message ID 5679E63E.8070101@linux.vnet.ibm.com
State New
Headers show

Commit Message

cseo Dec. 23, 2015, 12:09 a.m. UTC
On 12/22/15 2:44 PM, Tulio Magno Quites Machado Filho wrote:
>
> You have to check if the user passed --with-cpu before doing this.
> If you don't do that you'll overwrite the value passed by the user.
>

Good catch.

Here's the same patch fixed.

Thanks,

Comments

Tulio Magno Quites Machado Filho Dec. 24, 2015, 1:34 p.m. UTC | #1
Almost there.  ;-)

Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> writes:

> diff --git a/sysdeps/powerpc/preconfigure b/sysdeps/powerpc/preconfigure
> index 0c6fdde..4f91add 100644
> --- a/sysdeps/powerpc/preconfigure
> +++ b/sysdeps/powerpc/preconfigure
> @@ -15,3 +15,57 @@ powerpc*)
>    rm -f conftest.i
>    ;;
>  esac
> +
> +# Lets ask the compiler which Power processor we've got, in case the user did
> +# not choose a --with-cpu value.
> +# Note if you add patterns here you must ensure that an appropriate directory
> +# exists in sysdeps/powerpc
> +if test -z "$submachine"; then

$submachine will be "" when the user pass --with-cpu=no, which means the user
wants to force the default submachine.
So, I suspect the right variable is $with_cpu.

> +# Set --with-cpu as appropriate.
> +  case "$archcpu" in
> +  _ARCH_PWR8)
> +    submachine="power8"
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
> +$as_echo "$as_me:  CPU identified as $submachine" >&6;}
> +    ;;
> +  _ARCH_PWR7)
> +    submachine="power7"
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
> +$as_echo "$as_me:  CPU identified as $submachine" >&6;}
> +    ;;
> +  _ARCH_PWR6X)
> +    submachine="power6x"
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
> +$as_echo "$as_me:  CPU identified as $submachine" >&6;}
> +    ;;
> +  _ARCH_PWR6)
> +    submachine="power6"
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
> +$as_echo "$as_me:  CPU identified as $submachine" >&6;}
> +    ;;
> +  _ARCH_PWR5X)
> +    submachine="power5+"
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
> +$as_echo "$as_me:  CPU identified as $submachine" >&6;}
> +    ;;
> +  _ARCH_PWR5)
> +    submachine="power5"
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
> +$as_echo "$as_me:  CPU identified as $submachine" >&6;}
> +    ;;
> +  _ARCH_PWR4)
> +    submachine="power4"
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
> +$as_echo "$as_me:  CPU identified as $submachine" >&6;}
> +    ;;
> +  *)
> +    submachine=""
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU not identified; using default" >&5
> +$as_echo "$as_me:  CPU not identified; using default" >&6;}
> +    ;;
> +  esac

What about this instead?

  case "$archcpu" in
  _ARCH_PWR5X)
    submachine="power5+"
    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
      $as_echo "$as_me:  CPU identified as $submachine" >&6;}
    ;;
  _ARCH_PWR*)
  submachine=$(echo ${archcpu/_ARCH_PWR/power} | tr '[:upper:]' '[:lower:]')
    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
      $as_echo "$as_me:  CPU identified as $submachine" >&6;}
    ;;
  *)
    submachine=""
    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU not identified; using default" >&5
      $as_echo "$as_me:  CPU not identified; using default" >&6;}
    ;;
  esac
diff mbox

Patch

diff --git a/sysdeps/powerpc/preconfigure b/sysdeps/powerpc/preconfigure
index 0c6fdde..4f91add 100644
--- a/sysdeps/powerpc/preconfigure
+++ b/sysdeps/powerpc/preconfigure
@@ -15,3 +15,57 @@  powerpc*)
   rm -f conftest.i
   ;;
 esac
+
+# Lets ask the compiler which Power processor we've got, in case the user did
+# not choose a --with-cpu value.
+# Note if you add patterns here you must ensure that an appropriate directory
+# exists in sysdeps/powerpc
+if test -z "$submachine"; then
+  archcpu=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
+	  sed -n 's/^#define \(_ARCH_PWR[0-9].*\) .*$/\1/p' |
+	  sort -r | head -n 1`
+
+# Set --with-cpu as appropriate.
+  case "$archcpu" in
+  _ARCH_PWR8)
+    submachine="power8"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
+$as_echo "$as_me:  CPU identified as $submachine" >&6;}
+    ;;
+  _ARCH_PWR7)
+    submachine="power7"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
+$as_echo "$as_me:  CPU identified as $submachine" >&6;}
+    ;;
+  _ARCH_PWR6X)
+    submachine="power6x"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
+$as_echo "$as_me:  CPU identified as $submachine" >&6;}
+    ;;
+  _ARCH_PWR6)
+    submachine="power6"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
+$as_echo "$as_me:  CPU identified as $submachine" >&6;}
+    ;;
+  _ARCH_PWR5X)
+    submachine="power5+"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
+$as_echo "$as_me:  CPU identified as $submachine" >&6;}
+    ;;
+  _ARCH_PWR5)
+    submachine="power5"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
+$as_echo "$as_me:  CPU identified as $submachine" >&6;}
+    ;;
+  _ARCH_PWR4)
+    submachine="power4"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
+$as_echo "$as_me:  CPU identified as $submachine" >&6;}
+    ;;
+  *)
+    submachine=""
+    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU not identified; using default" >&5
+$as_echo "$as_me:  CPU not identified; using default" >&6;}
+    ;;
+  esac
+fi