[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 18/36: services: hurd: Add dummy loopback.
From: |
Ludovic Courtès |
Subject: |
Re: 18/36: services: hurd: Add dummy loopback. |
Date: |
Tue, 05 May 2020 11:23:01 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
Hi,
Jan Nieuwenhuizen <address@hidden> skribis:
>> Could it be ‘ifreq-struct-size’ that’s off on GNU/Hurd, or one of its
>> friends?
>
> 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:
--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guild compile --target=i686-pc-linux-gnu
guix/build/syscalls.scm -o guix/build/syscalls.go
wrote `guix/build/syscalls.go'
$ guix environment -s i686-linux -C --ad-hoc guile-next -- guile -L . -C .
GNU Guile 3.0.2
Copyright (C) 1995-2020 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guile-user)> ,use(guix build syscalls)
scheme@(guile-user)> ,m(guix build syscalls)
scheme@(guix build syscalls)> sizeof-ifconf
$1 = 8
scheme@(guix build syscalls)> %host-type
$2 = "i686-unknown-linux-gnu"
--8<---------------cut here---------------end--------------->8---
Thank you!
Ludo’.
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)