Subject: Re: bug#37801: Possible insight into issue #30756 #include_next bug

From: Danny Milosavljevic <[email-masked]>
Date: Fri, 18 Oct 2019 02:03:44 +0200

Hi Carl,

On Thu, 17 Oct 2019 21:56:44 +0000
Carl Dong <[email-masked]> wrote:

> Note that the reason mingw-w64-x86_64-6.0.0/include is in this list at all is
> because of the 'fix-env phase I added, which plucked it from CPATH and plopped
> it into CROSS_CPATH.

Yeah, I did the same in sunxi-tools--which was also broken after the core-updates
merge, but had been working fine before.
It's using an x86_64->ARM cross compiler.
But just changing it to CROSS_CPATH works, there.

> 3. Does this reveal something more fundamentally wrong with how we build our
> search paths in the first place that should be addressed

I think so.  I can't figure out why Guix is not just setting up CROSS_CPATH
on its own in the first place.
gnu/packages/cross-base.scm DOES have a search-path specification for CROSS_CPATH.

Notes:

* CPATH is something like "-I", but CPATH applies after all command-line "-I"s.
* C_INCLUDE_PATH, CPLUS_INCLUDE_PATH and OBJC_INCLUDE_PATH are something like
"-isystem", but they apply after all command-line "-isystem"s.

Note that an empty (colon-separated) element in those environment variables
means "current working directory".

https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/Directory-Options.html :

>If a standard system include directory, or a directory specified with
>-isystem, is also specified with -I, the -I option is ignored. The
>directory is still searched but as a system directory at its normal
>position in the system include chain. This is to ensure that GCC's
>procedure to fix buggy system headers and the ordering for the
>include_next directive are not inadvertently changed. If you really
>need to change the search order for system directories, use the
>-nostdinc and/or -isystem options. 

https://gcc.gnu.org/onlinedocs/cpp/Invocation.html#Invocation :

>The lookup order is as follows:
> For the quote form of the include directive, the directory of the current file is searched first.
> For the quote form of the include directive, the directories specified by -iquote options are searched in LTR order.
> Directories specified with -I options are scanned in left-to-right order.
> Directories specified with -isystem options are scanned in left-to-right order.
> Standard system directories are scanned[, except if -nostdinc[++] is specified].
> Directories specified with -idirafter options are scanned in left-to-right order.