glibc-inst.xml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <sect2><title>&nbsp;</title><para>&nbsp;</para></sect2>
  2. <sect2>
  3. <title>Glibc installation</title>
  4. <para>Before starting to install glibc, you must cd into the
  5. glibc-&glibc-version; directory and unpack glibc-linuxthreads inside
  6. the glibc-&glibc-version; directory, not in /usr/src as you normally
  7. would do.</para>
  8. <para>This package is known to behave badly when you have changed its
  9. default optimization flags (including the -march and -mcpu options).
  10. Therefore, if you have defined any environment variables that override
  11. default optimizations, such as CFLAGS and CXXFLAGS, we recommend unsetting
  12. or modifying them when building Glibc.</para>
  13. <para>Basically, compiling Glibc in any other way than the book suggests
  14. is putting your system at a very high risk.</para>
  15. <para>We'll start by applying a patch to Glibc that fixes the following:</para>
  16. <itemizedlist>
  17. <listitem><para>It converts all occurrences of <emphasis>$(PERL)</emphasis>
  18. to <emphasis>/usr/bin/perl</emphasis> in the
  19. <filename>malloc/Makefile</filename> file. This is done because Glibc
  20. can't autodetect the location of perl because the Perl package hasn't been
  21. installed yet. And if Glibc thinks Perl isn't installed, the
  22. <userinput>mtrace</userinput> perl program won't be installed
  23. either.</para></listitem>
  24. <listitem><para>It replaces all occurrences of <emphasis>root</emphasis>
  25. with <emphasis>0</emphasis> in the <filename>login/Makefile</filename>
  26. file. This is done because Glibc itself isn't installed yet and therefore
  27. username to userid resolving isn't working yet, so a
  28. <userinput>chown root file</userinput> will fail, however it'll work fine
  29. if you use the numeric IDs (such as <userinput>chown 0
  30. file</userinput>).</para></listitem>
  31. </itemizedlist>
  32. <para><screen><userinput>patch -Np1 -i ../glibc-&glibc-rootperl-patch-version;-root-perl.patch</userinput></screen></para>
  33. <para>There is a potential problem that causes statically linked binaries
  34. to crash that were linked against Glibc-2.2 or older libraries. Even though
  35. static binaries have all the necessary parts of Glibc built-in, they still
  36. rely on one external library set: Glibc's NSS libraries. These libraries,
  37. among other things, tell programs where the system's password database is
  38. (/etc/password, or NIS, or whatever other scheme has been
  39. configured).</para>
  40. <para>Glibc has undergone some changes since version 2.2.x and the new NSS
  41. code is incompatible with the old one. So when Glibc is installed, it will
  42. install its new NSS libraries and static programs will load these new NSS
  43. libraries and start to abort with <emphasis>segmentation fault</emphasis>
  44. error. This patch undoes a few of the changes to overcome the problem.</para>
  45. <para>If you started chapter 5 with a host system that uses Glibc-2.2.x
  46. or older, you must apply the following patch. We will install Glibc again at
  47. the end of this chapter to remove this patch so you'll have a pristine Glibc
  48. as the developers intended it.</para>
  49. <para><screen><userinput>patch -Np1 -i ../glibc-&glibc-libnss-patch-version;-libnss.patch</userinput></screen></para>
  50. <para>Glibc will check for the <filename>/etc/ld.so.conf</filename> file
  51. and abort with an error if the file is missing, so we must create it:</para>
  52. <para><screen><userinput>touch /etc/ld.so.conf</userinput></screen></para>
  53. <para>It is recommended by the Glibc installation documentation to build
  54. Glibc outside of the source directory in a dedicated directory:</para>
  55. <para><screen><userinput>mkdir ../glibc-build &amp;&amp;
  56. cd ../glibc-build</userinput></screen></para>
  57. <para>Next, prepare Glibc to be compiled:</para>
  58. <para><screen><userinput>../glibc-&glibc-version;/configure --prefix=/usr \
  59. &nbsp;&nbsp;&nbsp;&nbsp;--disable-profile --enable-add-ons \
  60. &nbsp;&nbsp;&nbsp;&nbsp;--libexecdir=/usr/bin</userinput></screen></para>
  61. <para>The meaning of the configure options are:</para>
  62. <itemizedlist>
  63. <listitem><para><userinput>--disable-profile</userinput>: This disables the
  64. building of libraries with profiling information. This command may be
  65. omitted if you plan to do profiling.</para></listitem>
  66. <listitem><para><userinput>--enable-add-ons</userinput>: This enables the
  67. add-on that we install with Glibc, linuxthreads</para></listitem>
  68. <listitem><para><userinput>--libexecdir=/usr/bin</userinput>: This will
  69. cause the pt_chown program to be installed in the /usr/bin
  70. directory.</para></listitem>
  71. </itemizedlist>
  72. <para>During this stage you will see the following warning:</para>
  73. <blockquote><screen>configure: warning:
  74. *** These auxiliary programs are missing or too old: msgfmt
  75. *** some features will be disabled.
  76. *** Check the INSTALL file for required versions.</screen></blockquote>
  77. <para>The missing msgfmt (from the gettext package which we will install
  78. later in this chapter) won't cause any problems. msgfmt is used to generate
  79. the binary translation files that are used to make your system talk in a
  80. different language. Because these translation files have already been
  81. generated for you, there is no need for msgfmt. You'd only need msgfmt if
  82. you change the translation source files (the <filename>*.po</filename>
  83. files in the <filename class="directory">po</filename> subdirectory) which
  84. would require you to re-generate the binary files.</para>
  85. <para>Because Glibc hasn't been installed yet, one of the tests that was
  86. run by the configure script failed. This test is supposed to test gcc to
  87. determine whether or not a cross-compiler is installed. However, Glibc
  88. needs to be installed already to run this test. Since the test failed, the
  89. configure script automatically assumed we do have a cross-compiler. We have
  90. to override that assumption by explicitly telling Glibc we're not
  91. cross-compiling. Not doing this has a couple of unintended side effects,
  92. such as the timezone files not being installed.</para>
  93. <para><screen><userinput>echo "cross-compiling = no" &gt; configparms</userinput></screen></para>
  94. <para>Continue with compiling the package:</para>
  95. <para><screen><userinput>make</userinput></screen></para>
  96. <para>We'll continue with installing the package. The Linuxthreads man
  97. pages are not going to be installed at this point because it requires a
  98. working Perl installation. We'll install Perl later on in this chapter,
  99. and the man pages will be installed when Glibc is installed for the second
  100. time at the end of this chapter.</para>
  101. <para><screen><userinput>make install</userinput></screen></para>
  102. <para>Locales aren't installed when you ran
  103. <userinput>make install</userinput>, so we have to do that ourselves now.
  104. Locales are used by Glibc to make your Linux system talk in a different
  105. language:</para>
  106. <para><screen><userinput>make localedata/install-locales</userinput></screen></para>
  107. <para>An alternative to running <userinput>make
  108. localedata/install-locales</userinput> is to only install those locales
  109. which you need or want. This can be achieved using the localedef
  110. command. Information on this can be found in the INSTALL
  111. file in the glibc-&glibc-version; tree.</para>
  112. <para>To finish off the installation we'll reload Bash so it uses the
  113. libnss files. This will also get rid of the
  114. <emphasis>I have no name!</emphasis> message in the command prompt:</para>
  115. <para><screen><userinput>exec /static/bin/bash --login</userinput></screen></para>
  116. </sect2>