Subject: Cross-compiled guile-lzlib unusable, causing ‘guix substitute’ to crash on GNU/Hurd
From: Ludovic Courtès <[email-masked]>
To: <[email-masked]>
Date: Sat, 26 Sep 2020 11:09:57 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Seen on i586-gnu (cross-compiled childhurd):

--8<---------------cut here---------------start------------->8---
root@childhurd ~# /gnu/store/*-guile-3.0.4/bin/guile -L /run/current-system/profile/share/guile/site/3.0/ -C /run/current-system/profile/lib/guile/3.0/site-ccache/
GNU Guile 3.0.4
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 scripts substitute)
scheme@(guile-user)>  (guix-substitute "--substitute" "/gnu/store/vq7zyb4hmlrafflmrcjbqccxp4dsx0s3-bash" "/tmp/t")

sha256:1as8649aqaibahhhrvkj10ci8shpi4hq5n7gnik8rhhy0dc1jarg
Downloading http://ci.guix.gnu.org/nar/lzip/vq7zyb4hmlrafflmrcjbqccxp4dsx0s3-bash...
 bash  717KiB                      +nan.0TiB/s 00:00 [                  ]   0.0%ice-9/boot-9.scm:1669:16: In procedure raise-exception:
Wrong type to apply: #f

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,bt
In ice-9/boot-9.scm:
  1669:16  0 (raise-exception _ #:continuable? _)
scheme@(guile-user) [1]> ,q
--8<---------------cut here---------------end--------------->8---

Trick to get a proper backtrace, I added a breakpoint on
‘raise-exception’:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user) [1]> ,bt
In ice-9/boot-9.scm:
  1731:15  9 (with-exception-handler #<procedure 38e1cc0 at ice-9/boot-9.scm:1815:7 (exn)> _ #:unwind? _ #:unwind-for-type _)
  1736:10  8 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
  1731:15  7 (with-exception-handler #<procedure 38e1ca8 at ice-9/boot-9.scm:1815:7 (exn)> _ #:unwind? _ #:unwind-for-type _)
In guix/scripts/substitute.scm:
  1162:10  6 (_)
  1008:19  5 (process-substitution _ "/tmp/t" #:cache-urls _ #:acl _ #:print-build-trace? _)
In guix/utils.scm:
   212:12  4 (decompressed-port _ _)
In lzlib.scm:
    589:2  3 (make-lzip-input-port #<input: string 5661038>)
   287:25  2 (_)
   287:25  1 (_)
In ice-9/boot-9.scm:
   1615:4  0 (raise-exception #<&compound-exception components: (#<&assertion-failure> #<&origin origin: #f> #<&message message: "Wrong type to apply: ~S"> #<&irritants irritants: (#f)> #<&exc?>)
--8<---------------cut here---------------end--------------->8---

This is because under the hood liblz.so could not be loaded (but the
actual error is silently swallowed):

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,m(lzlib)
scheme@(lzlib)> (lzlib-procedure int "LZ_decompress_open" '())
$1 = #f
scheme@(lzlib)> %liblz 
$2 = "liblz"
scheme@(lzlib)> (dynamic-link %liblz)
ice-9/boot-9.scm:1669:16: In procedure raise-exception:
In procedure dynamic-link: file: "liblz", message: "file not found"

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(lzlib) [1]> ,q
--8<---------------cut here---------------end--------------->8---

Compare with a native build of guile-lzlib on GNU/Linux:

--8<---------------cut here---------------start------------->8---
scheme@(lzlib)> %liblz
$2 = "/gnu/store/jqr5bz89gfwhxcndnhq333dyclvkq7ws-lzlib-1.11/lib/liblz"
--8<---------------cut here---------------end--------------->8---

Indeed, the cross-compilation build log shows:

--8<---------------cut here---------------start------------->8---
checking dependency style of i586-pc-gnu-gcc... none
checking lzlib's file name... 
--8<---------------cut here---------------end--------------->8---

Ludo’.