dslm4515 / Musl-LFS

Linux From Scratch using Musl as Libc
GNU General Public License v3.0
167 stars 21 forks source link

Why are we deleting GCC headers in /tools stage? #62

Closed takusuman closed 3 years ago

takusuman commented 3 years ago

https://github.com/dslm4515/Musl-LFS/blob/988f2c6b9c763df812e9f878eff7161976324248/doc/2-toolchain/04-gcc#L111-L114 Link related.

dslm4515 commented 3 years ago

That is a good question.

I could not trace where I got that from... definitely from LFS... but latest book no longer has it and their build method changed.

I have yet to try a build with those 3 commands omitted

takusuman commented 3 years ago

That is a good question.

I could not trace where I got that from... definitely from LFS... but latest book no longer has it and their build method changed.

I have yet to try a build with those 3 commands omitted

If i get an explanation for this, i will pull-request it for sure.

dslm4515 commented 3 years ago

Apparently, it's from Chapter 5.7 of LFS 6.3?

During the build process, GCC runs a script (fixincludes) that scans the system for header files that may need to be fixed (they might contain syntax errors, for example), and installs the fixed versions in a private include directory. There is a possibility that, as a result of this process, some header files from the host system have found their way into GCC's private include directory. As the rest of this chapter only requires the headers from GCC and Glibc, which have both been installed at this point, any “fixed” headers can safely be removed. This helps to avoid any host headers polluting the build environment. Run the following commands to remove the header files in GCC's private include directory (you may find it easier to copy and paste these commands, rather than typing them by hand, due to their length):

GCC_INCLUDEDIR=`dirname $(gcc -print-libgcc-file-name)`/include &&
find ${GCC_INCLUDEDIR}/* -maxdepth 0 -xtype d -exec rm -rvf '{}' \; &&
rm -vf `grep -l "DO NOT EDIT THIS FILE" ${GCC_INCLUDEDIR}/*` &&
unset GCC_INCLUDEDIR
dslm4515 commented 3 years ago

Which is strange because when LFS 6.3 was current, I wasnt even aware of Musl libc

takusuman commented 3 years ago

During the build process, GCC runs a script (fixincludes) that scans the system for header files that may need to be fixed (they might contain syntax errors, for example), and installs the fixed versions in a private include directory. There is a possibility that, as a result of this process, some header files from the host system have found their way into GCC's private include directory.

That's a good point.