diff mbox series

[bug#74290,v3,36/51] gnu: hurd: Build fixes for the 64bit Hurd.

Message ID 92b73ddd7fe349d12445f8e0f39cdca8dfc6599c.1731999203.git.janneke@gnu.org
State New
Headers show
Series Add support for x86_64-gnu, aka the 64bit Hurd. | expand

Commit Message

Janneke Nieuwenhuizen Nov. 19, 2024, 6:55 a.m. UTC
* gnu/packages/patches/hurd-64bit.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/hurd.scm (hurd)[source]: Use it.
[arguments]: When building for the 64bit Hurd, add "create-machine-symlink"
phase.  In phases "build-libdde-linux" and "install-goodies", do not assume
x86, rather use actual ARCH, and follow upstream's "amd64" symlinking voodoo.

Change-Id: If264a91b2433add13f9121c482f0abe67ae5f1e9
---
 gnu/local.mk                          |   1 +
 gnu/packages/hurd.scm                 | 126 ++++++++++++++++----------
 gnu/packages/patches/hurd-64bit.patch |  56 ++++++++++++
 3 files changed, 135 insertions(+), 48 deletions(-)
 create mode 100644 gnu/packages/patches/hurd-64bit.patch
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index e4b6de83cb..8a607e5df7 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1553,6 +1553,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/htslib-for-stringtie.patch		\
   %D%/packages/patches/hubbub-sort-entities.patch		\
   %D%/packages/patches/hueplusplus-mbedtls.patch		\
+  %D%/packages/patches/hurd-64bit.patch				\
   %D%/packages/patches/hurd-rumpdisk-no-hd.patch		\
   %D%/packages/patches/hurd-startup.patch			\
   %D%/packages/patches/hwloc-1-test-btrfs.patch			\
diff --git a/gnu/packages/hurd.scm b/gnu/packages/hurd.scm
index 6701d00251..63249b4ef7 100644
--- a/gnu/packages/hurd.scm
+++ b/gnu/packages/hurd.scm
@@ -317,7 +317,8 @@  (define-public hurd
     (source (origin
               (inherit (package-source hurd-headers))
               (patches (search-patches "hurd-rumpdisk-no-hd.patch"
-                                       "hurd-startup.patch"))))
+                                       "hurd-startup.patch"
+                                       "hurd-64bit.patch"))))
     (version (package-version hurd-headers))
     (arguments
      `(#:tests? #f                      ;no "check" target
@@ -467,54 +468,84 @@  (define-public hurd
                          (find-files (string-append out "/libexec")))
                #t)))
          (add-after 'build 'build-libdde-linux
-           (lambda* (#:key inputs native-inputs #:allow-other-keys)
-             (invoke (string-append (assoc-ref (or native-inputs inputs) "make")
-                                    "/bin/make")
-                     ;; XXX There can be a race condition because subdirs
-                     ;; aren't interdependent targets in the Makefile.
-                     "-j1" "-C" "libdde_linux26"
-                     (string-append "SHELL="
-                                    (assoc-ref (or native-inputs inputs) "bash")
-                                    "/bin/bash")
-                     (string-append "CC="
-                                    ,(cc-for-target))
-                     (string-append "WARNINGS="
-                                    " -Wno-declaration-missing-parameter-type"
-                                    " -Wno-implicit-function-declaration"
-                                    " -Wno-implicit-int"
-                                    " -Wno-int-conversion"
-                                    " -Wno-strict-prototypes")
-                     "ARCH=x86")))
+          (lambda* (#:key inputs native-inputs #:allow-other-keys)
+            (let ((arch ,(match (or (%current-target-system)
+                                    (%current-system))
+                           ((? target-x86-32?)
+                            "x86")
+                           ((? target-x86-64?)
+                            "amd64"))))
+              (when ,(target-hurd64?)
+                (let ((dir "libdde_linux26/build/include"))
+                  (mkdir-p (string-append dir "/x86"))
+                  (format #t "symlink ~a -> ~a\n"
+                          (string-append dir "/x86/amd64") "x86")
+                  (symlink "x86" (string-append dir "/amd64"))
+                  (format #t "symlink ~a -> ~a\n"
+                          (string-append dir "/amd64/asm-x86_64") "asm-x86")
+                  (symlink "asm-x86" (string-append dir "/amd64/asm-x86_64"))))
+              (invoke (string-append (assoc-ref (or native-inputs inputs) "make")
+                                     "/bin/make")
+                      ;; XXX There can be a race condition because subdirs
+                      ;; aren't interdependent targets in the Makefile.
+                      "-j1" "-C" "libdde_linux26"
+                      (string-append "SHELL="
+                                     (assoc-ref (or native-inputs inputs) "bash")
+                                     "/bin/bash")
+                      (string-append "CC="
+                                     ,(cc-for-target))
+                      (string-append "WARNINGS="
+                                     " -Wno-declaration-missing-parameter-type"
+                                     " -Wno-implicit-function-declaration"
+                                     " -Wno-implicit-int"
+                                     " -Wno-int-conversion"
+                                     " -Wno-strict-prototypes")
+                      (string-append "ARCH=" arch)))))
          (add-after 'install 'install-goodies
-           (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
-             ;; Install additional goodies.
-             ;; TODO: Build & install *.msgids for rpctrace.
-             (let* ((out (assoc-ref outputs "out"))
-                    (datadir (string-append out "/share/hurd")))
-               ;; Install libdde_linux26.
-               (invoke (string-append (assoc-ref (or native-inputs inputs) "make")
-                                      "/bin/make")
-                       "-C" "libdde_linux26" "install"
-                       (string-append "SHELL="
-                                      (assoc-ref (or native-inputs inputs) "bash")
-                                      "/bin/bash")
-                       (string-append "INSTALLDIR="
-                                      out
-                                      "/share/libdde_linux26/build/include")
-                       "ARCH=x86")
-               ;; Install the fancy UTF-8 motd.
-               (mkdir-p (string-append out "/etc"))
-               (copy-file "console/motd.UTF8"
-                          (string-append out "/etc/motd"))
+          (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
+            ;; Install additional goodies.
+            ;; TODO: Build & install *.msgids for rpctrace.
+            (let* ((out (assoc-ref outputs "out"))
+                   (datadir (string-append out "/share/hurd"))
+                   (arch ,(match (or (%current-target-system)
+                                     (%current-system))
+                            ((? target-x86-32?)
+                             "x86")
+                            ((? target-x86-64?)
+                             "amd64")))
+                   (dir (string-append out "/share/libdde_linux26/build/include")))
+              (mkdir-p dir)
+              (when ,(target-hurd64?)
+                (mkdir-p (string-append dir "/amd64"))
+                (format #t "symlink ~a -> ~a\n"
+                        (string-append dir "/amd64/asm-x86_64")
+                        "x86")
+                (symlink "x86" (string-append dir "/amd46")))
+              (invoke (string-append (assoc-ref (or native-inputs inputs) "make")
+                                     "/bin/make")
+                      "-C" "libdde_linux26" "install"
+                      (string-append "SHELL="
+                                     (assoc-ref (or native-inputs inputs) "bash")
+                                     "/bin/bash")
+                      (string-append "INSTALLDIR=" dir)
+                      (string-append "ARCH=" arch))
+              (when ,(target-hurd64?)
+                (format #t "symlink ~a -> ~a\n"
+                        (string-append dir "/amd64/asm-x86_64")
+                        "asm-x86")
+                (symlink "asm-x86" (string-append dir "/amd64/asm-x86_64")))
+              ;; Install the fancy UTF-8 motd.
+              (mkdir-p (string-append out "/etc"))
+              (copy-file "console/motd.UTF8"
+                         (string-append out "/etc/motd"))
 
-               ;; Install the BDF font for use by the console client.
-               (copy-file (assoc-ref inputs "unifont")
-                          "unifont.gz")
-               (invoke "gunzip" "unifont.gz")
-               (mkdir-p datadir)
-               (copy-file "unifont"
-                          (string-append datadir "/vga-system.bdf"))
-               #t))))
+              ;; Install the BDF font for use by the console client.
+              (copy-file (assoc-ref inputs "unifont")
+                         "unifont.gz")
+              (invoke "gunzip" "unifont.gz")
+              (mkdir-p datadir)
+              (copy-file "unifont"
+                         (string-append datadir "/vga-system.bdf"))))))
        #:configure-flags
        ,#~(list (string-append "LDFLAGS=-Wl,-rpath="
                                #$output "/lib")
@@ -599,7 +630,6 @@  (define-public netdde
                               " -Wno-implicit-int"
                               " -Wno-int-conversion"
                               " -Wno-strict-prototypes")
-               "ARCH=x86")
                (let ((arch ,(match (or (%current-target-system)
                                        (%current-system))
                               ((? target-x86-32?)
diff --git a/gnu/packages/patches/hurd-64bit.patch b/gnu/packages/patches/hurd-64bit.patch
new file mode 100644
index 0000000000..643550ad68
--- /dev/null
+++ b/gnu/packages/patches/hurd-64bit.patch
@@ -0,0 +1,56 @@ 
+Upstream-status: Taken from upstream:
+    <https://git.savannah.gnu.org/cgit/hurd/hurd.git/commit/?id=d494333e7607ea03819adcfb69d89f8248ec2044>.
+
+From d494333e7607ea03819adcfb69d89f8248ec2044 Mon Sep 17 00:00:00 2001
+From: Flavio Cruz <flaviocruz@gmail.com>
+Date: Sun, 21 Jul 2024 17:20:55 -0400
+Subject: [PATCH] nfsd: fix -Werror=incompatible-pointer-types issues for
+ x86_64
+Content-Transfer-Encoding: 8bit
+Content-Type: text/plain; charset=UTF-8
+
+Message-ID: <3pmgbk2myx4phdb6wcso54solmybulrvbytols5md3nri2p2qp@xjmfmpvwjp6t>
+---
+ nfsd/cache.c | 2 +-
+ nfsd/ops.c   | 4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/nfsd/cache.c b/nfsd/cache.c
+index cd5524af..864739c0 100644
+--- a/nfsd/cache.c
++++ b/nfsd/cache.c
+@@ -387,7 +387,7 @@ create_cached_handle (int fs, struct cache_handle *credc, file_t userport)
+   struct cache_handle *c;
+   int hash;
+   char *bp = fhandle.array + sizeof (int);
+-  size_t handlelen = NFS2_FHSIZE - sizeof (int);
++  mach_msg_type_number_t handlelen = NFS2_FHSIZE - sizeof (int);
+   mach_port_t newport, ref;
+ 
+   /* Authenticate USERPORT so that we can call file_getfh on it.  */
+diff --git a/nfsd/ops.c b/nfsd/ops.c
+index 463a9c87..64e94b93 100644
+--- a/nfsd/ops.c
++++ b/nfsd/ops.c
+@@ -292,7 +292,7 @@ op_write (struct cache_handle *c,
+   off_t offset;
+   size_t count;
+   error_t err;
+-  mach_msg_type_number_t amt;
++  vm_size_t amt;
+   char *bp;
+   struct stat st;
+ 
+@@ -583,7 +583,7 @@ op_readdir (struct cache_handle *c,
+   error_t err;
+   char *buf;
+   struct dirent *dp;
+-  size_t bufsize;
++  mach_msg_type_number_t bufsize;
+   int nentries;
+   int i;
+   int *replystart;
+-- 
+Janneke Nieuwenhuizen <janneke@gnu.org>  | GNU LilyPond https://LilyPond.org
+Freelance IT https://www.JoyOfSource.com | AvatarĀ® https://AvatarAcademy.com
+