gnu: ld-wrapper: Also unset GUILE_LOAD_PATH.

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.

Series-to: 69396@debbugs.gnu.org
Series-postfix: core-updates
Series-version: 2
Series-changes: 2
 - Revert to load-compiled scheme to load ld.go
 - Refine comment

Change-Id: Iaaa721019f3646d851202bb018214ec9fcc04fd4
This commit is contained in:
Maxim Cournoyer 2024-02-25 15:47:13 -05:00 committed by Ludovic Courtès
parent 966fc61144
commit d1b8834927
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -1,23 +1,28 @@
#!@BASH@ #!@BASH@
# -*- mode: scheme; coding: utf-8; -*- # -*- mode: scheme; coding: utf-8; -*-
# XXX: We have to go through Bash because there's no command-line switch to # XXX: We have to go through Bash because there's no Guile command-line switch to
# augment %load-compiled-path, and because of the silly 127-byte limit for # ignore the various Guile load path related environment variables.
# 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>.
# 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_LOAD_COMPILED_PATH
unset GUILE_SYSTEM_PATH
unset GUILE_SYSTEM_COMPILED_PATH unset GUILE_SYSTEM_COMPILED_PATH
# Use `load-compiled' because `load' (and `-l') doesn't otherwise load our
# .go file, or causes extraneous `stat' system calls when the "-C" "/" arguments
# are provided.
main="(@ (gnu build-support ld-wrapper) ld-wrapper)" main="(@ (gnu build-support ld-wrapper) ld-wrapper)"
exec @GUILE@ -c "(load-compiled \"@SELF@.go\") (apply $main (cdr (command-line)))" "$@" exec @GUILE@ -c "(load-compiled \"@SELF@.go\") ($main (command-line))" "$@"
!# !#
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2020 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com> ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2024 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -285,9 +290,9 @@ library outside of ~a: ~s~%"
result result
(expand-arguments result))) (expand-arguments result)))
(define (ld-wrapper . args) (define (ld-wrapper args)
;; Invoke the real `ld' with ARGS, augmented with `-rpath' switches. ;; Invoke the real `ld' with ARGS, augmented with `-rpath' switches.
(let* ((args (expand-arguments args)) (let* ((args (expand-arguments (cdr args))) ;strip arg0
(path (library-search-path args)) (path (library-search-path args))
(libs (library-files-linked args path)) (libs (library-files-linked args path))
(args (append args (rpath-arguments libs)))) (args (append args (rpath-arguments libs))))