Finally, we get started building the system in Chapter 5. As mentioned in the last important point here, for every package done in Chapter 5, you need to do the following commands, as the 'lfs' user:
$ cd $LFS/sources
lfs:/mnt/lfs/sources$ tar xjvf binutils-2.20.tar.bz2
lfs:/mnt/lfs/sources$ cd binutils-2.20
If the downloaded package is a .gz file, then instead of 'xjvf', you do use 'xzvf' to untar it. 'j' uncompresses bz2 files while 'z' uncompresses .gz files. The untarring command is implied before you start each sub-chapter. I also finally figured out how to time multiple commands using the GNU time command (which has a nicer, seconds-only format) rather than the builtin bash 'time' command:
$ \time -f "\\n================\\nTotal time: %e seconds\\n================" bash -c "../binutils-2.20/configure \
--target=$LFS_TGT --prefix=/tools \
--disable-nls --disable-werror && make && make install"
[.... many many commands later ....]
================
Total time: 146.24 seconds
================
$ \time -f "\\n================\\nTotal time: %e seconds\\n================" bash -c " ../gcc-4.4.2/configure \
--target=$LFS_TGT --prefix=/tools \
--disable-nls --disable-shared --disable-multilib \
--disable-decimal-float --disable-threads \
--disable-libmudflap --disable-libssp \
--disable-libgomp --enable-languages=c && make && make install"
[....]
================
Total time: 678.12 seconds
================
I use \time
to make sure I'm not using any builtin or alias command - this picks up GNUs /usr/bin/time (read more about finding the correct time
in an earlier post). The -f
option lets you specify a printf-like statement for formatting the output, so in this case I want it to just show seconds (%e). The real tricky part was how to get the multiple commands to run as one command, as time
just times one single command. By invoking bash with its -c option, and quoting the entire rest of the line, we get it all together as one.
Oh, I also forgot to remove the source and build directories as specified in the book, so I needed to go back and do that for gcc and the binutils. And for the API headers, I understood it to mean that I needed to untar the linux-2.6.31.5.tar.bz2 file. And actually, that's one of the gotchas mentioned in the Linux Format's article:
Kernel API headers
A common mistake is to expect the kernel API headers to be in their own package. This is not the case - you will need to extract the kernel source package (usually of the form linux-2.6.x.tar.bz2) and then move into the extracted directory to follow the steps in the ebook.
For the binutils Pass 2 build, I needed to tweak the line a bit because of quoting problems:
$ \time -f "\\n================\\nTotal time: %e seconds\\n================" bash -c "CC=\"$LFS_TGT-gcc -B/tools/lib/\" \
AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \
../binutils-2.20/configure --prefix=/tools \
--disable-nls --with-lib-path=/tools/lib && make && make install"
[.....]
================
Total time: 135.00 seconds
================
Note the \" ...\" for the CC= line. This is so that it gets passed along correctly to the bash shell that gets run. I do wonder if the SBU time used should include the last 2 make commands specified on the binutils, Pass 2 page though. To get the current status of the SBUs for my system, you can see it here.
And I do know what LXF means when one of their caveats says to be careful with getting lulled into feeling it is always ./configure --prefix=/tools
! I have changed my sample timing command to be:
\time -f "\\n================\\nTotal time: %e seconds\\n================" bash -c "./configure --prefix=/tools && make && make install"
I have this in a file and I just copy / paste while running it in an Emacs shell. But every now and then, a configure slips in that wants just a little more...
I finished up with Chapter 5: Constructing a Temporary System without too many problems. I've really been enjoying the in depth exploration of exactly what gets built and why. I do wonder about some of the unapplied patches though. Perhaps because it is just the "bootstrap" system, they aren't important at this point. I also thought it very quaint that the book worries about disk space and gives advice on how to save a whole 95mb by stripping the apps and removing some doc files:)
Edit: turns out the manual, not surprisingly, does talk about the unapplied patches here::
Several of the packages are patched before compilation, but only when the patch is needed to circumvent a problem. A patch is often needed in both this and the next chapter, but sometimes in only one or the other. Therefore, do not be concerned if instructions for a downloaded patch seem to be missing
The series so far:
No comments:
Post a Comment