ºìÁªLinuxÃÅ»§
Linux°ïÖú

LFS (°æ±¾6.1.1) °²×°ÐĵÃ

·¢²¼Ê±¼ä:2006-10-18 09:54:39À´Ô´:ºìÁª×÷Õß:supop
---Ç°Ðò:

ºÃ¶àÄêÇ°,°²×°¹ýÔçÆÚµÄSlackware.

Á½ÈýÄêÇ°°²×°¹ýRedHat9.

»ù±¾ÉϾÍÊÇ°²×°ºÃºó, ½ø×ÀÃæϵͳ´òÒ»ÏÂСÓÎÏ·,È»ºó¾Íɾ³ýµô.ÒòΪÎÒµÄÓ²ÅÌÒ»Ö±ºÜС,20G.

µ±È»Ò»¸öºÜÖ÷ÒªµÄÔ­ÒòÊÇÎÒ²»Ï²»¶ÕâЩ·¢ÐаæÖÐÒ»´ó¶ÑµÄ¶«Î÷,Ì«ÂÒ,¿´²»Ã÷°×Ôõô×éÖ¯µÄ.

Ç°¼¸Ìì»»ÁË40GÓ²ÅÌ,ÓÚÊÇ»®·ÖÁË8G°²×°ÁËDebian.×°ºÃÁ˺óÒ»¿´Ò²ÊÇÒ»´ó¶ÑµÄÈí¼þ,¸÷ʽ¸÷Ñù.ÕýҪ׼±¸É¾³ý.

²»ÖªµÀÔÚÄÄÀï¿´µ½ÁËLFSÒ»ÏÂ,¶Ùʱ±»ÎüÒýÁË,ÓÚÊǼƻ®°²×°Ò»¸öLFS.¶øDebianÕýºÃ×÷Ϊhost system.

ÏÂÃæÊÇÎҵݲװÐĵÃ,»¨ÁËÖÜ5,ÖÜ6Á½¸öͨÏü. (glibc, gcc, firefox, XorgºÄʱºÜ¶à,ÔڱʼDZ¾ÉÏ°²×°.)

дµã×Ô¼ºµÄÌå»á,Ö÷ÒªÊÇÕûÀí×Ô¼º¶ÔLFS°²×°¹ý³ÌµÄÀí½â, ÌرðÊÇldºÍgccµÄ¶à´Î±àÒë.


----Ä¿±ê:

ΪÁË´´½¨Ò»¸ö¸É¾»µÄLFSϵͳ.


----ʵÏֵĴó²½Öè:

1. ¾¡¿ÉÄܵİÚÍÑhost systemµÄÓ°Ïì, Ê×ÏÈ´´½¨Ò»¸ö×î»ù±¾µÄ×ÔÖεÄToolchain.

Õâ¸öToolchainÖÐ×î»ù±¾µÄÐèÒªÊÇ: binutils(×î»ù±¾µÄbinary¹¤¾ß), gcc(±àÒëÆ÷), glibc(º¯Êý¿â)

ÒòΪÆäËüµÄtools¾Í¿ÉÒÔÓÉÕâÈý¸ö´´½¨³öÀ´ÁË.

2. µ±ËùÓеĻù±¾Toolchain¹¤¾ß×¼±¸ºÃÁË,¾Í¿ÉÒÔchroot.

3. ÔÚChrootºóµÄÐéÄâ¸ù/»·¾³ÏÂ, ÓÃtoolchainÖеŤ¾ßÉú³É³ö×îºóµÄLFSϵͳ.


---Ò»¸ö˵Ã÷:

ΪʲôҪ´´½¨/toolsÕâ¸ölink

³õʼµÄToolchain¹¤¾ß´´½¨ÔÚ/mnt/lfs/toolsĿ¼ÏÂ.

ͬʱΪÁ˽«À´chrootºó, ¹¤¾ßÖеÄInterpreterÐÅÏ¢ÈÔȻָÏòÕýÈ·,ʹÓÃÁËÒ»¸öС¼¼ÇÉ.

ÔÚhost systemÖеÄ/Ŀ¼Ï´´½¨Ò»¸öÃûΪtoolsµÄlink, Ö¸Ïò/tools --> /mnt/lfs/tools

Õâ¸ö×÷Óôò¸ö±È·½À´Ëµ¾ÍÊÇ,µ±ÎÒÃÇÔÚʹÓÃhost systemµÄʱºò,ÎÒÃÇ¿ÉÒÔʹÓÃ/tools/bin/ldÕÒµ½ld³ÌÐò,

½«À´chrootºó,/tools/bin/ld»¹ÊÇÄÜÕÒµ½Õâ¸öld.

·ñÔòÎÒÃÇÔÚʹÓÃhost systemµÄʱºò,ʹÓÃ/mnt/lfs/tools/bin/ldÀ´ÕÒµ½ld,

»»¾ä»°ËµÉú³ÉµÄ³ÌÐò°üº¬/mnt/lfsÕâÑùµÄÐÅÏ¢,½«À´chrootÖ®ºó,¿É¾Í²»Ì«ºÃÁË.


----·ûºÅ˵Ã÷:

(ΪÁËÐÐÎÄ·½±ã)

bin-0 -----> host systemµÄbinutils

ld-0 -----> host system µÄld

bin-1 -----> µÚÒ»±é±àÒë³öµÄbinutils

ld-1 -----> bin-1ÖеÄld

ld-a -----> µÚÒ»´Îµ÷ÕýºóµÄld

bin-2 -----> µÚ¶þ±é±àÒëµÄbinutils

ld-2 -----> bin-2ÖеÄld

ld-b -----> µÚ¶þ´Îµ÷ÕýºóµÄld

bin-3 -----> µÚÈý±é±àÒëÉú³ÉµÄbinutils

ld-3 -----> bin-3ÖеÄld

gcc-0, gcc-1, gcc-2, gcc-3·Ö±ð±íʾhost systemÖеÄgcc, ºÍToolchainÖеÄÁ½±égccºÍ×îºóLFSϵͳµÄgcc.
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 2 ÌõÆÀÂÛ

  1. supop ÓÚ 2006-10-18 09:56:06·¢±í:

    ** µÚ¶þ´Îµ÷Õý:

    ÓÐÁËglibc-2ºó,ÎÒÃǾͽ«¿ªÊ¼µÚ¶þ´Î,Ò²ÊÇ×îºóÒ»´ÎToolchainµ÷Õý.

    ºÍµÚÒ»´Îµ÷ÕýÀàËÆ, ×î¹Ø¼üµÄÊÇÒªµ÷ÕýldºÍgcc.

    ld-2µ÷Õý³Éld-b:

    make -C ld clean

    make -C ld LIB_PATH=/usr/lib:/lib (¸æËßldÒÔºó´ÓÕâÁ½¸öĿ¼ȥÕÒlib)

    make -C ld INSTALL=/tools/bin/install install

    gcc-2µ÷Õý³Égcc-b:

    ÐÞ¸Ägcc specÎļþ's@ /tools/lib/ld-linux.so.2@ /lib/ld-linux.so.2@g;

    ÕýºÃºÍµÚÒ»´Îµ÷ÕýÏà·´.

    ** bin-3ºÍgc-3±àÒë:

    ÓÐÁ˵÷ÕýºóµÄld-b, gcc-b,¾Í¿ÉÒÔ¿ªÊ¼×îÖÕϵͳµÄ±àÒëÁË.

    Ê×ÏÈÊÇbin-3. (ʹÓõÄÊÇ: ld-b, gcc-bºÍglibc-2)

    È»ºóÊÇgcc-3. (ʹÓõÄÊÇ: ld-3, gcc-bºÍglibc-2)

    ** ϵͳµÄÆäËüËùÐèÈí¼þ:

    ÔÙºóÃæÆäËüµÄϵͳÈí¼þ¾Í¶¼½«ÓÉbin-2, gcc-3, glibc-2Éú³É³öÀ´ÁË.

    ×ßµ½ÕâÀï,ÅäÖúÃϵͳScriptsºÍKernel,ÒÔ¼°grub.

    Reboot!

    !!!»¶Ó­½øÈëLFS!!!


    ----ºó¼ÇBLFS:

    ºÜ¿ªÐÄ, ²Î¿¼LFS Book (v6.1.1)ºÜ˳ÀûµØ°²×°ºÃÁËLFSϵͳ.

    LFS×î¿áµÄµØ·½,Ò²ÊÇ×îÎüÒýÎҵĵط½¾ÍÊÇÈÃÎÒÖªµÀϵͳÿ¸öÈí¼þ¶¼ÓÐÄÇЩ¹¦ÄܺÍÄÄЩÎļþ.

    ¿ÉÒÔ×ÔÖ÷Ñ¡ÔñÐèÒª°²×°µÄÈí¼þ.

    °²×°ºÃLFSÖ®ºó, Á¢¿Ì¾Íɾ³ýÁ˵Ähost system --> debian. :-), ÌÚ³ö¿Õ¼ä±ãÓÚ°²×°Xϵͳ.

    -gmp,±ãÓÚ¿½±´Õ³Ìù.

    -lynx,¿ÉÒÔÒ»±ßÏÂÔØÈí¼þ°üºÍÒ»±ßä¯ÀÀBLFS Book.

    -wget, ÓÐЩÇé¿öËü±ÈlynxÏÂÔØ¿ì¶àÁË.

    Ñ¡ÔñÁËXorg.

    (ºÜÆæ¹ÖËüûÓа²×°µ½/usr/X11R6ÏÂÃæ,ºÍÊéÉϲ»Ò»ÖÂ,µ«ÊÇʹÓúÃÏñûÓÐÎÊÌâ,ûÓÐÉîÈë¼ì²é.)

    Xorg×Ô´øÁËtvm,µ«ÊµÔÚÌ«³ó.

    ÔĶÁÁËÒ»ÏÂBLFS,ȨºâºóÑ¡ÔñÁËXfce.ÎÒ¾õµÃXfceÒѾ­ºÜƯÁÁ,¶øÇÒ¾«º·.

    ×îºó°²×°µÄÈý¸öÈí¼þ·Ö±ðÊÇ:

    gdb, gvim, firefox.

  2. supop ÓÚ 2006-10-18 09:55:23·¢±í:

    ----²½Öè·ÖÎö:

    ºÃ,ÏÖÔÚÈÃÎÒÃÇ´ÓÍ·¿ªÊ¼¿´LFSÊÇÈçºÎÉú³ÉµÄ.

    ** bin-1ºÍgcc-1µÄ±àÒë:

    µÚÒ»²½,ÎÒÃÇÓÃhost systemÖбàÒë³öbin-1ʱºò,

    ʹÓõÄÊÇhost systemµÄbinutils(ld), gcc-0ºÍglibcº¯Êý¿â.

    (a) Éú³ÉµÄProgramÎ޿ɱÜÃâµÄÊܵ½host systemµÄÓ°Ïì, ÀýÈç:

    ʹÓÃÉú³ÉµÄld-1³ÌÐò½«»álinkĬÈÏ/libϵÄlibarary.

    µÚ¶þ²½,ÎÒÃÇÒ²Ðí¿ÉÒÔÓÃhost systemÖ±½ÓÀ´±àÒëglibc,µ«ÊÇÎÒÃǸüÏ£ÍûʹÓÃ×Ô¼ºµÄgccÀ´±àÒëglibc,

    ËùÒÔÎÒÃÇÏÈÓÃhost systemÀ´±àÒë³ögcc-1.

    ×¢Òâ:±àÒëgcc-1ʹÓõÄÊÇbin-1/ld-1, gcc-0, glibc-0.Éú³ÉµÄgcc-1ÈÔÈ»Êܵ½host systemµÄÓ°Ïì.

    gcc-1»áʹÓÃ/libĿ¼ÏµÄdynamic linker (ld-linux.so.2), ¶ø²»ÊÇ/tools/lib/ld-linux.so.2.

    ÓÐÁËbin-1, gcc-1, ÎÒÃǾͿÉÒÔÁ¢¿ÌʹÓÃÐÂÉú³ÉµÄbintuilsºÍgccÀ´±àÒëglibcÁË.

    ҪעÒâ./configureµÄ²ÎÊý,Ëü±íÃ÷ÁËglibcµÄ±àÒ빤¾ß¶¼ÊÇÓõÄ/tools/binϵÄld, gccÁË,

    ¶ø²»ÔÚÊÇhost systemÖеÄld, gcc.ËäÈ»Õâ¸öÑ¡Ïî²¢²»ÖØÒª.

    ** µÚÒ»´Î½øÐÐToolchainµ÷Õý

    µ±glibc-1±àÒëÍê³É,ÊÇʱºòÐÞ¸Ä(a)ÖÐÌáµ½µÄÎÊÌâÁË.

    Õâ´Îµ÷ÕýµÄÄ¿±ê¾ÍÊÇÒªÈÃÔÚÒÔºóµÄ±àÒë¹ý³ÌÖÐ,ÒªÇóldºÍgcc¶¼Ö»Ê¹ÓÃ/tools/libϵĺ¯Êý¿â,Ò²¾ÍÊǸոձàÒëºÃµÄglibc.

    µ÷ÕûµÄ°ì·¨ÊÇ:

    1.)¶ÔÓÚld,

    make -C ld clean (ÏÈÇå¿Õld)

    make -C ld LIB_PATH=/tools/lib (ÖØбàÒëld, ¸æËßldÒÔºóÒªlink /tools/libϵĺ¯ÊÚ¿â)

    (ÕâÁ½²½Ð´ÔÚÁËBinutils-2.15.94.0.2.2 - Pass 1ÕâÒ»½Ú,

    ÎÒÈÏΪ²»ºÃ,Ó¦¸Ã·Åµ½µÚÒ»´ÎToolchainµ÷ÕýÖÐ,¸ü¼ÓÁ¬¹á.)

    make -C ld install (ÖØÐÂinstallµ½/tools/bin)

    Õâ¾ÍÉú³ÉÁËld-a (Çë×¢Òâ,ld³ÌÐòʵ¼ÊÉÏÔÚÕû¸ö´´½¨LFS¹ý³ÌÖбàÒëÁË5´Î!!!)

    2.)¶ÔÓÚgcc,

    ÐÞ¸ÄÄ¿µÄ:¸æËßgccҪʹÓÃ/tools/libϵÄdynamic linker.

    ÐÞ¸ÄgccµÄSPECÎļþ,°Ñ¶¨Òådynamic linkerµÄµØ·½Ð޸ijÉ/tools/lib/ld-linux.so.2

    (½¨ÒéÓÃvi×Ô¼º¸Ä,¸üÓаÑÎÕ,ÎÒµÚÒ»´Î¿½±´sedÃüÁîºÃÏñ³ö´íÁË,ûÓÐÖØÊÔ).

    ×öÍêºó,Îñ±ØÒª×ö²âÊÔ, Ò»¶¨±£Ö¤ÒÔºó±àÒë³öÀ´µÄ³ÌÐòʹÓÃÕýÈ·µÄº¯Êý¿â(/tools/libµÄglibc)

    Õâ¸ögcc¿ÉÒÔ³Æ֮Ϊgcc-a

    (ÕâÀïÊÇÎÒÃǵÚÒ»±é±àÒëbinutilsºÍgcc.ÔÚÕû¸öϵͳµÄ´´½¨¹ý³ÌÖÐ,bintuilsºÍgccÊÇÒª±àÒëÈý´Î,

    ÆäËüµÄ»ù±¾Toolchain¹¤¾ßÊDZàÒëÁ½´Î, ¶îÍâµÄLFSϵͳÈí¼þ½öÐèÒªÒ»´Î.)

    Ò»¸öÎÊÌâ,ÔÚ×¼±¸toolchainµÄʱºòΪʲôҪ±àÒëbintuilsºÍgccÁ½´ÎÄØ?

    ÒòΪÔÚΪÁËÉú³ÉToolchainÖеÄgccµÄ¹ý³ÌÖÐ,ÎÒÃÇÏ£ÍûÉú³ÉµÄgccÊÇSelf compileµÄ,Ò²¾ÍÊÇ×Ô¼ºÄܱàÒë³ö×Ô¼ºÀ´.

    µÚÒ»±éµÄbinutilsºÍgccÊÇΪÁ˱àÒë³öglibc²¢ÄÜ×Ô¼º±àÒë³öµÚ¶þ±éµÄgcc(Self compile).

    ËäȻʵ¼ÊÉÏ¿ÉÒÔÖ±½ÓÓÉhost system±àÒë³öToolchainÖеÄgccºÍbintuils,µ«ÄÇÑùµÄToolchain¾Í²»ÊÇself compileÁË.

    ËùÒÔgccºÍbinutils±È±ðµÄ»ù±¾¹¤¾ß¶¼¶à±àÒëÁËÒ»´Î. (ÔÙ´Î×¢Òâ:ld¹²±àÒëÁË5´Î!ÔÚÁ½´Îµ÷ÕýÖи÷»¹±àÒëÒ»´Î)

    ** bin-2ºÍgcc-2µÄ±àÒë:

    µ½ÕâÀïºó, ÎÒÃÇÊÖÀïÓÐÁËld-a, gcc-a, °´µÀÀíÎÒÃÇÓ¦¸ÃÁ¢¿Ì¿ÉÒÔÖØбàÒëbintuilsºÍgccÀ´Éú³Ébin-2ºÍgcc-2.

    µ«ÊÇΪÁË×ö½«À´gcc-2µÄ²âÊÔ, ÏȱàÒëÁËÈý¸ö²âÊÔËùÐèµÄÈí¼þ°ü: Tcl, Expect, DejaGNU.ÕâÈý¸ö°üÀíÂÛÉÏ¿ÉÒÔ²»Òª.

    Okay,ÏÖÔÚ¿ªÊ¼±àÒëgcc-2

    Óõ½µÄ±àÒëÆ÷,linkerºÍº¯Êý¿â·Ö±ðÊÇgcc-a, ld-a, glibc-1,¿ÉÒÔ¿´µ½ÒѾ­Ã»ÓÐhost systemµÄÓ°ÏìÁË.

    È»ºó±àÒëbin-2,

    ÓõķֱðÊÇgcc-2, ld-a, glibc-1, Ò²²»ÔÙÊÜhost systemµÄÓ°ÏìÁË.

    make install bin-2ºó, ld-aÒ²¸üÐÂΪld-2,

    ** ÆäËü»ù±¾¹¤¾ßµÄ±àÒë:

    ÒÔºótoolchainÖеÄÆäËü¹¤¾ß¾Í¿ÉÒÔºÜÈÝÒ׵Ĵ´½¨ÁË.

    ʹÓõĶ¼ÊÇ(ld-2, gcc-2, glibc-1)

    ** ChrootÖ®ºóµÄglibc-2:

    µ±/toolsĿ¼ÏÂÕâЩ¹¤¾ß×¼±¸ÆëÈ«ºó,ÎÒÃǾͿÉÒÔ¿ªÊ¼chrootÈ»ºóÔÚ»ùÓÚ¸ù/·ÖÇøµÄ»·¾³ÖÐ,

    ÀûÓÃÕâЩ¹¤¾ßÉú³É×îºóµÄϵͳÈí¼þÁË.

    ºÁÎÞÒÉÎÊ,ÎÒÃÇÏëÒª×îÏÈÉú³ÉµÄϵͳÈí¼þ¾ÍÊÇbintuilsºÍgcc.

    µ«ÔÚ´´½¨ËüÃÇ֮ǰ,»¹ÓÐÒ»¸ö¹Ø¼üµÄ°üglibc-2ÐèÒª±àÒë³öÀ´.

    glibc-2±àÒëÓõ½ÊÇ:bin-2/ld-2, gcc-2, glibc-1.