From e9a652b5f0811defdb3d22e1bb679d2781add0c2 Mon Sep 17 00:00:00 2001 From: Dan Nichilson Date: Fri, 23 Mar 2007 21:05:26 +0000 Subject: Readjust the gcc header search path to include /usr/include and test it git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@7972 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- chapter06/readjusting.xml | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'chapter06/readjusting.xml') 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 -- cgit v1.2.3-54-g00ecf