From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id EJNGGy5gsV7kXAAA0tVLHw (envelope-from ) for ; Tue, 05 May 2020 12:46:38 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id qBjjMzhgsV6UCAAAB5/wlQ (envelope-from ) for ; Tue, 05 May 2020 12:46:48 +0000 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:470:142::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 B27A1940B52 for ; Tue, 5 May 2020 12:46:47 +0000 (UTC) Received: from localhost ([::1]:38150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVwyG-0001Rc-6c for larch@yhetil.org; Tue, 05 May 2020 08:46:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVwy7-0001RM-SI for guix-devel@gnu.org; Tue, 05 May 2020 08:46:39 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:53271) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVwy5-0007JV-LQ; Tue, 05 May 2020 08:46:37 -0400 Received: from [2001:980:1b4f:1:42d2:832d:bb59:862] (port=59812 helo=dundal.peder.onsbrabantnet.nl) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jVwy4-0004Fr-M3; Tue, 05 May 2020 08:46:37 -0400 From: Jan Nieuwenhuizen To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: 18/36: services: hurd: Add dummy loopback. Organization: AvatarAcademy.nl References: <20200427101927.7020.76060@vcs0.savannah.gnu.org> <20200427101947.E79D320A5E@vcs0.savannah.gnu.org> <87o8r8lj9h.fsf@gnu.org> <87a72rr8jq.fsf@gnu.org> <87zhaovj3o.fsf@gnu.org> <87wo5spswe.fsf@gnu.org> <87wo5qn3be.fsf@gnu.org> X-Url: http://AvatarAcademy.nl Date: Tue, 05 May 2020 14:46:34 +0200 In-Reply-To: <87wo5qn3be.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Tue, 05 May 2020 11:23:01 +0200") Message-ID: <87o8r25z2t.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: guix-devel@gnu.org Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Scanner: scn0 X-Spam-Score: -1.01 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 2001:470:142::17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Scan-Result: default: False [-1.01 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.49547695337888]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2001:470:142::/48:c]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.13), country: US(-0.00), ip: 2001:470:142::17(-0.50)]; DWL_DNSWL_FAIL(0.00)[2001:470:142::17:server fail]; HAS_ORG_HEADER(0.00)[]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; RCPT_COUNT_TWO(0.00)[2]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_IN_DNSWL_FAIL(0.00)[2001:470:142::17:server fail]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:+]; ASN(0.00)[asn:22989, ipnet:2001:470:142::/48, country:US]; TAGGED_FROM(0.00)[larch=yhetil.org]; FROM_NEQ_ENVFROM(0.00)[janneke@gnu.org,guix-devel-bounces@gnu.org]; ARC_NA(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; URIBL_BLOCKED(0.00)[avataracademy.com:url,gnu.org:email,lilypond.org:url,joyofsource.com:url]; MIME_GOOD(-0.10)[multipart/mixed,text/plain,text/x-patch]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[gnu.org]; HAS_LIST_UNSUB(-0.01)[]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: ijiIJE7wS9gf --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s writes: Hi, >> Something like that: sizeof-ifconf is set to 16 (like on x86_64), but >> it's size should be 8. > > Oh, that=E2=80=99s because =E2=80=98define-c-struct=E2=80=99 does all the= work at > macro-expansion time, with the host types and alignment constraints. I > wonder how we didn=E2=80=99t notice it earlier. Cross-compiling from x86= _64 to > ARMv7 has the same problem, but maybe the networking ioctls work by > chance. > > The patch below appears to fix it: Yes, it fixes the struct sizes in the cross-compiled .go file. Thanks! I have added it as the attached patch to "wip-hurd-vm" for now. I did ./pre-inst-env guild compile --target=3Di586-pc-gnu -o syscalls.go guix= /build/syscalls.scm=20 and copied that to the Hurd. When running this (changed #$... to UPPERCASE) --8<---------------cut here---------------start------------->8--- (use-modules (guix build syscalls)) (define LOOPBACK? #t) (define IP "127.0.0.1" ) (define INTERFACE "lo") (define NETMASK #f) (define GATEWAY #f) (format #t "ifreq-struct-size: ~a\n" (@@ (guix build syscalls) ifreq-struct= -size)) (format #t "sizeof-ifconf: ~s\n" (@@ (guix build syscalls) sizeof-ifconf)) (define (test) (let* ((addr (inet-pton AF_INET IP)) (sockaddr (make-socket-address AF_INET addr 0)) (mask (and NETMASK (inet-pton AF_INET NETMASK))) (maskaddr (and mask (make-socket-address AF_INET mask 0))) (gateway (and GATEWAY (inet-pton AF_INET GATEWAY))) (gatewayaddr (and gateway (make-socket-address AF_INET gateway 0)))) (configure-network-interface INTERFACE sockaddr (logior IFF_UP (if LOOPBACK? IFF_LOOPBACK 0)) #:netmask maskaddr) (when gateway (let ((sock (socket AF_INET SOCK_DGRAM 0))) (add-network-route/gateway sock gatewayaddr) (close-port sock))))) (test) --8<---------------cut here---------------end--------------->8--- Now I see the correct sizes... root@guixygnu# guile -L . -C . static.scm=20 ;;; note: source file /root/static.scm ;;; newer than compiled /root/.cache/guile/ccache/3.0-LE-4-4.2/root/s= tatic.scm.go ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=3D0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /root/static.scm ;;; compiled /root/.cache/guile/ccache/3.0-LE-4-4.2/root/static.scm.go ifreq-struct-size: 32 sizeof-ifconf: 8 Backtrace: In ice-9/boot-9.scm: 1736:10 9 (with-exception-handler _ _ #:unwind? _ # _) In unknown file: 8 (apply-smob/0 #) In ice-9/boot-9.scm: 718:2 7 (call-with-prompt _ _ #) In ice-9/eval.scm: 619:8 6 (_ #(#(#))) In ice-9/boot-9.scm: 2806:4 5 (save-module-excursion _) 4351:12 4 (_) In static.scm: 24:4 3 (test) In guix/build/syscalls.scm: 1529:8 2 (configure-network-interface "lo" #(2 2130706433 0) 9 # _) 1464:18 1 (_ _ "lo" _) In unknown file: Exception thrown while printing backtrace: In procedure primitive-call-ip: Wrong type argument in position 1 (expectin= g PRIMITIVE_P): # ERROR: Value out of range 0 to 4294967295: -1 ...but still/again a similar range error; Ideas? Greetings, janneke --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-syscalls-Cross-build-fix-for-alignof-sizeof.patch >From 33fbfcd7f46cf675cc24db92b1110d38afa51ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 5 May 2020 11:53:39 +0200 Subject: [PATCH] syscalls: Cross-build fix for alignof*, sizeof*. See . Reported by Jan (janneke) Nieuwenhuizen . * guix/build/syscalls.scm (sizeof*, alignof*): When cross-compiling, emit code to call at runtime. --- guix/build/syscalls.scm | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 73b439fb7d..00d8ceb480 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -23,6 +23,7 @@ (define-module (guix build syscalls) #:use-module (system foreign) + #:use-module (system base target) #:use-module (rnrs bytevectors) #:autoload (ice-9 binary-ports) (get-bytevector-n) #:use-module (srfi srfi-1) @@ -194,9 +195,14 @@ (* (sizeof* type) n)) ((_ type) (let-syntax ((v (lambda (s) - (let ((val (sizeof type))) - (syntax-case s () - (_ val)))))) + ;; When compiling natively, call 'sizeof' at expansion + ;; time; otherwise, emit code to call it at run time. + (syntax-case s () + (_ + (if (= (target-word-size) + (with-target %host-type target-word-size)) + (sizeof type) + #'(sizeof type))))))) v)))) (define-syntax alignof* @@ -208,9 +214,14 @@ (alignof* type)) ((_ type) (let-syntax ((v (lambda (s) - (let ((val (alignof type))) - (syntax-case s () - (_ val)))))) + ;; When compiling natively, call 'sizeof' at expansion + ;; time; otherwise, emit code to call it at run time. + (syntax-case s () + (_ + (if (= (target-word-size) + (with-target %host-type target-word-size)) + (alignof type) + #'(alignof type))))))) v)))) (define-syntax align ;as found in (system foreign) -- 2.26.0 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar=C2=AE http://AvatarAcademy.com --=-=-=--