GNU bug report logs - #30756
GCC >= 6 '-isystem' and C_INCLUDE_PATH behavior changed, breaking #include_next

Previous Next

Package: guix;

Reported by: julien lepiller <julien <at> lepiller.eu>

Date: Fri, 9 Mar 2018 12:12:01 UTC

Severity: important

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Giel van Schijndel <giel <at> mortis.eu>
To: Ludovic Courtès <ludo <at> gnu.org>, julien lepiller <julien <at> lepiller.eu>
Cc: 30756 <at> debbugs.gnu.org, Marius Bakke <mbakke <at> fastmail.com>
Subject: bug#30756: gcc7 doesn't find stdlib.h
Date: Fri, 4 May 2018 11:46:58 +0200
On 09-03-18 13:42, Ludovic Courtès wrote:
> julien lepiller <julien <at> lepiller.eu> skribis:
>
>> I'm trying to build a software that requires gcc>=7.2. Unfortunately,
>> the process crashes and ends with:
>>
>> /gnu/store/a4vwdk8r6p6l2mnffz4yaqlr1z6z6w3r-gcc-7.3.0/include/c++/cstdlib:75:15:
>> fatal error: stdlib.h: No such file or directory.
> On IRC Marius mentioned this bug report:
>
>   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129#c3
>
> Note that we use C_INCLUDE_PATH, which is equivalent to ‘-isystem’.

This is biting me too for a C++17 project I'm trying to build.

That GCC bug report (Jakub Jellinek) says that you shouldn't be using
-isystem for the default include directories. So I believe these paths
shouldn't get added to CPLUS_INCLUDE_PATH in the first place.

In that bug report there's a link to a CMake bug report with a link to a
solution employed by WebKit:
https://trac.webkit.org/changeset/205672/webkit/trunk/Source/cmake/OptionsCommon.cmake

That solution boils down to executing "g++ -v -E -x c++ /dev/null" and
extracting the list of (default) include directories from its output
then giving CMake that list to ensure it won't ever try to add it with
either -I or -isystem to the preprocessor's search path. I believe a
similar approach should be taken by (gnu packages gcc) (assuming that's
what is responsible for adding this).

To confirm that this works:
> $ env -u CPATH -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH c++ -v -E -x
> c++ /dev/null
> ...
> #include <...> search starts here:
>  /gnu/store/f9wi8xs84b29f5igp578hnqfpjnfn4gh-gcc-7.3.0/include/c++
>  /gnu/store/f9wi8xs84b29f5igp578hnqfpjnfn4gh-gcc-7.3.0/include/c++/x86_64-unknown-linux-gnu
>  /gnu/store/f9wi8xs84b29f5igp578hnqfpjnfn4gh-gcc-7.3.0/include/c++/backward
>  /gnu/store/8jp0v7q1g4g87ay94i7h7p54mcw48mf3-gcc-7.3.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.3.0/include
>  /gnu/store/8jp0v7q1g4g87ay94i7h7p54mcw48mf3-gcc-7.3.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.3.0/include-fixed
>  /gnu/store/4sqaib7c2dfjv62ivrg9b8wa7bh226la-glibc-2.26.105-g0890d5379c/include
> End of search list.
> ...

To get my C++17 project building I can take the auto-generated
CPLUS_INCLUDE_PATH and just strip every path from it that also occurs in
the above list and set it again with (setenv).

There's two problems with this:

1. It's a workaround for a break in the build environment that would
need to be copy-pasted to every project wishing to build C++ with a
modern GCC
2. My skill at Scheme/Guile isn't good enough to execute the above
command and capture its output from within the build phases, let alone
parse and use its result to clean up CPLUS_INCLUDE_PATH.

-- 
Met vriendelijke groet,
With kind regards,
Giel van Schijndel





This bug report was last modified 5 years and 109 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.