On 10/19/2011 08:17 PM, Jon Masters wrote:
Folks,

I would like to come to some kind of resolution that works for us in the
Fedora ARM project, and continue the longer term planning for better
multiple ABI support, which it is clear won't be happening overnight.

It is my proposal that we temporarily carry the patch posted previously:

http://lists.rpm.org/pipermail/rpm-maint/2011-September/003078.html

Until such time as RPM has generic support for multiple ABIs. This is
very similar to that used in SPARC and so on, and we can conditionally
compile this away for builds that will target ARMv5, for example. I am
told it isn't worth reworking this to use HW_CAP (the existing stuff for
other architectures doesn't either) and that we might aswell leave the
current approach since it will eventually all get replaced anyway.

It's not my intention to shove this in now and forget about it, but we
need something from upstream for Fedora ARM, and there was previous
buy-in to carry this for the time being...can we do that please? :)

Oh, I meant carrying the patch in Fedora for now, just like the sparc-niagara patch is, conditionally applied if you need that. I dont see a huge value add putting it temporarily in upstream just to be able to say "its upstream" especially when upstream said its ok to carry it downstream for the time being :)

OTOH in the meantime I've played with the hwcaps approach a bit, if somebody can test whether the attached patch (diffed against 4.9.x since that's what you probably are working with, but should apply to HEAD too) actually works for ARM (and Sparc Niagara for that matter) that'd be swell. I dont have any meaningful way to test either arch.

HWCAP is not the holy grail either, this being a library we cannot rely on the auxiliary vector being available at the time we get to it, so it needs to read /proc ... which in turn might not be there. Of course in normal system it is, and we cache the value so if rpm is initialized before going into chroot (as typically is the case) then it can be reinitialized in the chroot without losing anything, but if initialization is attempted in an environment where /proc isn't mounted then its going to just fail :-/

        - Panu -
diff --git a/lib/rpmrc.c b/lib/rpmrc.c
index 1b47dc3..6a71923 100644
--- a/lib/rpmrc.c
+++ b/lib/rpmrc.c
@@ -17,6 +17,13 @@
 #define __power_pc() 0
 #endif
 
+#if defined(__linux)
+#if defined(__arm__) || defined(__sparc__) 
+#include <link.h>
+#define NEED_HWCAP 1
+#endif
+#endif
+
 #include <rpm/rpmlib.h>                        /* RPM_MACTABLE*, Rc-prototypes 
*/
 #include <rpm/rpmmacro.h>
 #include <rpm/rpmfileutil.h>
@@ -707,6 +714,40 @@ exit:
     return rc;
 }
 
+#if defined(NEED_HWCAP)
+/* hwcap defs are scattered in strange places, define what we need here */
+#define HWC_SPARC_BLKINIT      (1 << 6)
+#define HWC_ARM_NEON           (1 << 12)
+#define HWC_ARM_VFPv3          (1 << 13)
+
+static uint64_t hwcaps(uint64_t have_caps)
+{
+    static uint64_t cached_caps = 0;
+    static int oneshot = 1;
+
+    if (oneshot) {
+       int fd = open("/proc/self/auxv", O_RDONLY);
+
+       if (fd == -1) {
+           rpmlog(RPMLOG_WARNING,
+                  _("Failed to read auxiliary vector, /proc not mounted?\n"));
+       } else {
+           ElfW(auxv_t) auxv;
+           while (read(fd, &auxv, sizeof(auxv)) == sizeof(auxv)) {
+              if (auxv.a_type == AT_NULL)
+                   break;
+              if (auxv.a_type == AT_HWCAP) {
+                   cached_caps = auxv.a_un.a_val;
+                   break;
+               }
+           }
+           close(fd);
+       }
+       oneshot = 0; /* only try once even if it fails */
+    }
+    return have_caps ? (cached_caps & have_caps) : cached_caps;
+}
+#endif /* NEED_HWCAP */
 
 #      if defined(__linux__) && defined(__i386__)
 #include <setjmp.h>
@@ -1123,8 +1164,33 @@ static void defaultMachine(const char ** arch,
                personality(oldpers);
            }
        }
+
+       /* Supposed to detect Sun4v aka Niagara */
+       if (hwcaps(HWC_SPARC_BLKINIT)) {
+           if (rstreq(un.machine, "sparcv9") || rstreq(un.machine, "sparc")) {
+               strcpy(un.machine, "sparcv9v");
+           } else if (rstreq(un.machine, "sparc64")) {
+               strcpy(un.machine, "sparc64v");
+           }
+       }
 #      endif   /* sparc*-linux */
 
+#      if defined(__linux__) && defined(__arm__)
+       if (rstreq(un.machine, "armv7l")) {
+           if (hwcaps((HWC_ARM_NEON | HWC_ARM_VFPv3))) {
+               strcpy(un.machine, "armv7hnl");
+           } else if (hwcaps(HWC_ARM_VFPv3)) {
+               strcpy(un.machine, "armv7hl");
+           }
+       } else if (rstreq(un.machine, "armv6l")) {
+           if (hwcaps((HWC_ARM_NEON | HWC_ARM_VFPv3))) {
+               strcpy(un.machine, "armv6hnl");
+           } else if (hwcaps(HWC_ARM_VFPv3)) {
+               strcpy(un.machine, "armv6hl");
+           }
+       }
+#      endif /* arm*-linux */
+
 #      if defined(__GNUC__) && defined(__alpha__)
        {
            unsigned long amask, implver;
_______________________________________________
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to