This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] powerpc: Automatic CPU detection in preconfigure


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

Added a check to detect the CPU value in preconfigure, so that glibc is
built with the correct --with-cpu value.

2017-02-08  Carlos Eduardo Seo  <cseo@linux.vnet.ibm.com>
	    Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>

	* sysdeps/powerpc/preconfigure: Automatically configure
	--with-cpu value based on compiler target cpu.
---
 sysdeps/powerpc/preconfigure | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/sysdeps/powerpc/preconfigure b/sysdeps/powerpc/preconfigure
index 0c6fdde..e269616 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.
+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=`echo "int foo () { return 0; }" \
+	   | $CC $CFLAGS $CPPFLAGS -S -frecord-gcc-switches -xc -o - - \
+	   | grep -E "\.ascii.*mcpu" | sed "s/.*mcpu=\(.*\)\"/\1/"`
+
+  # Set --with-cpu as appropriate.
+  # Note if you add patterns here you must ensure that an appropriate
+  # directory exists in sysdeps/powerpc.
+  case "$archcpu" in
+  405|405fp)
+    submachine="405"
+    ;;
+  440|440fp)
+    submachine="440"
+    ;;
+  476|476fp)
+    submachine="476"
+    ;;
+  e500mc|e500mc64)
+    submachine="e500"
+    ;;
+  a2|464|970|power*)
+    submachine=${archcpu}
+    ;;
+  *)
+  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.1.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]