Subject: Re: bug#36813: 'lower-gexp' does not respect 'system' or 'target' keywords

From: Ludovic Courtès <[email-masked]>
Date: Fri, 26 Jul 2019 10:21:47 +0200

Hello Jakob,

[email-masked] (Jakob L. Kreuze) skribis:

> I believe there is an issue with 'lower-gexp'. Running the following
> snippet to lower a G-Expression for "i686-linux" yields output that
> references store paths built for x86_64. In this case, the Guile
> interpreter used is an x86_64 binary.
>
> #+BEGIN_SRC scheme
> (define (display-exp exp)
>   (mlet* %store-monad ((lowered (lower-gexp exp
>                                             #:system "i686-linux"
>                                             #:target "i686-linux"))
>                        (to-build -> (cons (lowered-gexp-guile lowered)
>                                           (lowered-gexp-inputs lowered)))
>                        (_ (built-derivations to-build)))
>     (return (format #t "~a~%" (lowered-gexp-sexp lowered)))))
>
> (with-store store
>   (run-with-store store
>     (display-exp #~(primitive-load #$(switch-system-program %system)))))
> #+END_SRC

Note: #:target must be a “GNU triplet” like “arm-linux-gnueabihf”, not a
system type like “i686-linux”.

> jakob@Epsilon ~ $ guile ~/test.scm 
> (primitive-load /gnu/store/v7v1b7375j9j82dvfycv56v36nv5jq3y-switch-to-system.scm)
> jakob@Epsilon ~ $ cat /gnu/store/v7v1b7375j9j82dvfycv56v36nv5jq3y-switch-to-system.scm
> #!/gnu/store/9alic3caqhay3h8mx4iihpmyj6ymqpcx-guile-2.2.4/bin/guile --no-auto-compile
> !#
> ...
> jakob@Epsilon ~ $ file /gnu/store/9alic3caqhay3h8mx4iihpmyj6ymqpcx-guile-2.2.4/bin/guile
> /gnu/store/9alic3caqhay3h8mx4iihpmyj6ymqpcx-guile-2.2.4/bin/guile: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /gnu/store/h90vnqw0nwd0hhm1l5dgxsdrigddfmq4-glibc-2.28/lib/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, not stripped

That’s because the Guile used here comes from the #:guile-for-build
parameter.

So the caller is responsible for doing the right thing here.  In fact,
if you do:

  (lower-gexp exp #:system whatever #:guile-for-build #f)

it will automatically take care of computing the right Guile for this
system.  For consistency, I don’t think we should change the default,
though.

WDYT?

Thanks,
Ludo’.