From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <guix-patches-bounces+larch=yhetil.org@gnu.org>
Received: from mp1.migadu.com ([2001:41d0:303:e16b::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms13.migadu.com with LMTPS
	id eK99BZLfQmdacwEA62LTzQ:P1
	(envelope-from <guix-patches-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Sun, 24 Nov 2024 08:10:58 +0000
Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp1.migadu.com with LMTPS
	id eK99BZLfQmdacwEA62LTzQ
	(envelope-from <guix-patches-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Sun, 24 Nov 2024 09:10:58 +0100
X-Envelope-To: larch@yhetil.org
Authentication-Results: aspmx1.migadu.com;
	dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b="oiNe/70n";
	dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=IeSA7zJ6;
	dmarc=pass (policy=none) header.from=gnu.org;
	spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"
ARC-Seal: i=1; s=key1; d=yhetil.org; t=1732435858; a=rsa-sha256; cv=none;
	b=He8D2FKG3mjRN1GSrzRUm6jm1AWgYu/rrIq9dj7ssL7osiZ+WkIvIHx0skETGqBmiL4rmj
	6xpaXf+BWw3vDRUbj9tMM/EBIUqGtroqdDS33gsNuSbK5mBNVgryg6AhGv6eXDV4dwELwZ
	iGi3AsAWeKB92nu9uasbQnMe/qv4tp4nakedKcQ9xajokoYoZ0795hiTQDjPtImylmWZ01
	PoxOD3NZm6sBLx8Vk7tIean4MSUKWL1M0krAIosDTHplK3pbifHxzN1dRtc6yZ98gzL2jk
	myuOPIZwCmKyhynOvn199XpI5PFIOcu6SohVTT02IKxV4ceAzkOprma4ONK3ZQ==
ARC-Authentication-Results: i=1;
	aspmx1.migadu.com;
	dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b="oiNe/70n";
	dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=IeSA7zJ6;
	dmarc=pass (policy=none) header.from=gnu.org;
	spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org;
	s=key1; t=1732435858;
	h=from:from:sender:sender:reply-to:subject:subject:date:date:
	 message-id:message-id:to:to:cc:mime-version:mime-version:
	 content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding:resent-cc:
	 resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to:
	 references:references:list-id:list-help:list-unsubscribe:
	 list-subscribe:list-post:dkim-signature;
	bh=AlGqGL75ySyrk8iZymv7a6Z1oJ7DOO8fftgkErDQE0U=;
	b=UTPyQ0J+DVVpkDmVwvL0dfWG85KH5GAcQehk/PvYVEYrmNQrz6OLFZYFjQkg5Pps9rcDdL
	Lker62YYJZWs3sDGdZFz0vgFGzWhdmK6xLtrXcPyIJJ7dRzwSWa09pHV16vsMY2Lxy8enA
	4h2efcMRctDJd2HiKT7+dxw864MkcfYzhIrJnCA5hisOeikisZxrjRuWUH9R9bNfnMPf9I
	s3TWcA8bOwwT1szlWfC80M3rJqL37IyAVXWDpTGyTR3xci/hzeqHwfuXLGZbzWa+z/ZOO4
	3TaNLgjyrrJs9w71/i6A/sKkDQdy+HrJAINuTReuUq/T0snS8/mlPZFuHOEfYA==
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by aspmx1.migadu.com (Postfix) with ESMTPS id CD823786FD
	for <larch@yhetil.org>; Sun, 24 Nov 2024 09:10:57 +0100 (CET)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <guix-patches-bounces@gnu.org>)
	id 1tF7Vu-0001Xv-IV; Sun, 24 Nov 2024 02:58:39 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1tF7Ul-0000R0-3p
 for guix-patches@gnu.org; Sun, 24 Nov 2024 02:57:32 -0500
Received: from debbugs.gnu.org ([2001:470:142:5::43])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1tF7Uk-0002PU-AN
 for guix-patches@gnu.org; Sun, 24 Nov 2024 02:57:26 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=debbugs.gnu.org; s=debbugs-gnu-org; 
 h=MIME-Version:References:In-Reply-To:Date:From:To:Subject;
 bh=AlGqGL75ySyrk8iZymv7a6Z1oJ7DOO8fftgkErDQE0U=; 
 b=oiNe/70nqCzGBc88PywLHJA2Za92xiNJ6ICNwb4V+GOXXrWS/1eIVsILouOtn9phf9EaEexw8HtWsRI6IKfr9PRrXZQKUGxJw9yDFrIcC2I3fJBa6lnkO8DRtH+vd5RCb4YJiufXpyfLnIsxQx9zAwxoVriis44Q3GnUQm6u3C6PYlFSfoLSGgz9wozQGy2na1AbZPLdqhd5g7v2d4Eg8xG3E3C9Ltu+bFgQ54XHLaVd/gcxg+oZE7W5DX0SKN5KhnHT+I5NA+w/vvNJnKeg/B3xoK128UoAO9dyTIDSyHrW1eHUU0KQU645touKuHwi9bTJC1M9XrEDas2GeWZPDg==;
Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1tF7Uk-0004mJ-3d
 for guix-patches@gnu.org; Sun, 24 Nov 2024 02:57:26 -0500
X-Loop: help-debbugs@gnu.org
Subject: [bug#74290] [PATCH v4 38/58] gnu: hurd: Build fixes for the 64bit
 Hurd.
Resent-From: Janneke Nieuwenhuizen <janneke@gnu.org>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: guix-patches@gnu.org
Resent-Date: Sun, 24 Nov 2024 07:57:26 +0000
Resent-Message-ID: <handler.74290.B74290.173243503418144@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 74290
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 74290@debbugs.gnu.org
Received: via spool by 74290-submit@debbugs.gnu.org id=B74290.173243503418144
 (code B ref 74290); Sun, 24 Nov 2024 07:57:26 +0000
Received: (at 74290) by debbugs.gnu.org; 24 Nov 2024 07:57:14 +0000
Received: from localhost ([127.0.0.1]:60843 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1tF7UX-0004iJ-Jw
 for submit@debbugs.gnu.org; Sun, 24 Nov 2024 02:57:14 -0500
Received: from eggs.gnu.org ([209.51.188.92]:55734)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <janneke@gnu.org>) id 1tF7Tw-0004aK-CO
 for 74290@debbugs.gnu.org; Sun, 24 Nov 2024 02:56:37 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <janneke@gnu.org>)
 id 1tF7Tr-0002ET-6P; Sun, 24 Nov 2024 02:56:31 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To:
 From; bh=AlGqGL75ySyrk8iZymv7a6Z1oJ7DOO8fftgkErDQE0U=; b=IeSA7zJ6ovAcGHwbCISu
 /0wxxShXyHazQWeVVfWiDKazz5co43SN7MoF6Yq0dTLcKGXA0j4ByaaExQ78s7rX7PvS7TunSqQuc
 T1an+nSoLYLN3jchhbGU9vBPv8nd8WjyV5siqV+ikXqzwLuxvg7dNPtzA2jb8jI08wJ9Cj3k48/WW
 fJYTD1eAfcS/s+xLUTGPyiciYJZuhcR/llgjnZaePM2FV/Dmpv4k+3Y0h3xzdiuCgLXODdtrbrDv/
 7xFzL3q08S8+OLReVUPwFxWdxY4MlyRPMZPOB/NjrKtsvNcWOBvIiCBCvHSHe0xWGvriVBBwRwUYg
 GGTEcvOjDAWKwg==;
From: Janneke Nieuwenhuizen <janneke@gnu.org>
Date: Sun, 24 Nov 2024 08:55:01 +0100
Message-ID: <6e35b48b7ef3cc93c0f0a9bcd859531ba4fa9cb5.1732434271.git.janneke@gnu.org>
X-Mailer: git-send-email 2.46.0
In-Reply-To: <cover.1732434270.git.janneke@gnu.org>
References: <cover.1732434270.git.janneke@gnu.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
X-BeenThere: guix-patches@gnu.org
List-Id: <guix-patches.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>,
 <mailto:guix-patches-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/guix-patches>
List-Post: <mailto:guix-patches@gnu.org>
List-Help: <mailto:guix-patches-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>,
 <mailto:guix-patches-request@gnu.org?subject=subscribe>
Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org
Sender: guix-patches-bounces+larch=yhetil.org@gnu.org
X-Migadu-Flow: FLOW_IN
X-Migadu-Country: US
X-Migadu-Queue-Id: CD823786FD
X-Migadu-Scanner: mx13.migadu.com
X-Migadu-Spam-Score: -7.47
X-Spam-Score: -7.47
X-TUID: +10/CntIUKAH

* 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 --git a/gnu/local.mk b/gnu/local.mk
index 2e18ed7870..eb1bc43276 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
+
-- 
2.46.0