Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 536878 - toolchain.eclass: disable fixincludes rather than undoing it
Summary: toolchain.eclass: disable fixincludes rather than undoing it
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-17 17:42 UTC by Michał Górny
Modified: 2023-09-29 09:42 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch to the eclass (toolchain.eclass.diff,885 bytes, patch)
2015-01-17 17:42 UTC, Michał Górny
Details | Diff
Patch updated to handle gcc-3* (toolchain.eclass.diff,992 bytes, patch)
2015-01-17 18:33 UTC, Michał Górny
Details | Diff
stub out fixed includes (stub-fixed-includes.patch,1.36 KB, patch)
2015-01-18 20:42 UTC, Anthony Basile
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2015-01-17 17:42:00 UTC
Created attachment 394182 [details, diff]
Patch to the eclass

The fixincludes script from gcc is quite ugly in design. It wastes some time during build-time and confuses users like me who think 'this looks like a really bad idea'. Then I notice the gcc ebuild basically undoes the whole fixinclude thing by grepping for generated include files and removing them...

So I'm attaching a patch that instead stubs out fixincludes. End result is the same but the script no longer wastes time and its output no longer confuses people. While at it, it's also safer than the ugly find/rm loop.

Tested with 4.9.2. Running builds of older versions with the patch right now.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2015-01-17 18:33:46 UTC
Created attachment 394192 [details, diff]
Patch updated to handle gcc-3*

The previous patch worked fine for all gcc-4.* slots but failed for gcc-3. Here's one that works fine with newest version in all in-tree 3.* and 4.* slots.
Comment 2 Anthony Basile gentoo-dev 2015-01-18 18:20:06 UTC
(In reply to Michał Górny from comment #1)
> Created attachment 394192 [details, diff] [details, diff]
> Patch updated to handle gcc-3*
> 
> The previous patch worked fine for all gcc-4.* slots but failed for gcc-3.
> Here's one that works fine with newest version in all in-tree 3.* and 4.*
> slots.

I compile tested 3.3 to 4.9 with no problems.  For 4.9.2 I compared all .h's that would be put on the tree and they are identical.  So this looks good to me.

Post to gentoo-dev@ with the usual 2-3 day wait and then commit it.
Comment 3 Anthony Basile gentoo-dev 2015-01-18 20:42:03 UTC
Created attachment 394304 [details, diff]
stub out fixed includes

I've also tested and it seems you don't generate sym links in gcc/include* so we can get rid of that too.
Comment 5 Ryan Hill (RETIRED) gentoo-dev 2015-01-28 23:43:10 UTC
fixinclude is meant to sanitize headers for building GCC itself.  You won't run into any problems on a standard glibc system, but I'd be surprised if this doesn't break BSD.
Comment 6 Ryan Hill (RETIRED) gentoo-dev 2015-01-28 23:51:00 UTC
for example https://gcc.gnu.org/PR51705 / bug #444678
Comment 7 Anthony Basile gentoo-dev 2015-01-29 00:45:42 UTC
(In reply to Ryan Hill from comment #5)
> fixinclude is meant to sanitize headers for building GCC itself.  You won't
> run into any problems on a standard glibc system, but I'd be surprised if
> this doesn't break BSD.

I wondered if you needed them for building gcc itself because you removed them after they were built, but i just couldn't convince myself looking at what was generated.  I did consider BSD.

Perhaps we should poke the bsd people to test and revert if it does.
Comment 8 Ryan Hill (RETIRED) gentoo-dev 2015-01-30 05:13:28 UTC
The prefix guys would probably be affected as well, but I think they forked the eclass a long time ago.

In any case I think this should be reverted.  Most people probably don't need it but some might, and I don't like the idea that one bad header sneaking in could render GCC unbuildable for everybody.  Potentially breaking systems outweighs saving a couple minutes of build time.
Comment 9 Fabian Groffen gentoo-dev 2015-01-30 06:48:11 UTC
Like said in another place, we /need/ the fix-included headers, so please make it a switch we can easily enable.
Comment 10 Anthony Basile gentoo-dev 2015-01-30 18:06:19 UTC
(In reply to Ryan Hill from comment #8)
> The prefix guys would probably be affected as well, but I think they forked
> the eclass a long time ago.
> 
> In any case I think this should be reverted.  Most people probably don't
> need it but some might, and I don't like the idea that one bad header
> sneaking in could render GCC unbuildable for everybody.  Potentially
> breaking systems outweighs saving a couple minutes of build time.

I agreee with not rendering gcc unbuildable.  I'll email the list and revert.

@Ryan, thanks for looking over my shoulders!
Comment 11 Anthony Basile gentoo-dev 2015-01-30 18:21:28 UTC
(In reply to Fabian Groffen from comment #9)
> Like said in another place, we /need/ the fix-included headers, so please
> make it a switch we can easily enable.

Sorry dude.  I will restore it.  I don't want to exclude anyone.  I don't have Ryan's memory why pieces were added to toolchain.eclass.  I tested extensively but only in linux and non-prefix.
Comment 12 Fabian Groffen gentoo-dev 2015-01-31 07:49:22 UTC
(In reply to Anthony Basile from comment #11)
> Sorry dude.  I will restore it.  I don't want to exclude anyone.  I don't
> have Ryan's memory why pieces were added to toolchain.eclass.  I tested
> extensively but only in linux and non-prefix.

No worries!  Thanks!
Comment 13 Anthony Basile gentoo-dev 2015-02-06 13:10:28 UTC
(In reply to Fabian Groffen from comment #12)
> (In reply to Anthony Basile from comment #11)
> > Sorry dude.  I will restore it.  I don't want to exclude anyone.  I don't
> > have Ryan's memory why pieces were added to toolchain.eclass.  I tested
> > extensively but only in linux and non-prefix.
> 
> No worries!  Thanks!

Reverted with a long comment on why we need to do things as we do to future proof against stupidity.  Please take a look and let me know if there's still more to be done.

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.eclass?r1=1.648&r2=1.649

Not to detract too far from the original purpose of this bug, but maybe now we can merge the prefix toolchain.eclass into the tree.  To be clear what's the official prefix overlay url?
Comment 14 Guilherme Amadio gentoo-dev 2015-02-06 13:55:06 UTC
Official prefix is here: http://rsync8.prefix.bitzolder.nl/hg/prefix-tree
Comment 15 Michael Haubenwallner (RETIRED) gentoo-dev 2015-02-06 15:00:30 UTC
For Linux, IMO the reasoning why we can remove the "fixed" headers is not that they break things (shouldn't that be fixed within gcc-fixincludes anyway?), but that we have full control over the original headers and prefer fixing these to get them work with gcc.

For Prefix (and others), we don't have control over the original headers, so we need to use the "fixed" ones instead.
Comment 16 Anthony Basile gentoo-dev 2015-02-06 17:42:31 UTC
(In reply to Michael Haubenwallner from comment #15)
> For Linux, IMO the reasoning why we can remove the "fixed" headers is not
> that they break things (shouldn't that be fixed within gcc-fixincludes
> anyway?), but that we have full control over the original headers and prefer
> fixing these to get them work with gcc.

Interesting perspective.  The original point of fixincludes is that gcc requires ansi compliant headers to build and some unix vendors didn't provide them.  Hence the hack.  But I'm guessing that in linux a lot of those fixes got upstreamed.  I was able to compile all versions of gcc in the tree (except 2.95) without the fixincludes on a system with 2000+ common packages.  I even tested on my ubuntu box and didn't have any issues.

> 
> For Prefix (and others), we don't have control over the original headers, so
> we need to use the "fixed" ones instead.

Right.  I can see merit in having them if needed.  I just didn't think of prefix.
Comment 17 Anthony Basile gentoo-dev 2015-02-06 18:00:02 UTC
(In reply to Anthony Basile from comment #16)
> > 
> > For Prefix (and others), we don't have control over the original headers, so
> > we need to use the "fixed" ones instead.
> 
> Right.  I can see merit in having them if needed.  I just didn't think of
> prefix.

BTW, this is a good read by Felker, the author of musl, on why fixincludes are a bad idea: http://ewontfix.com/12/  It would be nice to get rid of the altogether,b ut as I said, if they're needed, they're needed.
Comment 18 Anthony Basile gentoo-dev 2015-02-09 23:05:54 UTC
(In reply to Guilherme Amadio from comment #14)
> Official prefix is here: http://rsync8.prefix.bitzolder.nl/hg/prefix-tree

Thanks I cloned and looked at it.  I'm not sure what the ${D} -> ${ED} and ${EPREFIX} might break, like maybe cross compiling?  We'd probably have to test in all cases where toolchains.eclass is consumed to make sure those updates are okay.  I might have time to do that over the summer.

I'm going to close this bug because the original issue was dealt with (not really fixed because it wasn't a problem in the first place).
Comment 19 Benda Xu gentoo-dev 2015-04-07 02:34:39 UTC
Hi Anthony,

(In reply to Anthony Basile from comment #18)
>
> Thanks I cloned and looked at it.  I'm not sure what the ${D} -> ${ED} and
> ${EPREFIX} might break, like maybe cross compiling?  We'd probably have to
> test in all cases where toolchains.eclass is consumed to make sure those
> updates are okay.  I might have time to do that over the summer.
> 
> I'm going to close this bug because the original issue was dealt with (not
> really fixed because it wasn't a problem in the first place).

I would like to point you to bug 531610 for Prefix support, where I made a patch for your review.

Benda
Comment 20 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-09-29 09:42:47 UTC
Upstream now have a proper --disable-fixincludes configure arg to disable it in GCC 13, see https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=be9dd80f9334800300a80268dbb92cf3fafcfcf8.

We're not using it yet because of:

commit 6ce12231a50fd05970501f67adc916754a21fe60
Author: Sam James <sam@gentoo.org>
Date:   Tue Oct 4 02:23:32 2022 +0100

    toolchain.eclass: allow fixincludes for >= GCC 13

    Signed-off-by: Sam James <sam@gentoo.org>

... for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107128. But hopefully we can change that at some point.