[PATCH-v2] powerpc: Automatic CPU detection in preconfigure

Message ID 5706D1B7.80500@linux.vnet.ibm.com
State Superseded
Delegated to: Florian Weimer
Headers

Commit Message

Carlos Eduardo Seo April 7, 2016, 9:31 p.m. UTC
  Added a check to detect the CPU value in preconfigure, so that glibc is 
built with the correct --with-cpu value. This is only done for Power 
servers.

This should address the sort issue pointed by Andreas.

Thanks,
  

Comments

Florian Weimer April 8, 2016, 12:12 p.m. UTC | #1
On 04/07/2016 11:31 PM, Carlos Eduardo Seo wrote:
> +# Note if you add patterns here you must ensure that an appropriate directory
> +# exists in sysdeps/powerpc

> +  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*)

Does this mean if GCC adds _ARCH_PWR19, glibc configure will no longer run?

In this case, I think you have to use a non-wildcard pattern here.

Thanks,
Florian
  

Patch

diff --git a/sysdeps/powerpc/preconfigure b/sysdeps/powerpc/preconfigure
index 0c6fdde..b0e036c 100644
--- a/sysdeps/powerpc/preconfigure
+++ b/sysdeps/powerpc/preconfigure
@@ -15,3 +15,35 @@  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 "$with_cpu"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: --with-cpu not set. Trying to detect CPU." >&5
+    $as_echo "$as_me: --with-cpu not set. Trying to detect CPU." >&6;}
+  archcpu=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
+	   grep "#define _ARCH_PWR" | sed "s/^.*PWR//" | sed "s/ 1$//" |
+	   sort -nr | head -n 1 | sed "s/^/_ARCH_PWR/"
+
+# Set --with-cpu as appropriate.
+  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 | sed "s/_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
+fi