Subject: [bug#39414] [PATCH 2/2] gnu: commencement: Rationalize search path handling.

From: Jan Nieuwenhuizen <[email-masked]>
Date: Thu, 06 Feb 2020 07:25:33 +0100

Ludovic Courtès writes:

> This commit ensures that only packages that correspond to compilers have
> a search path set.  It also reduces manual handling of search path
> environment variables.

Beautiful, thank you!

>      (native-inputs `(("binutils" ,binutils-mesboot0)
> -                     ("gcc" ,gcc-core-mesboot)
> +
> +                     ;; GCC-CORE-MESBOOT must appear last because it also
> +                     ;; provides libc headers from Mes that we want to shadow
> +                     ;; with those of GLIBC-MESBOOT0.
>                       ("libc" ,glibc-mesboot0)
> +                     ("kernel-headers" ,%bootstrap-linux-libre-headers)
> +                     ("gcc" ,gcc-core-mesboot)
>  
>                       ("bash" ,%bootstrap-coreutils&co)
>                       ("coreutils" ,%bootstrap-coreutils&co)
>                       ("diffutils" ,diffutils-mesboot)
> -                     ("kernel-headers" ,%bootstrap-linux-libre-headers)
>                       ("make" ,make-mesboot0)))

Here it gets real interesting; it seems above you actually fix (or work
around?) a bug that allowed you to...

>      (arguments
>       (substitute-keyword-arguments (package-arguments gcc-core-mesboot)
>         ((#:phases phases)
>          `(modify-phases ,phases
>             (replace 'setenv
> -             (lambda* (#:key outputs #:allow-other-keys)
> -               (let ((out (assoc-ref outputs "out"))
> -                     (bash (assoc-ref %build-inputs "bash"))
> -                     (gcc (assoc-ref %build-inputs "gcc"))
> -                     (glibc (assoc-ref %build-inputs "libc"))
> -                     (kernel-headers (assoc-ref %build-inputs "kernel-headers")))
> -                 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
> -                 (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH"))
> -                 (setenv "C_INCLUDE_PATH" (string-append
> -                                           gcc "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include"
> -                                           ":" kernel-headers "/include"
> -                                           ":" glibc "/include"))
> -                 (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH"))
> -                 (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH"))
> -                 ;; FIXME: add glibc dirs to paths manually
> -                 (setenv "LIBRARY_PATH" (string-join
> -                                         (list (string-append glibc "/lib")
> -                                               (getenv "LIBRARY_PATH"))
> -                                         ":"))
> -                 (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH"))
> -                 (with-output-to-file "config.cache"
> -                   (lambda _
> -                     (display "
> +             (lambda _
> +               (setenv "CONFIG_SHELL" (which "sh"))
> +               (with-output-to-file "config.cache"
> +                 (lambda _
> +                   (display "
>  ac_cv_c_float_format='IEEE (little-endian)'
>  ")))
> -                 #t)))
> +               #t))

remove this monster.  Although I am especially happy with it, I am
unsure exactly how it works.

> -             (lambda* (#:key outputs #:allow-other-keys)
> -               (let* ((out (assoc-ref outputs "out"))
> -                      (binutils (assoc-ref %build-inputs "binutils"))
> -                      (bash (assoc-ref %build-inputs "bash"))
> -                      (gcc (assoc-ref %build-inputs "gcc"))
> -                      (glibc (assoc-ref %build-inputs "libc"))
> -                      (kernel-headers (assoc-ref %build-inputs "kernel-headers")))
> -                 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
> -                 (setenv "C_INCLUDE_PATH" (string-append
> -                                           gcc "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include"
> -                                           ":" kernel-headers "/include"
> -                                           ":" glibc "/include"
> -                                           ":" (getcwd) "/mpfr/src"))
> -                 (setenv "LIBRARY_PATH" (string-append glibc "/lib"
> -                                                       ":" gcc "/lib"))
> -                 (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH"))
> -                 (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH"))
> -                 #t)))
> +             (lambda _
> +               (setenv "CONFIG_SHELL" (which "sh"))
> +
> +               ;; Allow MPFR headers to be found.
> +               (setenv "C_INCLUDE_PATH"
> +                       (string-append (getcwd) "/mpfr/src:"
> +                                      (getenv "C_INCLUDE_PATH")))
> +
> +               ;; Set the C++ search path so that C headers can be found as
> +               ;; libstdc++ is being compiled.
> +               (setenv "CPLUS_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
> +               #t))

Similar here,

> -                     "--disable-build-with-cxx")))
> -           ((#:phases phases)
> -            `(modify-phases ,phases
> -               (replace 'setenv
> -                 (lambda* (#:key outputs #:allow-other-keys)
> -                   (let* ((out (assoc-ref outputs "out"))
> -                          (binutils (assoc-ref %build-inputs "binutils"))
> -                          (bash (assoc-ref %build-inputs "bash"))
> -                          (gcc (assoc-ref %build-inputs "gcc"))
> -                          (glibc (assoc-ref %build-inputs "libc"))
> -                          (kernel-headers (assoc-ref %build-inputs "kernel-headers")))
> -                     (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
> -                     (setenv "C_INCLUDE_PATH" (string-append
> -                                               gcc "/lib/gcc-lib/i686-unknown-linux-gnu/4.7.4/include"
> -                                               ":" kernel-headers "/include"
> -                                               ":" glibc "/include"
> -                                               ":" (getcwd) "/mpfr/src"))
> -                     (setenv "CPLUS_INCLUDE_PATH" (string-append
> -                                                   gcc "/lib/gcc-lib/i686-unknown-linux-gnu/4.7.4/include"
> -                                                   ":" kernel-headers "/include"
> -                                                   ":" glibc "/include"
> -                                                   ":" (getcwd) "/mpfr/src"))
> -                     (setenv "LIBRARY_PATH" (string-append glibc "/lib"
> -                                                           ":" gcc "/lib"))
> -                     (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH"))
> -                     (format (current-error-port) "CPLUS_INCLUDE_PATH=~a\n" (getenv "CPLUS_INCLUDE_PATH"))
> -                     (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH"))
> -                     #t))))))))))
> +                     "--disable-build-with-cxx"))))))))

and same here.

I tried your commit and it works for me.  Rebasing `wip-bootstrap' onto
it was some work as you might imagine.  The good news is that I finally
got it to "work" again (`wip-bootstrap' @ gitlab); the bad news is
that I have kept (or put back, actually) one of these 'setenv phases in
`gcc-mesboot0'.  Well, that's for later worry; so this will need another
look when merging the scheme-only "wip-bootsrap".

For this patch: LVGTM (looks /very/ good to me!).

Thank you!
janneke

-- 
Jan Nieuwenhuizen <[email-masked]> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com