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:403:58f0::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms13.migadu.com with LMTPS
	id YLFlENg3PGfbrwAA62LTzQ:P1
	(envelope-from <guix-patches-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Tue, 19 Nov 2024 07:01:44 +0000
Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp1.migadu.com with LMTPS
	id YLFlENg3PGfbrwAA62LTzQ
	(envelope-from <guix-patches-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Tue, 19 Nov 2024 08:01:44 +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=lNIRZiBy;
	dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b="Ps3/z+JZ";
	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";
	dmarc=pass (policy=none) header.from=gnu.org
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org;
	s=key1; t=1731999703;
	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=3eDAYvhD7/S4zRN1iNNY2OHp5VUTvmov5DDcV87PBp0=;
	b=LCE2EvAxZW3qwhDXao7ksy/upZQAP0rN5IY2IVuXbBON+0cJbKJRWaAyDZFsmLnjm3WE+D
	U8WK/XEgFKjheop6gzRVX7qTTJJtAD8AOTMCXoQSHG2rvWlXpa5kKZwxA/Oxj4XxPnIYjS
	KiBpGGdkGSJcFzBPFQEuZhwo/Cpu9kxfc7NXUk4/1A1LQkxfPkhdKQ52o7oSXU+WEq7aOE
	Sxn6qJrhZhtT6/Hjyz3GjPrhQUnFrIh7+RDGSdOoTx8/SvgJai510o3AU8Uum04Tr8MUz0
	7Zi6CcekL+QuuJYnv9hlbVGNSoetCJVQeTqFJFUSQF9ycUJd0wj7FEH24iEkcA==
ARC-Authentication-Results: i=1;
	aspmx1.migadu.com;
	dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=lNIRZiBy;
	dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b="Ps3/z+JZ";
	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";
	dmarc=pass (policy=none) header.from=gnu.org
ARC-Seal: i=1; s=key1; d=yhetil.org; t=1731999703; a=rsa-sha256; cv=none;
	b=VV6zIBBx5v7MOCrU7LfLqZp8+ODE/rDns33/tWNo6krqiH2l9EaUp7qeGiwsdwEQL577Jf
	9aeGhV7QRphe2mzPDnWPxmf23IpmfaYyTmKqwhnaRc3LueLVdihk8x4aakTYXXNmIV5gAZ
	oCJmgOF5RNKAuxOPZgdfm5jxO3o80YCJlSNaVd7PjsGWBhsdM+Qz8r1xULWX75myQWMZ7F
	FbLupq4LMg7AoShQ1o7e+js69SUjs784Kj9zwJT7+XjYAJ9H5bZ3BV4f4ws5Gz3ZmUh/Ht
	twnj71dg+Vb8o0BjJNZOJxxhDcs1POGt+3qrQ4JfW16ssTZCm9EA77I/Pj+Xbw==
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 AD08F43A1D
	for <larch@yhetil.org>; Tue, 19 Nov 2024 08:01:43 +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 1tDICy-00006r-Uv; Tue, 19 Nov 2024 01:59:32 -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 1tDICx-0008WE-HP
 for guix-patches@gnu.org; Tue, 19 Nov 2024 01:59:31 -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 1tDICs-0004M7-9C
 for guix-patches@gnu.org; Tue, 19 Nov 2024 01:59:30 -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=3eDAYvhD7/S4zRN1iNNY2OHp5VUTvmov5DDcV87PBp0=; 
 b=lNIRZiBynKE1nugTtM9zGSgogpGJKsRMmEd0UE+C/qoqPykg+iXEBiNJ25g9o6+39Wsz600tqGm2A3IbK7LyH3bTmg/AfTiLSPmnJfwK5Z/zDk5C7fSUx+YwGRnT5xvrgPQvx/xhjwTNKFo95uxN+3KA/6ifRoaaxu47gmJ/nBpXA5cEFGvgSF7AJpU+xlL9cwqCdIFzkV514XKEIZYJ8jVlKbv0FHw/HCXLbYXBDCE2zgvrdWlZ74DZDdYvGjYDaTZAKGXKa7UT7grLy8YiZ3YquVqeQHN/lQybWsL/pQz812MTaYijbB0a9YsBSvFA7ZTH7Mt5jdh1JxbNVzg86A==;
Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1tDICr-0005Kd-VN
 for guix-patches@gnu.org; Tue, 19 Nov 2024 01:59:26 -0500
X-Loop: help-debbugs@gnu.org
Subject: [bug#74290] [PATCH v3 36/51] 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: Tue, 19 Nov 2024 06:59:25 +0000
Resent-Message-ID: <handler.74290.B74290.173199955620345@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.173199955620345
 (code B ref 74290); Tue, 19 Nov 2024 06:59:25 +0000
Received: (at 74290) by debbugs.gnu.org; 19 Nov 2024 06:59:16 +0000
Received: from localhost ([127.0.0.1]:40619 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1tDICh-0005Hp-C5
 for submit@debbugs.gnu.org; Tue, 19 Nov 2024 01:59:16 -0500
Received: from eggs.gnu.org ([209.51.188.92]:52146)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <janneke@gnu.org>) id 1tDICE-0005BL-1Y
 for 74290@debbugs.gnu.org; Tue, 19 Nov 2024 01:58:47 -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 1tDIA2-00043r-VM; Tue, 19 Nov 2024 01:56:30 -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=3eDAYvhD7/S4zRN1iNNY2OHp5VUTvmov5DDcV87PBp0=; b=Ps3/z+JZ9L45utHbfS+H
 wlsMWN6je9UbLxDWiUKwng0DneFRAPzSioNBxsOdfRlqUfKe/Z+HAqFA6oR5QVRCQu0LgV3lyx+ll
 2sDt6qIiWYCOFSnx9fGYQulTaDIdoU86Y8i7VBKU4ksNcANusFbU4Kx2GwZ8RnZKg+KPykBzgYiJx
 IvH0WIC+fO0EE1qj8w0yN7j/G+NeIDbe0SC1cVbsEktBslt6PCB7HHhG4jdsFQUE8iqf2BmdIQut9
 CJsn2yR3HnONR6i/053mYNO8JyhAwpLOljxpRArluUM4dh0SNIrAXIfvYNOcGLjFE2hp1Y5kTIz/g
 UUwM4A1FcVM59Q==;
From: Janneke Nieuwenhuizen <janneke@gnu.org>
Date: Tue, 19 Nov 2024 07:55:06 +0100
Message-ID: <92b73ddd7fe349d12445f8e0f39cdca8dfc6599c.1731999203.git.janneke@gnu.org>
X-Mailer: git-send-email 2.46.0
In-Reply-To: <cover.1731999202.git.janneke@gnu.org>
References: <cover.1731999202.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-Country: US
X-Migadu-Flow: FLOW_IN
X-Migadu-Scanner: mx11.migadu.com
X-Migadu-Spam-Score: -3.72
X-Spam-Score: -3.72
X-Migadu-Queue-Id: AD08F43A1D
X-TUID: W6fNhmlv7rL7

* 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 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
+
-- 
2.46.0