glibc-inst.xml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 <userinput>cd</userinput>
  5. into the <filename>glibc-&glibc-version;</filename> directory and unpack
  6. Glibc-linuxthreads in that directory, not in <filename>/usr/src</filename> as
  7. you would normally 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. 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 that does 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 <filename>perl</filename> because the Perl
  21. package hasn't been installed yet. And if Glibc thinks Perl isn't installed, the
  22. perl program <filename>mtrace</filename> 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> would fail. Using numeric IDs (as in
  29. <userinput>chown 0 file</userinput>) works fine.</para></listitem>
  30. </itemizedlist>
  31. <para><screen><userinput>patch -Np1 -i ../glibc-&glibc-rootperl-patch-version;-root-perl.patch</userinput></screen></para>
  32. <para>There is a potential problem that causes statically linked binaries
  33. to crash that were linked against Glibc-2.2 or older libraries. Even though
  34. static binaries have all the necessary parts of Glibc built-in, they still
  35. rely on one external library set: Glibc's NSS libraries. These libraries,
  36. among other things, tell programs where the system's password database is
  37. (in <filename>/etc/password</filename>, NIS, or whatever other scheme has
  38. been configured).</para>
  39. <para>Glibc has undergone some changes since version 2.2.x and the new NSS
  40. code is incompatible with the old one. So when Glibc is installed it will
  41. install its new NSS libraries, and static programs will load these new NSS
  42. libraries and will abort with a <emphasis>segmentation fault</emphasis>
  43. error. This patch undoes some of the changes to overcome the problem.</para>
  44. <para>If you started chapter 5 with a host system that uses Glibc-2.2.x
  45. or older, you must apply the following patch. We will install Glibc again at
  46. the end of this chapter to remove this patch so you'll have a pristine Glibc
  47. as the developers intended it.</para>
  48. <para><screen><userinput>patch -Np1 -i ../glibc-&glibc-libnss-patch-version;-libnss.patch</userinput></screen></para>
  49. <para>Glibc will check for the <filename>/etc/ld.so.conf</filename> file
  50. and abort with an error if the file is missing, so we must create it:</para>
  51. <para><screen><userinput>touch /etc/ld.so.conf</userinput></screen></para>
  52. <para>The documentation that comes with Glibc recommends to build the package
  53. not in the source directory but in a separate, dedicated directory:</para>
  54. <para><screen><userinput>mkdir ../glibc-build &amp;&amp;
  55. cd ../glibc-build</userinput></screen></para>
  56. <para>Next, prepare Glibc to be compiled:</para>
  57. <para><screen><userinput>../glibc-&glibc-version;/configure --prefix=/usr \
  58. &nbsp;&nbsp;&nbsp;&nbsp;--disable-profile --enable-add-ons \
  59. &nbsp;&nbsp;&nbsp;&nbsp;--libexecdir=/usr/bin</userinput></screen></para>
  60. <para>The meaning of the configure options are:</para>
  61. <itemizedlist>
  62. <listitem><para><userinput>--disable-profile</userinput>: This disables the
  63. building of the libraries with profiling information. Omit this option if you
  64. plan to do profiling.</para></listitem>
  65. <listitem><para><userinput>--enable-add-ons</userinput>: This enables any
  66. add-ons that we installed with Glibc, in our case Linuxthreads.</para></listitem>
  67. <listitem><para><userinput>--libexecdir=/usr/bin</userinput>: This will
  68. cause the <filename>pt_chown</filename> program to be installed in the
  69. <filename>/usr/bin</filename> directory.</para></listitem>
  70. </itemizedlist>
  71. <para>During this stage you will see the following warning:</para>
  72. <blockquote><screen>configure: warning:
  73. *** These auxiliary programs are missing or too old: msgfmt
  74. *** some features will be disabled.
  75. *** Check the INSTALL file for required versions.</screen></blockquote>
  76. <para>The missing <filename>msgfmt</filename> program (from the Gettext
  77. package, which we'll install later) won't cause any problems. The
  78. <filename>msgfmt</filename> is used to generate the binary translation
  79. files that can make your system talk in a different language. Because these
  80. translation files have already been generated for you, there is no need for
  81. <filename>msgfmt</filename>. You'd only need the program if you change the
  82. translation source files (the <filename>*.po</filename> files in the
  83. <filename class="directory">po</filename> subdirectory), which
  84. would require you to regenerate 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 has failed. This test is supposed to test
  87. <filename>gcc</filename> to determine whether a cross-compiler is installed.
  88. However, Glibc needs to be already installed to run this test. Since the test
  89. failed, the configure script assumes we have a cross-compiler. We override
  90. that assumption by explicitly telling Glibc we're not cross-compiling.
  91. Not doing this would have 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>The locales (used by Glibc to make your Linux system talk in a different
  103. language) weren't installed when you ran the previous command, so we have to
  104. do that ourselves now:</para>
  105. <para><screen><userinput>make localedata/install-locales</userinput></screen></para>
  106. <para>An alternative to running the previous command is to install only those
  107. locales which you need or want. This can be achieved using the localedef
  108. command. Information on this can be found in the <filename>INSTALL</filename>
  109. file in the <filename>glibc-&glibc-version;</filename> tree.</para>
  110. <para>To finish off the installation we'll reload Bash so it will use the new
  111. <filename>libnss_*</filename> files. This will also get rid of the
  112. <emphasis>I have no name!</emphasis> message in the command prompt:</para>
  113. <para><screen><userinput>exec /static/bin/bash --login</userinput></screen></para>
  114. </sect2>