Hi folks.

Here the promised patches to add support for adding a power7 optimized arch to ppc64 for rpm and yum.

It's pretty similar to the ARM neon support code from dgilmore, only that i needed to add the detection properly in rpm as well.

I've tested them to some degree with a local repository containing packages build with --target ppc64p7 and then installing, removing and updating the respective package. Selection worked as expected, preferred ppc64p7 obviously on a Power7 box.

The detection code is a bit rough, both in yum and rpm, but i didn't want to manually parse the C struct from /proc/self/auxv.

Let me know what you think of them. The toolchain guys i spoke with at least were already pretty curious about it as they'd like to use it at some point as well.

I'm on PTO next week, so no rush :)

Thanks & regards, Phil

--
Philipp Knirsch              | Tel.:  +49-711-96437-470
Supervisor Core Services     | Fax.:  +49-711-96437-111
Red Hat GmbH                 | Email: Phil Knirsch <pknir...@redhat.com>
Hauptstaetterstr. 58         | Web:   http://www.redhat.com/
D-70178 Stuttgart, Germany
diff -up rpm-4.9.1.2/lib/rpmrc.c.ppc64p7 rpm-4.9.1.2/lib/rpmrc.c
--- rpm-4.9.1.2/lib/rpmrc.c.ppc64p7	2012-03-21 16:12:33.604001667 +0100
+++ rpm-4.9.1.2/lib/rpmrc.c	2012-03-21 16:54:12.517003479 +0100
@@ -3,6 +3,7 @@
 #include <stdarg.h>
 #if defined(__linux__) && defined(__powerpc__)
 #include <setjmp.h>
+#include <elf.h>
 #endif
 
 #if HAVE_SYS_UTSNAME_H
@@ -1223,6 +1224,22 @@ static void defaultMachine(const char **
 	}
 #	endif	/* arm*-linux */
 
+#	if defined(__linux__) && defined(__powerpc__)
+	{
+            Elf64_auxv_t *auxv;
+            extern char **environ;
+            char **envp = environ;
+
+            while(*envp++ != NULL);
+
+            for (auxv = (Elf64_auxv_t *)envp; auxv->a_type != AT_NULL; auxv++) {
+                if( auxv->a_type == AT_PLATFORM && strcmp((char *) auxv->a_un.a_val, "power7") == 0) {
+                    strcpy(un.machine, "ppc64p7");
+                }
+            }
+	}
+#	endif	/* ppc64*-linux */
+
 #	if defined(__GNUC__) && defined(__alpha__)
 	{
 	    unsigned long amask, implver;
diff -up rpm-4.9.1.2/rpmrc.in.ppc64p7 rpm-4.9.1.2/rpmrc.in
--- rpm-4.9.1.2/rpmrc.in.ppc64p7	2012-03-21 16:12:33.610001661 +0100
+++ rpm-4.9.1.2/rpmrc.in	2012-03-23 16:13:44.780001847 +0100
@@ -48,6 +48,7 @@ optflags: ppc32dy4 -O2 -g -fsigned-char
 optflags: ppciseries -O2 -g -fsigned-char
 optflags: ppcpseries -O2 -g -fsigned-char
 optflags: ppc64 -O2 -g -fsigned-char
+optflags: ppc64p7 -O3 -mtune=power7 -mcpu=power7 -g -fsigned-char
 
 optflags: parisc -O2 -g -mpa-risc-1-0
 optflags: hppa1.0 -O2 -g -mpa-risc-1-0
@@ -161,6 +162,7 @@ arch_canon:	s390x: s390x	15
 arch_canon:	ppc64:	ppc64	16
 arch_canon:    ppc64pseries: ppc64pseries  16
 arch_canon:    ppc64iseries: ppc64iseries  16
+arch_canon:    ppc64p7: ppc64p7  16
 
 arch_canon:	sh: sh		17
 arch_canon:	sh3: sh3	17
@@ -243,6 +245,7 @@ buildarchtranslate: ppciseries: ppc
 buildarchtranslate: ppcpseries: ppc
 buildarchtranslate: ppc64iseries: ppc64
 buildarchtranslate: ppc64pseries: ppc64
+buildarchtranslate: ppc64p7: ppc64
 
 buildarchtranslate: armv3l: armv3l
 buildarchtranslate: armv4b: armv4b
@@ -313,6 +316,7 @@ arch_compat: ppc: rs6000
 arch_compat: rs6000: noarch fat
 arch_compat: ppc64pseries: ppc64
 arch_compat: ppc64iseries: ppc64
+arch_compat: ppc64p7: ppc64
 
 arch_compat: sun4c: sparc
 arch_compat: sun4d: sparc
@@ -436,6 +440,7 @@ buildarch_compat: ppc: noarch fat
 buildarch_compat: ppc64: noarch fat
 buildarch_compat: ppc64pseries: ppc64
 buildarch_compat: ppc64iseries: ppc64
+buildarch_compat: ppc64p7: ppc64
 
 buildarch_compat: mips: noarch
 buildarch_compat: mipsel: noarch
diff -up yum-3.4.3/rpmUtils/arch.py.ppc64p7 yum-3.4.3/rpmUtils/arch.py
--- yum-3.4.3/rpmUtils/arch.py.ppc64p7	2012-03-23 19:06:05.554002837 +0100
+++ yum-3.4.3/rpmUtils/arch.py	2012-03-23 19:06:09.143997990 +0100
@@ -2,6 +2,8 @@
 #
 
 import os
+import subprocess
+import tempfile
 import rpm
 
 _ppc64_native_is_best = True
@@ -31,6 +33,7 @@ arches = {
     "ia32e": "x86_64",
     
     # ppc
+    "ppc64p7": "ppc64",
     "ppc64pseries": "ppc64",
     "ppc64iseries": "ppc64",    
     "ppc64": "ppc",
@@ -260,13 +260,27 @@ def getCanonPPCArch(arch):
         if line.find("machine") != -1:
             machine = line.split(':')[1]
             break
-    if machine is None:
+
+    platform = None
+    so = tempfile.NamedTemporaryFile(mode="rw+b")
+    obj = subprocess.Popen(["LD_SHOW_AUXV=1 /bin/true"], shell=True, close_fds=True, stdout=so.file)
+    obj.wait()
+    so.file.seek(0, 0)
+    for line in so.readlines():
+        if line.find("AT_PLATFORM:") != -1:
+            platform = line.split(':')[1]
+
+    if machine is None and platform is None:
         return arch
 
-    if machine.find("CHRP IBM") != -1:
-        return "ppc64pseries"
-    if machine.find("iSeries") != -1:
-        return "ppc64iseries"
+    if platform != None and platform.find("power7") != -1:
+        return "ppc64p7"
+
+    if machine != None:
+        if machine.find("CHRP IBM") != -1:
+            return "ppc64pseries"
+        if machine.find("iSeries") != -1:
+            return "ppc64iseries"
     return arch
 
 def getCanonSPARCArch(arch):
_______________________________________________
Yum-devel mailing list
Yum-devel@lists.baseurl.org
http://lists.baseurl.org/mailman/listinfo/yum-devel

Reply via email to