[ Pobierz całość w formacie PDF ]
.This means the $LFS/proc/devices file won't be updated when the kernel updates /proc/devicesbut I don't see any harm in doing it, since it's only needed during the execution of the MAKEDEV script.Justmake sure you don't add or remove any hardware during the next 3 minutes by loading or unloading a kernelmodule or rebooting your computer before continuing with this book.Copy the /proc/devices file by running the following command:root:~# cp /proc/devices $LFS/procCopying /proc/devices 82Chapter 6.Installing basic system softwareChapter 6.Installing basic system software 83IntroductionThe installation of all the software is pretty straightforward and you'll think it's so much easier and shorter togive the generic installation instructions for each package and only explain how to install something if acertain package requires an alternate installation method.Although I agree with you on that, I, however,choose to give the full instructions for each and every package.This is simply to avoid any possibleconfusion and errors.Introduction 84Debugging symbols and compiler optimizationsMost programs and libraries by default are compiled with debugging symbols and optimizing level 2 (gccoptions -g and -O2) and are compiled for a specific CPU.On Intel platforms software is compiled for i386processors by default.If you don't wish to run software on other machines other than your own, you mightwant to change the default compiler options so that they will be compiled with a higher optimization level, nodebugging symbols and generate code for your specific architecture.Let me first explain what debuggingsymbols are.A program compiled with debugging symbols means you can run a program or library through a debuggerand the debugger's output will be user friendlier.These debugging symbols also enlarge the program orlibrary significantly.To remove debugging symbols from a binary (must be an a.out or ELF binary) run strip--strip-debug filename You can use wild cards if you need to strip debugging symbols frommultiple files (use something like strip --strip-debug $LFS/usr/bin/*).Another, easier, options is just not tocompile programs with debugging symbols.Most people will probably never use a debugger on software, soby leaving those symbols out you can save a lot of diskspace.Before you wonder if these debugging symbols would make a big difference, here are some statistics:"A dynamic Bash binary with debugging symbols: 1.2MB"A dynamic Bash binary without debugging symbols: 478KB"/lib and /usr/lib (glibc and gcc files) with debugging symbols: 87MB"/lib and /usr/lib (glibc and gcc files) without debugging symbols: 16MBSizes may vary depending on which compiler was used and which C library version was used to link dynamicprograms against, but your results will be similar if you compare programs with and without debuggingsymbols.After I was done with this chapter and stripped all debugging symbols from all LFS binaries andlibraries I regained a little over 102 MB of disk space.Quite the difference.There are a few ways to change the default compiler options.One way is to edit every Makefile file you canfind in a package, look for the CFLAGS and CXXFLAGS variables (a well designed package uses theCFLAGS variable to define gcc compiler options and CXXFLAGS to define g++ compiler options) andchange their values.Packages like binutils, gcc, glibc and others have a lot of Makefile files in a lot ofsubdirectories so this would take a lot of time to do.Instead there's an easier way to do things: create theCFLAGS and CXXFLAGS environment variables.Most configure scripts read the CFLAGS andCXXFLAGS variables and use them in the Makefile files.A few packages don't follow this convention andthose package require manual editing.In the next section we'll create the $LFS/root/.bash_profile that will contain the following optimization:CFLAGS="-O3 -mcpu=xxx -march=xxx"CXXFLAGS=$CFLAGSDebugging symbols and compiler optimizations 85Linux From ScratchThis is a minimal set of optimizations that ensures it works on almost all platforms.These two options (mcpuand march) will compile the binaries with specific instructions for that CPU you have specified.This meansyou can't copy this binary to a lower class CPU and execute it.It will either work very unreliable or not at all(it will give errors like Illegal Instruction, core dumped).You'll have to read the GCC Info page to find morepossible optimization flags.In the above environment variable you have to replace xxx and yyy with theappropriate CPU identifiers such as i586, i686, powerpc and others.Please keep in mind that if you find that a package doesn't compile and gives errors like "segmentation fault,core dumped" it's most likely got to do with these compiler optimizations.Try lowering the optimizing levelby changing -O3 to -O2.If that doesn't work try -O or leave it out all together.Also try changing the -mcpuand -march variables
[ Pobierz całość w formacie PDF ]