Subject: [bug#69396] [PATCH core-updates] gnu: ld-wrapper: Also unset GUILE_LOAD_PATH.

From: Ludovic Courtès <[email-masked]>
Date: Sun, 25 Feb 2024 22:49:59 +0100

Hi,

Maxim Cournoyer <[email-masked]> skribis:

> The following problem was discovered while attempting to configure Guix to use
> a locally built Guile tree, via its meta/uninstalled-env script, which would
> attempt to use the newer Guile source files and fail with:
>
>   Pre-boot error; key: unbound-variable, args: (#f "Unbound variable:
>   ~S" (error) #f)collect2: fatal error: ld terminated with signal 6 [Aborted]
>
> With the following change, a Guix user may now configure their build to use a
> locally built Guile with e.g.:
>
>   ~/src/guile/meta/uninstalled-env ./configure --localstatedir=/var \
>   --sysconfdir=/etc
>
> * gnu/packages/ld-wrapper.in: Unset GUILE_LOAD_PATH.  Also unset
> GUILE_SYSTEM_PATH, for symmetry.  Streamline exec call, using the now fixed
> '-l' option.
> (ld-wrapper): Fix args being a nested list, and strip its arg0.

[...]

> -# XXX: We have to go through Bash because there's no command-line switch to
> -# augment %load-compiled-path, and because of the silly 127-byte limit for
> -# the shebang line in Linux.
> -# Use `load-compiled' because `load' (and `-l') doesn't otherwise load our
> -# .go file (see <http://bugs.gnu.org/12519>).
> -# Unset 'GUILE_LOAD_COMPILED_PATH' to make sure we do not stumble upon
> -# incompatible .go files.  See
> -# <https://lists.gnu.org/archive/html/guile-devel/2016-03/msg00000.html>.
> +# XXX: We have to go through Bash because there's no Guile command-line switch to
> +# ignore the various Guile load path related environment variables.
>  
> +# Unset 'GUILE_LOAD_PATH' to make sure we do not stumble upon
> +# incompatible Guile files (see
> +# <https://lists.gnu.org/archive/html/guile-devel/2016-03/msg00000.html>).
> +
> +unset GUILE_LOAD_PATH
>  unset GUILE_LOAD_COMPILED_PATH
> +unset GUILE_SYSTEM_PATH
>  unset GUILE_SYSTEM_COMPILED_PATH

OK for this part (I guess nobody tried that before!).

> -main="(@ (gnu build-support ld-wrapper) ld-wrapper)"
> -exec @GUILE@ -c "(load-compiled \"@SELF@.go\") (apply $main (cdr (command-line)))" "$@"
> +
> +exec  @GUILE@ \
> +-l @SELF@ \
> +-e '(@ (gnu build-support ld-wrapper) ld-wrapper)' -s "$0" "$@"

@SELF@ might need to be enclosed in double quotes for good measure.

Can you check through ‘strace’ how loading with ‘-l’ compares to
(load-compiled …)?

Otherwise LGTM, thanks!

Ludo’.