From afc6823ff1ba62556cd61011dcda259b7fb99f0b Mon Sep 17 00:00:00 2001 From: Pierre Labastie Date: Mon, 20 Apr 2020 12:50:49 +0000 Subject: [PATCH] Change -isystem to -idirafter in "adjusting". Fix most of #4641. git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@11819 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- chapter01/changelog.xml | 14 ++++++++++++++ chapter06/adjusting.xml | 19 +++++++++++++------ general.ent | 6 +++--- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/chapter01/changelog.xml b/chapter01/changelog.xml index 1cc5ae937..8d5a3ce9a 100644 --- a/chapter01/changelog.xml +++ b/chapter01/changelog.xml @@ -42,6 +42,20 @@ or as appropriate for the entry or if needed the entire day's listitem. --> + + 2020-04-20 + + + [pierre] - Change -isystem to -idirafter in "Adjusting the + toolchain". This allows to search g++ private headers before + the public ones, which is the normal search order, with the + drawback that it includes the headers in /tools if they exist + in both /usr and /tools. Fix most of + #4641. + + + + 2020-04-19 diff --git a/chapter06/adjusting.xml b/chapter06/adjusting.xml index 5852d2958..3e6b49e19 100644 --- a/chapter06/adjusting.xml +++ b/chapter06/adjusting.xml @@ -24,15 +24,17 @@ mv -v /tools/$(uname -m)-pc-linux-gnu/bin/{ld,ld-old} mv -v /tools/bin/{ld-new,ld} ln -sv /tools/bin/ld /tools/$(uname -m)-pc-linux-gnu/bin/ld - Next, amend the GCC specs file so that it points to the new - dynamic linker. Simply deleting all instances of /tools should - leave us with the correct path to the dynamic linker. Also adjust the specs file - so that GCC knows where to find the correct headers and Glibc start files. + the next command amends the GCC specs file to achieve three goals: + first point GCC to the new dynamic linker. Simply deleting all instances of + /tools should leave us with the correct path to the dynamic + linker. Second, let GCC know where to find the Glibc start files. Third, + add the /usr/include directory at the end of the default search path, so + that header files added in chapter 6 are found. A sed command accomplishes this: gcc -dumpspecs | sed -e 's@/tools@@g' \ -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \ - -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > \ + -e '/\*cpp:/{n;s@$@ -idirafter /usr/include@}' > \ `dirname $(gcc --print-libgcc-file-name)`/specs It is a good idea to visually inspect the specs file to verify the @@ -72,13 +74,18 @@ readelf -l a.out | grep ': /lib' Verify that the compiler is searching for the correct header files: -grep -B1 '^ /usr/include' dummy.log +grep -B4 '^ /usr/include' dummy.log This command should return the following output: #include <...> search starts here: + /tools/lib/gcc/x86_64-pc-linux-gnu/&gcc-version;/include + /tools/include + /tools/lib/gcc/x86_64-pc-linux-gnu/&gcc-version;/include-fixed /usr/include + On a 32 bit system, x86_64 is replaced with i686. + Next, verify that the new linker is being used with the correct search paths: grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g' diff --git a/general.ent b/general.ent index faa2fcc7a..ebd59a1dd 100644 --- a/general.ent +++ b/general.ent @@ -1,13 +1,13 @@ - + - + - +