[PATCH] powerpc: Automatically guess --with-cpu value

Carlos Eduardo Seo cseo@linux.vnet.ibm.com
Wed Jan 6 19:57:00 GMT 2016


On 12/24/15 11:34 AM, Tulio Magno Quites Machado Filho wrote:
> 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
>

Good idea. Need to compute the POWER6X case as well.

Here's another try.

-- 
Carlos Eduardo Seo
Software Engineer - Linux on Power Toolchain
cseo@linux.vnet.ibm.com
-------------- next part --------------
>From 83698e7a993354a5e9c0d7d68e14af9ade3d77f8 Mon Sep 17 00:00:00 2001
From: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Date: Sun, 15 Nov 2015 19:31:30 -0200
Subject: [PATCH] powerpc: Automatic CPU detection in preconfigure

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.

2016-01-06  Carlos Eduardo Seo  <cseo@linux.vnet.ibm.com>

	* sysdeps/powerpc/preconfigure: Added a check to identify the CPU value
	and set it for the --with-cpu configure parameter.
---
 sysdeps/powerpc/preconfigure | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/sysdeps/powerpc/preconfigure b/sysdeps/powerpc/preconfigure
index 0c6fdde..83f254f 100644
--- a/sysdeps/powerpc/preconfigure
+++ b/sysdeps/powerpc/preconfigure
@@ -15,3 +15,39 @@ 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 |
+	  sed -n 's/^#define \(_ARCH_PWR[0-9].*\) .*$/\1/p' |
+	  sort -Vr | head -n 1`
+
+# Set --with-cpu as appropriate.
+  case "$archcpu" in
+  _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_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
+fi
-- 
2.5.4 (Apple Git-61)



More information about the Libc-alpha mailing list