Bug 48957 - GCC's handling of include-fixed does not work well with --sysroot
Summary: GCC's handling of include-fixed does not work well with --sysroot
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 14.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: build
Depends on:
Blocks:
 
Reported: 2011-05-11 04:42 UTC by Paul Smith
Modified: 2024-09-14 20:25 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-03-12 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Smith 2011-05-11 04:42:42 UTC
When GCC builds, it creates and stows away internally an "include-fixed" directory containing "fixed-up" versions of the system headers files on the system it was built with.  This feels wrong to me: it gives GCC a hard dependency on the specific set of system header files present when GCC was built.  It's potentially incorrect even for straightforward installations, where a newer header file provided with a package upgrade might be ignored in preference to an older "fixed" version.  However, when attempting to create a relocatable version of GCC it's even more problematic.

In particular, it seems very wrong (and, in fact, it often doesn't work) to search the include-fixed directory when the user has specified a --sysroot flag, choosing to compile against a wholly different set of headers and libraries than the ones on the host system.

I think that the include-fixed directory should be associated with the sysroot, somehow, not embedded deeply into the compiler internals, and when --sysroot is provided there should be a well-known location inside the sysroot which will be searched for include-fixed headers.

Also, the fixinc.sh script should be better documented and enhanced to be simpler to run, so that it can be invoked more easily against a given sysroot to construct the include-fixed directory for that sysroot.
Comment 1 jsm-csl@polyomino.org.uk 2011-05-11 10:16:53 UTC
On Wed, 11 May 2011, psmith at gnu dot org wrote:

> I think that the include-fixed directory should be associated with the sysroot,

It should be associated with each system include directory (sysroot or 
otherwise) - so there should be a fixed version of /usr/local/include, 
searched immediately before /usr/local/include, and likewise for 
/usr/include.  But there are certainly sysroot uses where include-fixed is 
still relevant - where the sysroot is based on a copy of that used when 
GCC was built, but with extra libraries added.  (That's the case of 
sysroots that works most reliably for other reasons as well; GCC's runtime 
libraries get configured depending on the libc libraries and headers 
present when GCC was built, and in some cases the headers affect the 
configuration of GCC itself as well as GCC's libraries.)

http://gcc.gnu.org/ml/gcc-patches/2010-07/msg02088.html
http://gcc.gnu.org/ml/gcc/2004-11/msg00255.html
Comment 2 Eric Gallager 2018-03-12 02:34:21 UTC
(In reply to joseph@codesourcery.com from comment #1)
> On Wed, 11 May 2011, psmith at gnu dot org wrote:
> 
> > I think that the include-fixed directory should be associated with the sysroot,
> 
> It should be associated with each system include directory (sysroot or 
> otherwise) - so there should be a fixed version of /usr/local/include, 
> searched immediately before /usr/local/include, and likewise for 
> /usr/include.

This sounds like an agreement that some form of change would be worthwhile; I'm going to take that as confirmation.

> But there are certainly sysroot uses where include-fixed is 
> still relevant - where the sysroot is based on a copy of that used when 
> GCC was built, but with extra libraries added.  (That's the case of 
> sysroots that works most reliably for other reasons as well; GCC's runtime 
> libraries get configured depending on the libc libraries and headers 
> present when GCC was built, and in some cases the headers affect the 
> configuration of GCC itself as well as GCC's libraries.)
> 
> http://gcc.gnu.org/ml/gcc-patches/2010-07/msg02088.html
> http://gcc.gnu.org/ml/gcc/2004-11/msg00255.html

Shouldn't it be possible to come up with a solution that still supports those cases while also fixing the cases Paul described?
Comment 3 Eric Gallager 2019-03-12 19:49:26 UTC
(In reply to Eric Gallager from comment #2)
> (In reply to joseph@codesourcery.com from comment #1)
> > On Wed, 11 May 2011, psmith at gnu dot org wrote:
> > 
> > > I think that the include-fixed directory should be associated with the sysroot,
> > 
> > It should be associated with each system include directory (sysroot or 
> > otherwise) - so there should be a fixed version of /usr/local/include, 
> > searched immediately before /usr/local/include, and likewise for 
> > /usr/include.
> 
> This sounds like an agreement that some form of change would be worthwhile;
> I'm going to take that as confirmation.
> 
> > But there are certainly sysroot uses where include-fixed is 
> > still relevant - where the sysroot is based on a copy of that used when 
> > GCC was built, but with extra libraries added.  (That's the case of 
> > sysroots that works most reliably for other reasons as well; GCC's runtime 
> > libraries get configured depending on the libc libraries and headers 
> > present when GCC was built, and in some cases the headers affect the 
> > configuration of GCC itself as well as GCC's libraries.)
> > 
> > http://gcc.gnu.org/ml/gcc-patches/2010-07/msg02088.html
> > http://gcc.gnu.org/ml/gcc/2004-11/msg00255.html
> 
> Shouldn't it be possible to come up with a solution that still supports
> those cases while also fixing the cases Paul described?

Joseph, can you think of one?
Comment 4 jsm-csl@polyomino.org.uk 2019-03-13 18:35:08 UTC
Well, I suppose you could have a new option to say what set of fixed 
headers to use, in the case where your sysroot is not based on the one 
used when building GCC.