From: Jan Nieuwenhuizen <janneke@gnu.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: 18/36: services: hurd: Add dummy loopback.
Date: Tue, 05 May 2020 14:46:34 +0200 [thread overview]
Message-ID: <87o8r25z2t.fsf@gnu.org> (raw)
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")
[-- Attachment #1: Type: text/plain, Size: 3699 bytes --]
Ludovic Courtès writes:
Hi,
>> Something like that: sizeof-ifconf is set to 16 (like on x86_64), but
>> it's size should be 8.
>
> Oh, that’s because ‘define-c-struct’ does all the work at
> macro-expansion time, with the host types and alignment constraints. I
> wonder how we didn’t 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=i586-pc-gnu -o syscalls.go guix/build/syscalls.scm
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
;;; note: source file /root/static.scm
;;; newer than compiled /root/.cache/guile/ccache/3.0-LE-4-4.2/root/static.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; 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 #<thunk 2e6430>)
In ice-9/boot-9.scm:
718:2 7 (call-with-prompt _ _ #<procedure default-prompt-handle?>)
In ice-9/eval.scm:
619:8 6 (_ #(#(#<directory (guile-user) 2dd820>)))
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 (expecting PRIMITIVE_P): #<procedure 8f8560 (_ _ _)>
ERROR: Value out of range 0 to 4294967295: -1
...but still/again a similar range error; Ideas?
Greetings,
janneke
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-syscalls-Cross-build-fix-for-alignof-sizeof.patch --]
[-- Type: text/x-patch, Size: 2509 bytes --]
From 33fbfcd7f46cf675cc24db92b1110d38afa51ae5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Tue, 5 May 2020 11:53:39 +0200
Subject: [PATCH] syscalls: Cross-build fix for alignof*, sizeof*.
See <https://lists.gnu.org/archive/html/guix-devel/2020-05/msg00008.html>.
Reported by Jan (janneke) Nieuwenhuizen <janneke@gnu.org>.
* 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
[-- Attachment #3: Type: text/plain, Size: 152 bytes --]
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
next prev parent reply other threads:[~2020-05-05 12:46 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200427101927.7020.76060@vcs0.savannah.gnu.org>
[not found] ` <20200427101942.B725620A5E@vcs0.savannah.gnu.org>
2020-04-30 21:48 ` 02/36: gnu: guix: Use gnutls-3.6.13 when cross-compiling Ludovic Courtès
2020-05-01 7:22 ` Jan Nieuwenhuizen
[not found] ` <20200427101943.A4BDD20A5E@vcs0.savannah.gnu.org>
2020-04-30 21:50 ` 05/36: vm: Make the device node procedure a parameter Ludovic Courtès
2020-05-01 6:07 ` Jan Nieuwenhuizen
2020-05-03 20:34 ` Ludovic Courtès
[not found] ` <20200427101943.F251E20A5E@vcs0.savannah.gnu.org>
2020-04-30 21:51 ` 06/36: gnu: hurd: Fix references to /bin/w Ludovic Courtès
2020-05-01 6:07 ` Jan Nieuwenhuizen
[not found] ` <20200427101944.46D0C20A5E@vcs0.savannah.gnu.org>
2020-04-30 21:52 ` 07/36: gnu: hurd: Use default Qemu guest ip: 10.0.2.15 Ludovic Courtès
2020-05-01 6:07 ` Jan Nieuwenhuizen
[not found] ` <20200427101944.86DE020BC2@vcs0.savannah.gnu.org>
2020-04-30 21:53 ` 08/36: gnu: hurd: Add NFS support Ludovic Courtès
2020-05-01 6:14 ` Jan Nieuwenhuizen
[not found] ` <20200427101945.023D020BC4@vcs0.savannah.gnu.org>
2020-04-30 21:55 ` 09/36: gnu: Add libtirpc/hurd Ludovic Courtès
2020-05-01 6:15 ` Jan Nieuwenhuizen
2020-04-30 21:56 ` branch wip-hurd-vm created (now fdb35e3) Ludovic Courtès
2020-05-01 7:02 ` Jan Nieuwenhuizen
[not found] ` <20200427101946.414C420A5E@vcs0.savannah.gnu.org>
2020-04-30 22:03 ` 13/36: services: Add hurd-console-service-type Ludovic Courtès
2020-05-01 15:16 ` Jan Nieuwenhuizen
2020-05-01 20:03 ` Jan Nieuwenhuizen
2020-05-03 20:39 ` Ludovic Courtès
2020-05-03 20:55 ` Jan Nieuwenhuizen
[not found] ` <20200427101947.E79D320A5E@vcs0.savannah.gnu.org>
2020-04-30 22:07 ` 18/36: services: hurd: Add dummy loopback Ludovic Courtès
2020-05-01 15:15 ` Jan Nieuwenhuizen
2020-05-03 20:50 ` Ludovic Courtès
2020-05-03 22:15 ` Jan Nieuwenhuizen
2020-05-05 9:23 ` Ludovic Courtès
2020-05-05 9:38 ` Vincent Legoll
2020-05-06 14:06 ` Ludovic Courtès
2020-05-05 12:46 ` Jan Nieuwenhuizen [this message]
2020-05-06 14:09 ` Ludovic Courtès
[not found] ` <20200427101948.9B2B220A5E@vcs0.savannah.gnu.org>
2020-04-30 22:25 ` 20/36: system: hurd: Add the Shepherd Ludovic Courtès
2020-05-01 10:28 ` Jan Nieuwenhuizen
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=87o8r25z2t.fsf@gnu.org \
--to=janneke@gnu.org \
--cc=guix-devel@gnu.org \
--cc=ludo@gnu.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).