Hi all,

I believe there's a untriggered bug in chapter 6, Re-adjusting the toolchain.

We've just entered the chroot, installed the kernel headers and built glibc.
At this point we still only have /tools/bin/gcc.  We've just built glibc so we 
have it under /lib.

Now we re-adjust the gcc (the /tools gcc, note) specs to use the newly built 
linker.

This is the code:

gcc -dumpspecs | sed \
    -e 's@/tools/lib/ld-linux.so.2@/lib/[EMAIL PROTECTED]' \
    -e '/\*startfile_prefix_spec:/{n;[EMAIL PROTECTED]@/usr/lib/ @}' \
    -e '/\*cpp:/{n;[EMAIL PROTECTED]@ -isystem /usr/[EMAIL PROTECTED]' > \
    `dirname $(gcc --print-libgcc-file-name)`/specs

this expands to /tools/lib/gcc/i686-pc-linux-gnu/4.1.2/specs (LFS-6.3)

So far, so (kinda) good, and still the problem is not triggered.

Then we go on building the rest of Chapter 6.  If this is all you ever use 
/tools for, and I'd say about 98% of the people building LFS do just that, 
you're ok.

Now, I remember reading in the book that /tools could be kept in case you want 
to build more instances of LFS.  I quickly scanned the LFS-6.3 but couldn't 
find the text.  Maybe it was in an older book and has been removed since.  But 
this is what we do for ipcop, we pack up /tools for speeding up future rebuilds.

Suppose you do want to use /tools to build another LFS and you tar it up (just 
/mnt/lfs/tools, not the rest in /mnt/lfs) and you unpack it on a new host and 
you chroot into it:

chroot "$LFS" /tools/bin/env -i \
    HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
    /tools/bin/bash --login +h

And now you want to build something.  Aha:


I have no name!:/# ls /
tools
I have no name!:/# 
I have no name!:/# echo 'main(){}' > test.c
I have no name!:/# gcc -v test.c
Reading specs from /tools/lib/gcc/i686-pc-linux-gnu/4.1.2/specs
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.1.2/configure --prefix=/tools 
--with-local-prefix=/tools --enable-clocale=gnu --enable-shared 
--enable-threads=posix --enable-__cxa_atexit --enable-languages=c,c++ 
--disable-libstdcxx-pch
Thread model: posix
gcc version 4.1.2
 /tools/libexec/gcc/i686-pc-linux-gnu/4.1.2/cc1 -quiet -v -isystem /usr/include 
test.c -quiet -dumpbase test.c -mtune=pentiumpro -auxbase test -version -o 
./ccjh2EpS.s
ignoring nonexistent directory "/usr/include"
ignoring nonexistent directory 
"/tools/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /tools/include
 /tools/lib/gcc/i686-pc-linux-gnu/4.1.2/include
End of search list.
GNU C version 4.1.2 (i686-pc-linux-gnu)
        compiled by GNU C version 4.1.2.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: bde1f24b4119042caf7e7373b8ff1063
 /tools/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../../i686-pc-linux-gnu/bin/as -V 
-Qy -o ./ccSRA7oz.o ./ccjh2EpS.s
GNU assembler version 2.17 (i686-pc-linux-gnu) using BFD version 2.17
 /tools/libexec/gcc/i686-pc-linux-gnu/4.1.2/collect2 --eh-frame-hdr -m elf_i386 
-dynamic-linker /lib/ld-linux.so.2 crt1.o crti.o 
/tools/lib/gcc/i686-pc-linux-gnu/4.1.2/crtbegin.o 
-L/tools/lib/gcc/i686-pc-linux-gnu/4.1.2 
-L/tools/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../../i686-pc-linux-gnu/lib 
./ccSRA7oz.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed 
-lgcc_s --no-as-needed /tools/lib/gcc/i686-pc-linux-gnu/4.1.2/crtend.o crtn.o
/tools/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../../i686-pc-linux-gnu/bin/ld: 
crt1.o: No such file: No such file or directory
collect2: ld returned 1 exit status
I have no name!:/# gcc -dumpspecs > specs
I have no name!:/# diff -Naur /tools/lib/gcc/i686-pc-linux-gnu/4.1.2/specs specs
--- /tools/lib/gcc/i686-pc-linux-gnu/4.1.2/specs        2007-09-19 
03:10:39.000000000 +0000
+++ specs       2007-12-10 06:55:36.000000000 +0000
@@ -15,7 +15,7 @@
  as %(asm_options) %|.s %A }

 *cpp:
-%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT} -isystem /usr/include
+%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}

 *cpp_options:
 %(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w} 
%{f*} %{g*:%{!g0:%{!fno-working-directory:-fworking-directory}}} %{O*} %{undef} 
%{save-temps:-fpch-preprocess}
@@ -108,7 +108,7 @@


 *startfile_prefix_spec:
-/usr/lib/
+

 *sysroot_spec:
 --sysroot=%R
@@ -133,7 +133,7 @@
 elf_i386

 *dynamic_linker:
-/lib/ld-linux.so.2
+/tools/lib/ld-linux.so.2

 *link_command:
 %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:    %(linker) %l %{pie:-pie} %X 
%{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}    %{s} %{t} %{u*} %{x} %{z} %{Z} 
%{!A:%{!nostdlib:%{!nostartfiles:%S}}}    %{static:} %{L*} %(mfwrap) 
%(link_libgcc) %o %(mflib)    
%{fprofile-arcs|fprofile-generate|coverage:-lgcov}    
%{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}    
%{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}
I have no name!:/#



So, we should not overwrite the /tools gcc specs in Chapter 6, but keep a copy 
of it in, say, /tools/lib/gcc/i686-pc-linux-gnu/4.1.2/specs-tools and rename it 
back after we build gcc in Chapter 6.  Then we can guarantee that /tools is 
self-sufficient.  Maybe we should do a pass 2 of the readjustment in Chapter 6. 
 This is what I'll do for ipcop, but if you come up with a better solution, I'd 
rather stick with LFS book.

IvanK.
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to