Subject: bug#30756: gcc7 doesn't find stdlib.h

From: [email-masked] (Ludovic Courtès)
Date: Fri, 04 May 2018 17:28:26 +0200

Giel van Schijndel <[email-masked]> skribis:

> On 04-05-18 14:43, Ludovic Courtès wrote:

[...]

>> Giel, does the patch below work for you?
>
> No, just by itself it doesn't. It does add 'CPATH', but doesn't drop
> 'C_INCLUDE_PATH' and 'CPLUS_INCLUDE_PATH'.

That’s probably because your package still includes gcc@5 as an implicit
input via ‘cmake-build-system’.

You could use a procedure like this to remove implicit inputs and add
your own GCC variant:

--8<---------------cut here---------------start------------->8---
(define (package-with-specific-compiler p compiler)
  "Return P modified to be built with COMPILER."
  (package
    (inherit p)
    (arguments
     `(#:implicit-inputs? #f ,@(package-arguments p)))
    (native-inputs `(("compiler" ,compiler)
                     ,@(package-native-inputs p)))
    (inputs (append (package-inputs p)
                    (alist-delete "gcc" (standard-packages))))))
--8<---------------cut here---------------end--------------->8---

… where ‘standard-packages’ comes from (guix build-system gnu).

> But I can no longer build with warnings treated as error at that point,
> because I'm getting a ton of warnings inside headers of dependencies
> now. With either of '-Wno-error' or '-w' I can build now.

Yeah, that’s a downside (that was the reason why we switched from CPATH
to C_INCLUDE_PATH a while back), but it could be a reasonable
workaround for now.

> Would it be possible to filter the list of directories added to these
> environment variables to exclude those already present in GCC's default
> search path?

I still don’t fully understand the issue actually.  What’s wrong with
having these directories appear several times in the search path?

The difficulty here will be that search path environment variables in
Guix are populated automatically based on their specifications, so it’s
not all that clear to me where that filtering would happen.

Thanks,
Ludo’.