Bug 7882

Summary: gcc detects sdl and boost from sysroot
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Richard Purdie <richard.purdie>
Component: devtools / tool chainAssignee: Leonardo Sandoval Gonzalez <leonardo.sandoval.gonzalez>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: anibal.limon, leonardo.sandoval.gonzalez, meta.mr.watcher, meta.watcher, raj.khem
Version: 1.8   
Target Milestone: 1.9 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
Screen shot showing gcc package contents differences
none
diff between a clean and a 'dirty' tmp/work/i586-poky-linux/gcc/4.9.2-r0/image directory none

Description Richard Purdie 2015-06-11 17:25:46 UTC
Created attachment 2545 [details]
Screen shot showing gcc package contents differences

It appears gcc (on target version) can detect sdl and boost in the sysroot and change its include-fixed content depending on whether these have previously built or not.
Comment 1 Richard Purdie 2015-06-18 15:12:25 UTC
In a clean build, "bitbake gcc" and you'll see gcc packages with a certain set of files. If you then "bitbake sdl boost"; bitbake gcc -c cleansstate; bitbake gcc you'll see there are new files appearing. The gcc build detects sdl and boost and generates new headers which means the build is not deterministic. We need to stop it detecting sdl/boost and any other things it may autodetect.
Comment 2 Leonardo Sandoval Gonzalez 2015-06-18 20:27:29 UTC
Created attachment 2557 [details]
diff between a clean and a 'dirty' tmp/work/i586-poky-linux/gcc/4.9.2-r0/image directory
Comment 3 Leonardo Sandoval Gonzalez 2015-06-19 22:38:24 UTC
On the gcc's compile stage, there is a script called fixinc.sh which gets called, and one of its tasks is to parse the headers files on  "build/tmp/sysroots/MACHINE/usr/include" (note, it looks into sysroot) and feed these into "build/tmp/work/i586-poky-linux/gcc/4.9.2-r0/gcc-4.9.2/build/i586-poky-linux.i586-poky-linux/build-x86_64-linux/fixincludes/fixincl" binary. The purpose of the latter as is the following:

"Install modified versions of certain ANSI-incompatible system header  files which are fixed to work correctly with ANSI C and placed in a  directory that GCC will search."

as a result, the fixincl writes this modified headers into gcc's "include-fixed" folder. 

In general, it is expected to have different results (as note by RP) depending on the content on "sysrooots/.../include". If we want a deterministic behavior, we can avoid the fixincl call, but before doing it, we need to understand the consequences.
Comment 4 Richard Purdie 2015-06-22 14:25:40 UTC
I added Khem to cc who may have ideas on how we fix this. I think we may have to whitelist the set of headers we install from this directory to ones we know are in the dependency chain so the build is deterministic.
Comment 5 Khem Raj 2015-06-28 17:35:12 UTC
(In reply to comment #3)
> On the gcc's compile stage, there is a script called fixinc.sh which gets
> called, and one of its tasks is to parse the headers files on 
> "build/tmp/sysroots/MACHINE/usr/include" (note, it looks into sysroot) and
> feed these into
> "build/tmp/work/i586-poky-linux/gcc/4.9.2-r0/gcc-4.9.2/build/i586-poky-linux.
> i586-poky-linux/build-x86_64-linux/fixincludes/fixincl" binary. The purpose
> of the latter as is the following:
> 
> "Install modified versions of certain ANSI-incompatible system header  files
> which are fixed to work correctly with ANSI C and placed in a  directory
> that GCC will search."
> 
> as a result, the fixincl writes this modified headers into gcc's
> "include-fixed" folder. 
> 
> In general, it is expected to have different results (as note by RP)
> depending on the content on "sysrooots/.../include". If we want a
> deterministic behavior, we can avoid the fixincl call, but before doing it,
> we need to understand the consequences.

fixedinclude is whats kicking in here and they have logic to detect certain anamolies in installed headers and if it finds those in any header file it will tweak it ( fix it in gcc terms ) and cache them in fixed-include, then gcc machinary is designed to prefer this version so the tweaks are effective when using gcc.

consequences can be a buggy compiler from gcc developers point of view. Linux distributions generally lets fixincludes hacks work as it is, but OSes like freebsd do not allow gcc to fix any of system headers. However, if we choose to remove fixed-includes, then we should remove it completely so we do not fix any of the headers of if we do then we do that manually on a known headers ( e.g. limits.h etc ). Currently what you see is a problem that has dynamic results which means its not limited to boost or sdl headers but depends on what you have in your sysroot. 

In anycase, if we want to drop fixed-includes, this will make us different from rest of linux systems, so we will have to be cognizant of that fact and own this change and maintain this configuration. 

I personally dont like fixed-includes and may be it served gcc's pursuit for platform independence in past but may be out of fashion in now, but it may be not something we/oe can fix alone.
Comment 6 Leonardo Sandoval Gonzalez 2015-09-15 15:10:09 UTC
Patch merged in master:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=1efd172dd89d13e10269c13d9ed8bb1c7f7ea2f0