diff --git a/chapter01/changelog.xml b/chapter01/changelog.xml index 283832ae8..201d5a636 100644 --- a/chapter01/changelog.xml +++ b/chapter01/changelog.xml @@ -39,6 +39,12 @@ 2007-03-23 + + [dnicholson] - When readjusting the GCC specs file, ensure + that GCC will search for the system headers in /usr/include. An + addition to the toolchain sanity checks has been made to test + this. This fix originates from DIY Linux. + [dnicholson] - Included the branch update patch for the temporary Glibc in Chapter 5 to help minimize differences with the diff --git a/chapter06/gcc.xml b/chapter06/gcc.xml index e58472759..288e049f8 100644 --- a/chapter06/gcc.xml +++ b/chapter06/gcc.xml @@ -161,19 +161,20 @@ cd ../gcc-build href="readjusting.xml" xpointer="xpointer(//*[@os='g'])"/> +grep -B2 '^ /usr/include' dummy.log + +#include <...> search starts here: + /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include + /usr/include + -SEARCH_DIR("/usr/i686-pc-linux-gnu/lib") -SEARCH_DIR("/usr/local/lib") -SEARCH_DIR("/lib") -SEARCH_DIR("/usr/lib"); - @@ -182,6 +183,11 @@ SEARCH_DIR("/usr/lib"); href="readjusting.xml" xpointer="xpointer(//*[@os='k'])"/> +SEARCH_DIR("/usr/i686-pc-linux-gnu/lib") +SEARCH_DIR("/usr/local/lib") +SEARCH_DIR("/lib") +SEARCH_DIR("/usr/lib"); + @@ -218,6 +224,14 @@ SEARCH_DIR("/usr/lib"); href="readjusting.xml" xpointer="xpointer(//*[@os='t'])"/> + + + + diff --git a/chapter06/readjusting.xml b/chapter06/readjusting.xml index f72081f0c..d33e4758b 100644 --- a/chapter06/readjusting.xml +++ b/chapter06/readjusting.xml @@ -44,9 +44,10 @@ ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld linkend="ch-tools-toolchaintechnotes" role=","/> if necessary. -gcc -dumpspecs | \ -perl -p -e 's@/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g;' \ - -e 's@\*startfile_prefix_spec:\n@$_/usr/lib/ @g;' > \ +gcc -dumpspecs | sed \ + -e 's@/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' \ + -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \ + -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > \ `dirname $(gcc --print-libgcc-file-name)`/specs It is a good idea to visually inspect the specs file to verify the @@ -57,7 +58,7 @@ perl -p -e 's@/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g;' \ as expected. To do this, perform the following sanity checks: echo 'main(){}' > dummy.c -cc dummy.c -Wl,--verbose &> dummy.log +cc dummy.c -v -Wl,--verbose &> dummy.log readelf -l a.out | grep ': /lib' If everything is working correctly, there should be no errors, @@ -80,44 +81,54 @@ readelf -l a.out | grep ': /lib' /usr/lib/crti.o succeeded /usr/lib/crtn.o succeeded - Next, verify that the new linker is being used with the correct search paths: + Verify that the compiler is searching for the correct header + files: -grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g' +grep -B1 '^ /usr/include' dummy.log - If everything is working correctly, there should be no errors, + This command should return successfully with the following output: + +#include <...> search starts here: + /usr/include + + Next, verify that the new linker is being used with the correct search paths: + +grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g' + + If everything is working correctly, there should be no errors, and the output of the last command will be: SEARCH_DIR("/tools/i686-pc-linux-gnu/lib") SEARCH_DIR("/usr/lib") SEARCH_DIR("/lib"); - Next make sure that we're using the correct libc: + Next make sure that we're using the correct libc: -grep "/lib/libc.so.6 " dummy.log +grep "/lib/libc.so.6 " dummy.log - If everything is working correctly, there should be no errors, + If everything is working correctly, there should be no errors, and the output of the last command will be: -attempt to open /lib/libc.so.6 succeeded +attempt to open /lib/libc.so.6 succeeded - Lastly, make sure GCC is using the correct dynamic linker: + Lastly, make sure GCC is using the correct dynamic linker: -grep found dummy.log +grep found dummy.log - If everything is working correctly, there should be no errors, + If everything is working correctly, there should be no errors, and the output of the last command will be (allowing for platform-specific differences in dynamic linker name): -found ld-linux.so.2 at /lib/ld-linux.so.2 +found ld-linux.so.2 at /lib/ld-linux.so.2 - If the output does not appear as shown above or is not received + If the output does not appear as shown above or is not received at all, then something is seriously wrong. Investigate and retrace the steps to find out where the problem is and correct it. The most likely reason is that something went wrong with the specs file adjustment. Any issues will need to be resolved before continuing on with the process. - Once everything is working correctly, clean up the test files: + Once everything is working correctly, clean up the test files: -rm -v dummy.c a.out dummy.log +rm -v dummy.c a.out dummy.log