Subject: Re: Qemu 4.2.0 build for x86_64-linux fails

From: Mathieu Othacehe <[email-masked]>
Date: Mon, 24 Feb 2020 10:36:28 +0100

Hey,

> So is it expected that C_INCLUDE_PATH comes before the hard-coded GCC
> include directory?  How can we work around that?

Turns out, the best source of documentation here is
gcc/incpath.c. Here's a summary of my understanding.

Header search list:

* QUOTE
 -> -iquote 
* BRACKET
 -> -I goes here
 -> CPATH goes here
* SYSTEM
 -> -isystem goes here
 -> C_INCLUDE_PATH goes here
 -> Hardcoded includes (gcc + glibc) goes here
* AFTER
-> -idirafter goes here.

Duplicates inside SYSTEM are deleted, the first occurence is kept. So as
long as we have glibc in C_INCLUDE_PATH it will trigger deletion of
glibc in hardcoded includes and AFTER section.

So I can see only two solutions here.

1. Go back to using CPATH (sad!), because when there is duplication
between BRACKET and SYSTEM, the include from SYSTEM is kept (why it
works on master).

2. Find a way to remove glibc from C_INCLUDE_PATH, but I have no clue
how to do this properly. Maybe using some kind of filter on
search-path-specifications.

WDYT?

Mathieu