From 4e82d4787a775438ce10fc7e3ccefe9fcd23ccd0 Mon Sep 17 00:00:00 2001 From: Jeremy Huntwork Date: Fri, 5 Dec 2008 20:46:02 +0000 Subject: Bring in DIY's next generation build method. Move GRUB to chapter 8. git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@8755 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- chapter01/changelog.xml | 15 ++ chapter01/whatsnew.xml | 2 +- chapter03/patches.xml | 8 + chapter04/settingenviron.xml | 8 +- chapter05/adjusting.xml | 77 +++------- chapter05/binutils-pass1.xml | 59 ++------ chapter05/binutils-pass2.xml | 51 +++++-- chapter05/chapter05.xml | 6 +- chapter05/gcc-pass1.xml | 75 +++------- chapter05/gcc-pass2.xml | 139 ++++++++++-------- chapter05/glibc.xml | 62 +++----- chapter05/toolchaintechnotes.xml | 16 +- chapter06/chapter06.xml | 1 - chapter06/creatingdirs.xml | 5 +- chapter06/readjusting.xml | 7 +- chapter08/grub.xml | 305 ++++++++++++++++++++++++++++++--------- general.ent | 4 +- patches.ent | 3 + 18 files changed, 493 insertions(+), 350 deletions(-) diff --git a/chapter01/changelog.xml b/chapter01/changelog.xml index 0234a0601..73ff0326d 100644 --- a/chapter01/changelog.xml +++ b/chapter01/changelog.xml @@ -36,6 +36,21 @@ --> + + 2008-12-04 + + + [jhuntwork] - Introduce new build method in Chapter 5 originating + in DIY-Linux. Thanks, Greg Schafer. + + + [jhuntwork] - Move instructions for GRUB to chapter 8 just after the + compilation of the kernel. Merge GRUB build and configuration instructions + into one page. + + + + 2008-12-03 diff --git a/chapter01/whatsnew.xml b/chapter01/whatsnew.xml index 27495333f..5d3de12ff 100644 --- a/chapter01/whatsnew.xml +++ b/chapter01/whatsnew.xml @@ -213,7 +213,7 @@ Added: - None yet + &gcc-startfiles-patch; diff --git a/chapter03/patches.xml b/chapter03/patches.xml index 495a260da..9f7586c26 100644 --- a/chapter03/patches.xml +++ b/chapter03/patches.xml @@ -114,6 +114,14 @@ + + GCC Startfiles Fix Patch - &gcc-startfiles-patch-size;: + + Download: + MD5 sum: &gcc-startfiles-patch-md5; + + + Glibc Iconv Test Fixes Patch - &glibc-iconv-test-fixes-patch-size;: diff --git a/chapter04/settingenviron.xml b/chapter04/settingenviron.xml index e605fea6e..485269e3b 100644 --- a/chapter04/settingenviron.xml +++ b/chapter04/settingenviron.xml @@ -42,8 +42,9 @@ EOF umask 022 LFS=/mnt/lfs LC_ALL=POSIX +LFS_TGT=$(uname -m)-lfs-linux-gnu PATH=/tools/bin:/bin:/usr/bin -export LFS LC_ALL PATH +export LFS LC_ALL LFS_TGT PATH EOF The set +h command turns off @@ -76,6 +77,11 @@ EOF POSIX or C (the two are equivalent) ensures that everything will work as expected in the chroot environment. + The LFS_TGT variable sets a non-default, but compatible machine + description for use when building our cross compiler and linker and when cross + compiling our temporary toolchain. More information is contained in + . + By putting /tools/bin ahead of the standard PATH, all the programs installed in are picked up by the shell immediately after diff --git a/chapter05/adjusting.xml b/chapter05/adjusting.xml index a916e3621..dc02f05e5 100644 --- a/chapter05/adjusting.xml +++ b/chapter05/adjusting.xml @@ -12,26 +12,13 @@ Now that the temporary C libraries have been installed, all tools compiled in the rest of this chapter should be linked against - these libraries. In order to accomplish this, the linker and the - compiler's specs file need to be adjusted. - - The linker, adjusted at the end of the first pass of Binutils, needs - to be renamed so that it can be properly found and used. First, backup the - original linker, then replace it with the adjusted linker. We'll also - create a link to its counterpart in - /tools/$(gcc -dumpmachine)/bin: - -mv -v /tools/bin/{ld,ld-old} -mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old} -mv -v /tools/bin/{ld-new,ld} -ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld - - From this point onwards, everything will link only against the - libraries in /tools/lib. - - The next task is to point GCC to the new dynamic linker. This is done by - dumping GCC's specs file to a location where GCC will look for it - by default. A simple sed substitution then alters the + these libraries. In order to accomplish this, the cross-compiler's + specs file needs to be adjusted to point to the new dynamic linker + in /tools. + + This is done by dumping the compiler's specs file to a + location where it will look for it by default. + A simple sed substitution then alters the dynamic linker that GCC will use. The principle here is to find all references to the dynamic linker file in /lib or possibly /lib64 if the host system @@ -46,28 +33,12 @@ ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld of the dynamic linker, if necessary. -gcc -dumpspecs | sed 's@/lib\(64\)\?/ld@/tools&@g' > \ - `dirname $(gcc -print-libgcc-file-name)`/specs - - During the build process, GCC runs a script - (fixincludes) that scans the system for header files - that may need to be fixed (they might contain syntax errors, for example), - and installs the fixed versions in a private include directory. There is a - possibility that, as a result of this process, some header files from the - host system have found their way into GCC's private include directory. As - the rest of this chapter only requires the headers from GCC and Glibc, - which have both been installed at this point, any fixed - headers can safely be removed. This helps to avoid any host headers - polluting the build environment. Run the following commands to remove the - header files in GCC's private include directory (you may find it easier to - copy and paste these commands, rather than typing them by hand, due to - their length): - - -GCC_FIXED=`dirname $(gcc -print-libgcc-file-name)`/include-fixed && -find ${GCC_FIXED}/* -maxdepth 0 -xtype d -exec rm -rvf '{}' \; && -rm -vf `grep -l "DO NOT EDIT THIS FILE" ${GCC_FIXED}/*` && -unset GCC_FIXED +SPECS=`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/specs +$LFS_TGT-gcc -dumpspecs | sed \ + -e 's@/lib\(64\)\?/ld@/tools&@g' \ + -e "/^\*cpp:$/{n;s,$, -isystem /tools/include,}" > $SPECS +echo "New specs file is: $SPECS" +unset SPECS At this point, it is imperative to stop and ensure that the basic @@ -75,7 +46,7 @@ unset GCC_FIXED expected. To perform a sanity check, run the following commands: echo 'main(){}' > dummy.c -cc dummy.c +$LFS_TGT-gcc -B/tools/lib dummy.c readelf -l a.out | grep ': /tools' If everything is working correctly, there should be no errors, @@ -91,17 +62,7 @@ readelf -l a.out | grep ': /tools' If the output is not shown as above or there was no output at all, then something is wrong. Investigate and retrace the steps to find out where the problem is and correct it. This issue must be resolved before - continuing on. First, perform the sanity check again, using - gcc instead of cc. If this works, - then the /tools/bin/cc symlink is - missing. Revisit and install - the symlink. Next, ensure that the PATH is correct. This - can be checked by running echo $PATH and verifying that - /tools/bin is at the head of the - list. If the PATH is wrong it could mean that you are not - logged in as user lfs or that - something went wrong back in Another option is that something may have gone wrong with the + continuing on. Something may have gone wrong with the specs file amendment above. In this case, redo the specs file amendment, being careful to copy-and-paste the commands. @@ -111,9 +72,9 @@ readelf -l a.out | grep ': /tools' - Building Tcl in the next section will serve as an additional check that - the toolchain has been built properly. If Tcl fails to build, it is an - indication that something has gone wrong with the Binutils, GCC, or Glibc - installation, but not with Tcl itself. + Building Binutils in the next section will serve as an additional check that + the toolchain has been built properly. If Binutils fails to build, it is an + indication that something has gone wrong with the previous Binutils, GCC, or Glibc + installations. diff --git a/chapter05/binutils-pass1.xml b/chapter05/binutils-pass1.xml index 6644c2250..2c8a5ab73 100644 --- a/chapter05/binutils-pass1.xml +++ b/chapter05/binutils-pass1.xml @@ -41,7 +41,7 @@ - Installation of Binutils + Installation of Cross Binutils It is important that Binutils be the first package compiled because both Glibc and GCC perform various tests on the available @@ -70,19 +70,20 @@ cd ../binutils-build Now prepare Binutils for compilation: -CC="gcc -B/usr/bin/" ../binutils-&binutils-version;/configure \ - --prefix=/tools --disable-nls --disable-werror +../binutils-&binutils-version;/configure \ + --target=$LFS_TGT --prefix=/tools \ + --disable-nls --disable-werror The meaning of the configure options: - CC="gcc -B/usr/bin/" + --target=$LFS_TGT - This forces gcc to prefer the linker from - the host in /usr/bin. This - is necessary on some hosts where the new ld - built here is not compatible with the host's gcc. + Because the machine description in the LFS_TGT + variable is slightly different than the value returned by the + config.guess script, this switch will tell the configure script to + adjust Binutil's build system for building a cross linker. @@ -124,49 +125,17 @@ cd ../binutils-build tests at this point are minimal since the programs from this first pass will soon be replaced by those from the second. - Create a symlink to ensure the sanity of our toolchain: + If building on x86_64, create a symlink to ensure the sanity of + the toolchain: -mkdir -v /tools/lib -ln -sv lib /tools/lib64 +case $(uname -m) in + x86_64) mkdir -v /tools/lib && ln -sv lib /tools/lib64 ;; +esac Install the package: make install - Finally, prepare the linker for the Adjusting phase - later on: - -make -C ld clean -make -C ld LIB_PATH=/tools/lib -cp -v ld/ld-new /tools/bin - - - The meaning of the make parameters: - - - -C ld clean - - This tells the make program to remove all compiled - files in the ld - subdirectory. - - - - - -C ld LIB_PATH=/tools/lib - - This option rebuilds everything in the ld subdirectory. Specifying the - LIB_PATH Makefile variable on the command line - allows us to override the default value and point it to the - temporary tools location. The value of this variable specifies - the linker's default library search path. This preparation is - used later in the chapter. - - - - - diff --git a/chapter05/binutils-pass2.xml b/chapter05/binutils-pass2.xml index 7cfcb6421..dd7e7d912 100644 --- a/chapter05/binutils-pass2.xml +++ b/chapter05/binutils-pass2.xml @@ -41,7 +41,7 @@ - Re-installation of Binutils + Installation of Binutils Binutils does not recognize versions of Texinfo newer than 4.9. Fix this issue by applying the following patch: @@ -55,12 +55,23 @@ cd ../binutils-build Prepare Binutils for compilation: -../binutils-&binutils-version;/configure --prefix=/tools \ - --disable-nls --with-lib-path=/tools/lib +CC="$LFS_TGT-gcc -B/tools/lib/" \ + AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \ + ../binutils-&binutils-version;/configure --prefix=/tools \ + --disable-nls --with-lib-path=/tools/lib The meaning of the new configure options: + + CC="$LFS_TGT-gcc -B/tools/lib/" AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib + + Because this is really a native build of Binutils, setting these + variables ensures that the build system uses the cross-compiler and + associated tools instead of the ones on the host system. + + + --with-lib-path=/tools/lib @@ -78,13 +89,6 @@ cd ../binutils-build make - Compilation is now complete. As discussed earlier, running the - test suite is not mandatory for the temporary tools here in this - chapter. To run the Binutils test suite anyway, issue the following - command: - -make check - Install the package: make install @@ -96,6 +100,33 @@ cd ../binutils-build make -C ld LIB_PATH=/usr/lib:/lib cp -v ld/ld-new /tools/bin + + The meaning of the make parameters: + + + -C ld clean + + This tells the make program to remove all compiled + files in the ld + subdirectory. + + + + + -C ld LIB_PATH=/usr/lib:/lib + + This option rebuilds everything in the ld subdirectory. Specifying the + LIB_PATH Makefile variable on the command line + allows us to override the default value of the temporary tools + and point it to the proper final path. The value of this variable + specifies the linker's default library search path. This + preparation is used in the next chapter. + + + + + diff --git a/chapter05/chapter05.xml b/chapter05/chapter05.xml index 5d776d032..096717c36 100644 --- a/chapter05/chapter05.xml +++ b/chapter05/chapter05.xml @@ -19,13 +19,11 @@ + + - - - diff --git a/chapter05/gcc-pass1.xml b/chapter05/gcc-pass1.xml index d9c6175ff..02854618d 100644 --- a/chapter05/gcc-pass1.xml +++ b/chapter05/gcc-pass1.xml @@ -41,7 +41,7 @@ - Installation of GCC + Installation of Cross GCC GCC now requires the GMP and MPFR packages. As these packages may not be included in your host distribution, they will be built with @@ -60,35 +60,16 @@ cd ../gcc-build Prepare GCC for compilation: -CC="gcc -B/usr/bin/" ../gcc-&gcc-version;/configure --prefix=/tools \ - --with-local-prefix=/tools --disable-nls --disable-shared --disable-libssp \ - --disable-multilib --enable-languages=c +../gcc-&gcc-version;/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 The meaning of the configure options: - - CC="gcc -B/usr/bin/" - - This forces gcc to prefer the linker from - the host in /usr/bin. This - is necessary on some hosts where the new ld - built in the previous section is not compatible with the host's - gcc. - - - - - --with-local-prefix=/tools - - The purpose of this switch is to remove /usr/local/include from - gcc's include search path. This is not - absolutely essential, however, it helps to minimize the - influence of the host system. - - - --disable-shared @@ -99,37 +80,34 @@ cd ../gcc-build - --disable-libssp + --disable-decimal-float, --disable-threads, --disable-libmudflap, --disable-libssp, --disable-libgomp - This switch prevents a conflict with older versions of - glibc which can cause the build to fail. + These switches disable support for the decimal floating point extension, + threading, libmudflap, libssp and libgomp respectively. These features will fail + to compile when building a cross-compiler and are not necessary for the task of + cross-compiling the temporary libc. - --enable-languages=c + --disable-multilib - This option ensures that only the C compiler is built. - This is the only language needed now. + On x86_64, LFS does not yet support a multilib configuration. + This switch is harmless for x86. - --disable-multilib + --enable-languages=c - We currently only want to build support for 64-bit libraries. + This option ensures that only the C compiler is built. + This is the only language needed now. - The following command will compile GCC not once, but several times. It - uses the programs compiled in a first round to compile itself a second time, - and then again a third time. It then compares these second and third compiles - to make sure it can reproduce itself flawlessly. This is called - bootstrapping. Building GCC in this way ensures that it was - compiled correctly and is now the default configuration for the released - package. Continue with compiling by running: + Compile GCC by running: make @@ -146,23 +124,14 @@ cd ../gcc-build Using --disable-shared means that the libgcc_eh.a file isn't created and installed. The Glibc package depends on this library as it uses - -lgcc_eh within its build system. We can satisfy - that dependency by creating a symlink to libgcc.a, + -lgcc_eh within its build system. This dependency + can be satisfied by creating a symlink to libgcc.a, since that file will end up containing the objects normally contained in libgcc_eh.a. -ln -vs libgcc.a `gcc -print-libgcc-file-name | \ +ln -vs libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | \ sed 's/libgcc/&_eh/'` - As a finishing touch, create a symlink. Many programs and scripts - run cc instead of gcc, which is - used to keep programs generic and therefore usable on all kinds of UNIX - systems where the GNU C compiler is not always installed. Running - cc leaves the system administrator free to decide - which C compiler to install: - -ln -vs gcc /tools/bin/cc - diff --git a/chapter05/gcc-pass2.xml b/chapter05/gcc-pass2.xml index bbdda355f..75bca7092 100644 --- a/chapter05/gcc-pass2.xml +++ b/chapter05/gcc-pass2.xml @@ -41,33 +41,19 @@ - Re-installation of GCC + Installation of GCC - The tools required to test GCC and Binutils—Tcl, Expect - and DejaGNU—are installed now. GCC and Binutils can now be - rebuilt, linking them against the new Glibc and testing them properly - (if running the test suites in this chapter). Please note that these - test suites are highly dependent on properly functioning PTYs which - are provided by the host. PTYs are most commonly implemented via the - devpts file system. Check - to see if the host system is set up correctly in this regard by - performing a quick test: + Versions of GCC later than 4.3 will treat this build as if + it were a relocated compiler and disallow searching for startfiles in + the location specified by --prefix. Since this + will not be a relocated compiler, and the startfiles in + /tools are crucial to building + a working compiler linked to the libs in /tools, + apply the following patch which partially reverts GCC to its old behavior: -expect -c "spawn ls" +patch -Np1 -i ../&gcc-startfiles-patch; - The response might be: - -The system has no more ptys. -Ask your system administrator to create more. - - If the above message is received, the host does not have its PTYs - set up properly. In this case, there is no point in running the test - suites for GCC and Binutils until this issue is resolved. Please consult - the LFS FAQ at for more - information on how to get PTYs working. - - As previously explained in , - under normal circumstances the GCC fixincludes script + Under normal circumstances the GCC fixincludes script is run in order to fix potentially broken header files. As GCC-&gcc-version; and Glibc-&glibc-version; have already been installed at this point, and their respective header files are known to not require fixing, the @@ -80,18 +66,17 @@ Ask your system administrator to create more. cp -v gcc/Makefile.in{,.orig} sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in - The bootstrap build performed in - built GCC with the compiler flag. - Non-bootstrap builds omit this flag by default, so apply the following - sed to use it in order to ensure consistent compiler - builds: + Non-bootstrap builds omit the + build flag by default, and the goal should be to produce a compiler that is + exactly the same as if it were bootstrapped. Apply the following + sed command to force the build to use the flag: cp -v gcc/Makefile.in{,.tmp} sed 's/^XCFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in.tmp \ > gcc/Makefile.in The following command will change the location of GCC's default - dynamic linker to use the one we installed in + dynamic linker to use the one installed in /tools. It also removes /usr/include from GCC's include search path. Doing this now rather than adjusting the specs file after installation @@ -105,9 +90,11 @@ do cp -uv $file{,.orig} sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \ -e 's@/usr@/tools@g' $file.orig > $file - echo " + echo ' #undef STANDARD_INCLUDE_DIR -#define STANDARD_INCLUDE_DIR 0" >> $file +#define STANDARD_INCLUDE_DIR 0 +#define STANDARD_STARTFILE_PREFIX_1 "" +#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file touch $file.orig done @@ -120,19 +107,24 @@ done /tools to every instance of /lib/ld, /lib64/ld or /lib32/ld, while the second one replaces hard-coded instances of /usr. Then we add our define - statements which alter the include search path to the end of the file. Finally, - we use touch to update the timestamp on the copied files. + statements which alter the include search path and the default startfile prefix + to the end of the file. + Finally, we use touch to update the timestamp on the copied files. When used in conjunction with cp -u, this prevents unexpected changes to the original files in case the command is inadvertently run twice. - Unsetting the multlib spec for GCC ensures that it + On x86_64, unsetting the multlib spec for GCC ensures that it won't attempt to link against libraries on the host: -for file in $(find gcc/config -name t-linux64) ; do \ - cp -v $file{,.orig} - sed '/MULTILIB_OSDIRNAMES/d' $file.orig > $file -done +case $(uname -m) in + x86_64) + for file in $(find gcc/config -name t-linux64) ; do \ + cp -v $file{,.orig} + sed '/MULTILIB_OSDIRNAMES/d' $file.orig > $file + done + ;; +esac As in the first build of GCC it requires the GMP and MPFR packages. Unpack the tarballs and move them into the required directory names: @@ -152,7 +144,9 @@ cd ../gcc-build Now prepare GCC for compilation: -../gcc-&gcc-version;/configure --prefix=/tools \ +CC="$LFS_TGT-gcc -B/tools/lib/" \ + AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \ + ../gcc-&gcc-version;/configure --prefix=/tools \ --with-local-prefix=/tools --enable-clocale=gnu \ --enable-shared --enable-threads=posix \ --enable-__cxa_atexit --enable-languages=c,c++ \ @@ -227,27 +221,58 @@ cd ../gcc-build make - Compilation is now complete. As previously mentioned, running the test - suites for the temporary tools compiled in this chapter is not mandatory. - To run the GCC test suite anyway, use the following command: - -make -k check - - The -k flag is used to make the test suite run - through to completion and not stop at the first failure. The GCC test - suite is very comprehensive and is almost guaranteed to generate a few - failures. - - For a discussion of test failures that are of particular - importance, please see - Install the package: make install - + As a finishing touch, create a symlink. Many programs and scripts + run cc instead of gcc, which is + used to keep programs generic and therefore usable on all kinds of UNIX + systems where the GNU C compiler is not always installed. Running + cc leaves the system administrator free to decide + which C compiler to install: + +ln -vs gcc /tools/bin/cc + + + At this point, it is imperative to stop and ensure that the basic + functions (compiling and linking) of the new toolchain are working as + expected. To perform a sanity check, run the following commands: + +echo 'main(){}' > dummy.c +cc dummy.c +readelf -l a.out | grep ': /tools' + + If everything is working correctly, there should be no errors, + and the output of the last command will be of the form: + +[Requesting program interpreter: + /tools/lib/ld-linux.so.2] + + Note that /tools/lib, or + /tools/lib64 for 64-bit machines + appears as the prefix of the dynamic linker. + + If the output is not shown as above or there was no output at all, + then something is wrong. Investigate and retrace the steps to find out + where the problem is and correct it. This issue must be resolved before + continuing on. First, perform the sanity check again, using + gcc instead of cc. If this works, + then the /tools/bin/cc symlink is + missing. Install the symlink as per above. + Next, ensure that the PATH is correct. This + can be checked by running echo $PATH and verifying that + /tools/bin is at the head of the + list. If the PATH is wrong it could mean that you are not + logged in as user lfs or that + something went wrong back in + + Once all is well, clean up the test files: + +rm -v dummy.c a.out + + diff --git a/chapter05/glibc.xml b/chapter05/glibc.xml index 3252c5a10..f8063f204 100644 --- a/chapter05/glibc.xml +++ b/chapter05/glibc.xml @@ -43,11 +43,6 @@ Installation of Glibc - Fix a potential issue if /etc/ld.so.preload is - used on the host system. - -sed -i 's@/etc/ld.so.preload@/tools/etc/ld.so.preload@' elf/rtld.c - The Glibc documentation recommends building Glibc outside of the source directory in a dedicated build directory: @@ -71,14 +66,23 @@ esac Next, prepare Glibc for compilation: ../glibc-&glibc-version;/configure --prefix=/tools \ + --host=$LFS_TGT --build=$(../glibc-&glibc-version;/scripts/config.guess) \ --disable-profile --enable-add-ons \ - --enable-kernel=2.6.0 --with-binutils=/tools/bin \ - --without-gd --with-headers=/tools/include \ - --without-selinux + --enable-kernel=2.6.0 --with-headers=/tools/include \ + libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes The meaning of the configure options: + + --host=$LFS_TGT, --build=$(../glibc-&glibc-version;/scripts/config.guess) + + The combined effect of these switches is that Glibc's build system + configures itself to cross-compile, using the cross-linker and + cross-compiler in /tools. + + + --disable-profile @@ -103,24 +107,6 @@ esac - - --with-binutils=/tools/bin - - While not required, this switch ensures that there are - no errors pertaining to which Binutils programs get used during the - Glibc build. - - - - - --without-gd - - This prevents the build of the memusagestat - program, which insists on linking against the host's libraries - (libgd, libpng, libz, etc.). - - - --with-headers=/tools/include @@ -131,12 +117,19 @@ esac - --without-selinux + libc_cv_forced_unwind=yes - When building from hosts that include SELinux functionality - (e.g., Fedora Core 3), Glibc will build with support for SELinux. - As the LFS tools environment does not contain support for SELinux, a - Glibc compiled with such support will fail to operate correctly. + The build requires support for forced unwind, but because it is + being cross compiled, it cannot auto detect it. Setting this variable + on the command line explicitly tells the configure script that support + is available. + + + + libc_cv_c_cleanup=yes + + The build also requires support for C cleanup handling, which it + cannot auto detect when being cross compiled. Enable it explicitly. @@ -167,13 +160,6 @@ esac This package does come with a test suite, however, it cannot be run at this time because we do not have a C++ compiler yet. - The install stage of Glibc will issue a harmless warning at the - end about the absence of /tools/etc/ld.so.conf. - Prevent this warning with: - -mkdir -v /tools/etc -touch /tools/etc/ld.so.conf - Install the package: make install diff --git a/chapter05/toolchaintechnotes.xml b/chapter05/toolchaintechnotes.xml index f6adefb61..60e1f10ff 100644 --- a/chapter05/toolchaintechnotes.xml +++ b/chapter05/toolchaintechnotes.xml @@ -14,7 +14,7 @@ behind the overall build method. It is not essential to immediately understand everything in this section. Most of this information will be clearer after performing an actual build. This section can be referred - back to at any time during the process. + to at any time during the process. The overall goal of is to provide a temporary environment that can be chrooted into and from which can be @@ -54,13 +54,17 @@ - The process is similar in principle to cross-compiling, whereby - tools installed in the same prefix work in cooperation, and thus utilize - a little GNU magic + Slightly adjusting the name of the working platform ensures that + the first build of Binutils and GCC produces a compatible cross-linker + and cross-compiler. Instead of producing binaries for another architecture, + the cross-linker and cross-compiler will produce binaries compatible with + the current hardware. - Careful manipulation of the standard linker's library search path - ensures programs are linked only against chosen libraries + The temporary libraries are cross-compiled. This removes all + dependency on the host system, lessens the chance of headers or libraries + from the host corrupting the new tools and allows for the possibility of + building both 32-bit and 64-bit libraries on 64-bit capable hardware. Careful manipulation of gcc's diff --git a/chapter06/chapter06.xml b/chapter06/chapter06.xml index 9266c3fc0..52e6fe6b7 100644 --- a/chapter06/chapter06.xml +++ b/chapter06/chapter06.xml @@ -48,7 +48,6 @@ - diff --git a/chapter06/creatingdirs.xml b/chapter06/creatingdirs.xml index 382b1e504..edd659738 100644 --- a/chapter06/creatingdirs.xml +++ b/chapter06/creatingdirs.xml @@ -24,8 +24,9 @@ mkdir -pv /usr/{,local/}share/man/man{1..8} for dir in /usr /usr/local; do ln -sv share/{man,doc,info} $dir done -ln -sv lib /lib64 -ln -sv lib /usr/lib64 +case $(uname -m) in + x86_64) ln -sv lib /lib64 && ln -sv lib /usr/lib64 ;; +esac mkdir -v /var/{lock,log,mail,run,spool} mkdir -pv /var/{opt,cache,lib/{misc,locate},local} diff --git a/chapter06/readjusting.xml b/chapter06/readjusting.xml index 8bda83151..695a6d684 100644 --- a/chapter06/readjusting.xml +++ b/chapter06/readjusting.xml @@ -33,9 +33,10 @@ mv -v /tools/bin/{ld-new,ld} ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld Next, amend the GCC specs file so that it points to the new - dynamic linker, and so that GCC knows where to find the correct headers - and Glibc start files. A sed command accomplishes - this: + 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. + A sed command accomplishes this: gcc -dumpspecs | sed -e 's@/tools@@g' \ -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \ diff --git a/chapter08/grub.xml b/chapter08/grub.xml index 913ed5f0c..b77d3e285 100644 --- a/chapter08/grub.xml +++ b/chapter08/grub.xml @@ -5,89 +5,172 @@ %general-entities; ]> - + - Making the LFS System Bootable + + grub + &grub-version; +
&grub-url;
+
+ + GRUB-&grub-version; GRUB - configuring - Your shiny new LFS system is almost complete. One of the last - things to do is to ensure that the system can be properly booted. The - instructions below apply only to computers of IA-32 architecture, - meaning mainstream PCs. Information on boot loading for - other architectures should be available in the usual resource-specific - locations for those architectures. - - Boot loading can be a complex area, so a few cautionary - words are in order. Be familiar with the current boot loader and any other - operating systems present on the hard drive(s) that need to be - bootable. Make sure that an emergency boot disk is ready to - rescue the computer if the computer becomes - unusable (un-bootable). - - Earlier, we compiled and installed the GRUB boot loader software - in preparation for this step. The procedure involves writing some - special GRUB files to specific locations on the hard drive. We highly - recommend creating a GRUB boot floppy diskette as a backup. Insert a - blank floppy diskette and run the following commands: + + + + <para>The GRUB package contains the GRand Unified Bootloader.</para> + + <segmentedlist> + <segtitle>&buildtime;</segtitle> + <segtitle>&diskspace;</segtitle> + + <seglistitem> + <seg>&grub-ch6-sbu;</seg> + <seg>&grub-ch6-du;</seg> + </seglistitem> + </segmentedlist> + + </sect2> + + <sect2 role="installation"> + <title>Installation of GRUB + + + This package will only build for x86 and x86_64 architectures + containing 32-bit libs. If you chose to build on x86_64 without 32-bit + libriaries (no multilib), then you must use LILO instead. + + + This package is known to have issues when its default + optimization flags (including the -march and + -mcpu options) are changed. If any environment + variables that override default optimizations have been defined, such + as CFLAGS and CXXFLAGS, + unset them when building GRUB. + + Start by applying the following patch to allow for better drive + detection, fix some GCC 4.x issues, and provide better SATA support + for some disk controllers: + +patch -Np1 -i ../&grub-geometry-patch; + + By default, GRUB doesn't support ext2 filesystems with 256-byte inodes. + Fix this by applying the following patch: + +patch -Np1 -i ../&grub-inode-patch; + + Prepare GRUB for compilation: + +./configure --prefix=/usr + + Compile the package: + +make + + To test the results, issue: + +make check + + Install the package: + +make install +mkdir -v /boot/grub +cp -v /usr/lib/grub/i386-pc/stage{1,2} /boot/grub + + Replace i386-pc with whatever + directory is appropriate for the hardware in use. + + The i386-pc directory + contains a number of *stage1_5 files, different + ones for different file systems. Review the files available and copy + the appropriate ones to the /boot/grub directory. Most users will + copy the e2fs_stage1_5 and/or + reiserfs_stage1_5 files. + + + + + Configuring GRUB + + Your shiny new LFS system is almost complete. One of the last + things to do is to ensure that the system can be properly booted. The + instructions below apply only to computers of IA-32 architecture, + meaning mainstream PCs. Information on boot loading for + other architectures should be available in the usual resource-specific + locations for those architectures. + + Boot loading can be a complex area, so a few cautionary + words are in order. Be familiar with the current boot loader and any other + operating systems present on the hard drive(s) that need to be + bootable. Make sure that an emergency boot disk is ready to + rescue the computer if the computer becomes + unusable (un-bootable). + + Earlier, we compiled and installed the GRUB boot loader software + in preparation for this step. The procedure involves writing some + special GRUB files to specific locations on the hard drive. We highly + recommend creating a GRUB boot floppy diskette as a backup. Insert a + blank floppy diskette and run the following commands: dd if=/boot/grub/stage1 of=/dev/fd0 bs=512 count=1 dd if=/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1 - Remove the diskette and store it somewhere safe. Now, run the - grub shell: + Remove the diskette and store it somewhere safe. Now, run the + grub shell: grub - GRUB uses its own naming structure for drives and partitions in - the form of (hdn,m), where n - is the hard drive number and m is the partition - number, both starting from zero. For example, partition hda1 is (hd0,0) to - GRUB and hdb3 is - (hd1,2). In contrast to Linux, GRUB does not - consider CD-ROM drives to be hard drives. For example, if using a CD - on hdb and a second hard drive - on hdc, that second hard drive - would still be (hd1). - - Using the above information, determine the appropriate - designator for the root partition (or boot partition, if a separate - one is used). For the following example, it is assumed that the root - (or separate boot) partition is hda4. - - Tell GRUB where to search for its - stage{1,2} files. The Tab key can be used - everywhere to make GRUB show the alternatives: + GRUB uses its own naming structure for drives and partitions in + the form of (hdn,m), where n + is the hard drive number and m is the partition + number, both starting from zero. For example, partition hda1 is (hd0,0) to + GRUB and hdb3 is + (hd1,2). In contrast to Linux, GRUB does not + consider CD-ROM drives to be hard drives. For example, if using a CD + on hdb and a second hard drive + on hdc, that second hard drive + would still be (hd1). + + Using the above information, determine the appropriate + designator for the root partition (or boot partition, if a separate + one is used). For the following example, it is assumed that the root + (or separate boot) partition is hda4. + + Tell GRUB where to search for its + stage{1,2} files. The Tab key can be used + everywhere to make GRUB show the alternatives: root (hd0,3) - - The following command will overwrite the current boot loader. Do not - run the command if this is not desired, for example, if using a third party - boot manager to manage the Master Boot Record (MBR). In this scenario, it - would make more sense to install GRUB into the boot sector - of the LFS partition. In this case, this next command would become - setup (hd0,3). - + + The following command will overwrite the current boot loader. Do not + run the command if this is not desired, for example, if using a third party + boot manager to manage the Master Boot Record (MBR). In this scenario, it + would make more sense to install GRUB into the boot sector + of the LFS partition. In this case, this next command would become + setup (hd0,3). + - Tell GRUB to install itself into the MBR of - hda: + Tell GRUB to install itself into the MBR of + hda: setup (hd0) - If all went well, GRUB will have reported finding its files in - /boot/grub. That's all there is - to it. Quit the grub shell: + If all went well, GRUB will have reported finding its files in + /boot/grub. That's all there is + to it. Quit the grub shell: quit - Create a menu list file defining GRUB's boot menu: + Create a menu list file defining GRUB's boot menu: cat > /boot/grub/menu.lst << "EOF" # Begin /boot/grub/menu.lst @@ -107,8 +190,8 @@ root (hd0,3) kernel /boot/lfskernel-&linux-version; root=/dev/hda4 EOF - Add an entry for the host distribution if desired. It might look - like this: + Add an entry for the host distribution if desired. It might look + like this: cat >> /boot/grub/menu.lst << "EOF" title Red Hat @@ -117,8 +200,8 @@ kernel /boot/kernel-2.6.5 root=/dev/hda3 initrd /boot/initrd-2.6.5 EOF - If dual-booting Windows, the following entry will allow - booting it: + If dual-booting Windows, the following entry will allow + booting it: cat >> /boot/grub/menu.lst << "EOF" title Windows @@ -126,15 +209,99 @@ rootnoverify (hd0,0) chainloader +1 EOF - If info grub does not provide all necessary material, - additional information regarding GRUB is located on its website at: - . + If info grub does not provide all necessary material, + additional information regarding GRUB is located on its website at: + . - The FHS stipulates that GRUB's menu.lst file should - be symlinked to /etc/grub/menu.lst. To - satisfy this requirement, issue the following command: + The FHS stipulates that GRUB's menu.lst file should + be symlinked to /etc/grub/menu.lst. To + satisfy this requirement, issue the following command: mkdir -v /etc/grub ln -sv /boot/grub/menu.lst /etc/grub + + + + Contents of GRUB + + + Installed programs + + + grub, grub-install, grub-md5-crypt, grub-set-default, + grub-terminfo, and mbchk + + + + + Short Descriptions + + + + + grub + + The Grand Unified Bootloader's command shell + + grub + + + + + + grub-install + + Installs GRUB on the given device + + grub-install + + + + + + grub-md5-crypt + + Encrypts a password in MD5 format + + grub-md5-crypt + + + + + + grub-set-default + + Sets the default boot entry for GRUB + + grub-set-default + + + + + + grub-terminfo + + Generates a terminfo command from a terminfo name; it can be + employed if an unknown terminal is being used + + grub-terminfo + + + + + + mbchk + + Checks the format of a multi-boot kernel + + mbchk + + + + + + + +
diff --git a/general.ent b/general.ent index 9df811ed8..f20e9ddf4 100644 --- a/general.ent +++ b/general.ent @@ -1,6 +1,6 @@ - - + + diff --git a/patches.ent b/patches.ent index 1956c1df0..352d60e7a 100644 --- a/patches.ent +++ b/patches.ent @@ -57,6 +57,9 @@ + + + -- cgit v1.2.3-54-g00ecf