unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Efraim Flashner <efraim@flashner.co.il>
To: Maxime Devos <maximedevos@telenet.be>
Cc: "Vagrant Cascadian" <vagrant@debian.org>,
	55283@debbugs.gnu.org, "Ludovic Courtès" <ludo@gnu.org>,
	raingloom <raingloom@riseup.net>
Subject: bug#55283: ‘tests/guix-shell-export-manifest.sh’ fails on aarch64-linux
Date: Mon, 9 May 2022 17:17:55 +0300	[thread overview]
Message-ID: <Ynkik6ZOXoVH4XHK@3900XT> (raw)
In-Reply-To: <4d2747729262ac3e3f27d7e75f1dfb50da4c7fed.camel@telenet.be>


[-- Attachment #1.1: Type: text/plain, Size: 838 bytes --]

On Mon, May 09, 2022 at 12:03:46PM +0200, Maxime Devos wrote:
> Efraim Flashner schreef op ma 09-05-2022 om 11:44 [+0300]:
> > +                (loop vendor family (string->number (string-append
> > "#x" (string-drop model 2)))))
> 
> #x is for hexadecimal, right?  If so, this can be simplified by using
> the second argument of string->number: (string->number (string-drop
> model 2) 16).

I hadn't realized that. I took the chance to take another look at it and
now it actually works, not just fills in each field with #f. I also
added more chips based on gcc-12 and fixed the fallback case.


-- 
Efraim Flashner   <efraim@flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

[-- Attachment #1.2: guix-cpu-aarch64.diff --]
[-- Type: text/plain, Size: 4564 bytes --]

diff --git a/guix/cpu.scm b/guix/cpu.scm
index a44cd082f1..37ed6f0a18 100644
--- a/guix/cpu.scm
+++ b/guix/cpu.scm
@@ -62,31 +62,51 @@ (define (prefix? prefix)
       (lambda (port)
         (let loop ((vendor #f)
                    (family #f)
-                   (model #f))
+                   (model #f)
+                   (flags (list->set '())))
           (match (read-line port)
             ((? eof-object?)
-             #f)
+             (cpu (utsname:machine (uname))
+                  vendor family model flags))
+            ;; vendor for x86_64 and i686
             ((? (prefix? "vendor_id") str)
              (match (string-tokenize str)
                (("vendor_id" ":" vendor)
-                (loop vendor family model))))
+                (loop vendor family model flags))))
+            ;; vendor for aarch64 and armhf
+            ((? (prefix? "CPU implementer") str)
+             (match (string-tokenize str)
+               (("CPU" "implementer" ":" vendor)
+                (loop vendor family model flags))))
+            ;; family for x86_64 and i686
             ((? (prefix? "cpu family") str)
              (match (string-tokenize str)
                (("cpu" "family" ":" family)
-                (loop vendor (string->number family) model))))
+                (loop vendor (string->number family) model flags))))
+            ;; model for x86_64 and i686
             ((? (prefix? "model") str)
              (match (string-tokenize str)
                (("model" ":" model)
-                (loop vendor family (string->number model)))
+                (loop vendor family (string->number model flags)))
                (_
-                (loop vendor family model))))
+                (loop vendor family model flags))))
+            ;; model for aarch64 and armhf
+            ((? (prefix? "CPU part") str)
+             (match (string-tokenize str)
+               (("CPU" "part" ":" model)
+                (loop vendor family (string->number (string-drop model 2) 16) flags))))
+            ;; flags for x86_64 and i686
             ((? (prefix? "flags") str)
              (match (string-tokenize str)
                (("flags" ":" flags ...)
-                (cpu (utsname:machine (uname))
-                     vendor family model (list->set flags)))))
+                (loop vendor family model (list->set flags)))))
+            ;; flags for aarch64 and armhf
+            ((? (prefix? "Features") str)
+             (match (string-tokenize str)
+               (("Features" ":" flags ...)
+                (loop vendor family model (list->set flags)))))
             (_
-             (loop vendor family model))))))))
+             (loop vendor family model flags))))))))
 
 (define (cpu->gcc-architecture cpu)
   "Return the architecture name, suitable for GCC's '-march' flag, that
@@ -191,6 +211,57 @@ (define (cpu->gcc-architecture cpu)
          ;; TODO: Recognize CENTAUR/CYRIX/NSC?
 
          "x86_64"))
+    ("aarch64"
+     ;; Transcribed from GCC's list of aarch64 processors in aarch64-cores.def
+     ;; What to do with big.LITTLE cores?
+     (match (cpu-vendor cpu)
+       ("0x41"
+        (match (cpu-model cpu)
+          ((or #xd02 #xd04 #xd03 #xd07 #xd08 #xd09)
+           "armv8-a")
+          ((or #xd05 #xd0a #xd0b #xd0e #xd0d #xd41 #xd42 #xd4b #xd46 #xd43 #xd44 #xd41 #xd0c #xd4a)
+           "armv8.2-a")
+          (#xd40
+           "armv8.4-a")
+          (#xd15
+           "armv8-r")
+          ((or #xd46 #xd47 #xd48 #xd49 #xd4f)
+           "armv9-a")))
+       ("0x42"
+        "armv8.1-a")
+       ("0x43"
+        (match (cpu-model cpu)
+          ((or #x0a0 #x0a1 #x0a2 #x0a3)
+           "armv8-a")
+          (#x0af
+           "armv8.1-a")
+          ((or #x0b0 #x0b1 #x0b2 #x0b3 #x0b4 #x0b5)
+           "armv8.2-a")
+          (#x0b8
+           "armv8.3-a")))
+       ("0x46"
+        "armv8.2-a")
+       ("0x48"
+        "armv8.2-a")
+       ("0x50"
+        "armv8-a")
+       ("0x51"
+        (match (cpu-model cpu)
+          (#xC00
+           "armv8-a")
+          (#x516
+           "armv8.1-a")
+          (#xC01
+           "armv8.4-a")))
+       ("0x53"
+        "armv8-a")
+       ("0x68"
+        "armv8-a")
+       ("0xC0"
+        "armv8.6-a")
+       (_
+        "armv8-a"))
+     "armv8-a")
     (architecture
-     ;; TODO: AArch64.
-     architecture)))
+      ;; TODO: More architectures
+      (utsname:machine (uname)))))

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-05-09 14:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-05 22:50 bug#55283: ‘tests/guix-shell-export-manifest.sh’ fails on aarch64-linux Ludovic Courtès
2022-05-06  0:28 ` raingloom
2022-05-06 20:43   ` Vagrant Cascadian
2022-05-06 21:12   ` Maxime Devos
2022-05-06 22:13     ` Vagrant Cascadian
2022-05-07  0:14       ` Vagrant Cascadian
2022-05-07  0:45         ` Vagrant Cascadian
2022-05-08 22:14         ` Ludovic Courtès
2022-05-09  8:44           ` Efraim Flashner
2022-05-09  8:57             ` Efraim Flashner
2022-05-09 10:03             ` Maxime Devos
2022-05-09 14:17               ` Efraim Flashner [this message]
2022-05-10 15:40                 ` Ludovic Courtès
2022-05-10 15:43                   ` Ludovic Courtès
2022-05-10 15:55                     ` Efraim Flashner
2022-05-10 15:50                   ` Efraim Flashner
2022-05-12  8:09                     ` Ludovic Courtès
2022-05-09 12:04 ` Sébastien Lerique
2022-05-09 12:32   ` Sébastien Lerique
2022-05-17 12:29 ` Efraim Flashner
2022-05-17 15:01   ` Pavel Shlyak
2022-05-17 16:38     ` Pavel Shlyak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Ynkik6ZOXoVH4XHK@3900XT \
    --to=efraim@flashner.co.il \
    --cc=55283@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    --cc=maximedevos@telenet.be \
    --cc=raingloom@riseup.net \
    --cc=vagrant@debian.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).