r189 - in trunk/BOOK: . chapter05 chapter06

manuel at linuxfromscratch.org manuel at linuxfromscratch.org
Sun Feb 13 12:10:05 PST 2005


Author: manuel
Date: 2005-02-13 13:10:04 -0700 (Sun, 13 Feb 2005)
New Revision: 189

Added:
   trunk/BOOK/chapter05/gcc-cross.xml
   trunk/BOOK/chapter05/gcc.xml
   trunk/BOOK/chapter06/gcc.xml
Modified:
   trunk/BOOK/chapter05/chapter05.xml
   trunk/BOOK/chapter06/chapter06.xml
   trunk/BOOK/general.ent
Log:
Added the GCC files.

Modified: trunk/BOOK/chapter05/chapter05.xml
===================================================================
--- trunk/BOOK/chapter05/chapter05.xml	2005-02-13 13:14:20 UTC (rev 188)
+++ trunk/BOOK/chapter05/chapter05.xml	2005-02-13 20:10:04 UTC (rev 189)
@@ -12,16 +12,16 @@
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="linux-libc-headers.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="glibc-headers.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="uclibc-headers.xml"/>
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="binutils-cross.xml"/><!--
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="gcc-cross.xml"/>-->
+<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="binutils-cross.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="gcc-cross.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="glibc.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="uclibc.xml"/><!--
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="adjusting.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="tcl.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="expect.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="dejagnu.xml"/>-->
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="binutils.xml"/><!--
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="gcc-native.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="binutils.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="gcc.xml"/><!--
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="gawk.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="coreutils.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="diffutils.xml"/>

Added: trunk/BOOK/chapter05/gcc-cross.xml
===================================================================
--- trunk/BOOK/chapter05/gcc-cross.xml	2005-02-13 13:14:20 UTC (rev 188)
+++ trunk/BOOK/chapter05/gcc-cross.xml	2005-02-13 20:10:04 UTC (rev 189)
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+  <!ENTITY % general-entities SYSTEM "../general.ent">
+  %general-entities;
+]>
+<sect1 id="ch-tools-gcc-cross" role="wrap">
+<title>GCC-&gcc-version; Cross C Compiler</title>
+<?dbhtml filename="gcc.html"?>
+
+<indexterm zone="ch-tools-gcc-cross">
+<primary sortas="a-GCC">GCC</primary>
+<secondary>tools, cross compiler</secondary></indexterm>
+
+<sect2 role="package"><title/>
+<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
+href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
+
+<segmentedlist>
+<segtitle>&buildtime;</segtitle>
+<segtitle>&diskspace;</segtitle>
+<seglistitem><seg>?? SBU</seg><seg>?? MB</seg></seglistitem>
+</segmentedlist>
+
+<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
+href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
+
+</sect2>
+
+<sect2 role="installation">
+<title>Installation of GCC</title>
+
+<para>Unpack only the gcc-core tarball because neither the C++
+compiler nor the test suite will be needed here.</para>
+
+<para>This package is known to have issues when its default
+optimization flags (including the <parameter>-march</parameter> and
+<parameter>-mcpu</parameter> options) are changed. If any environment
+variables that override default optimizations have been defined, such
+as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
+unset them when building GCC.</para>
+
+<para condition="uclibc">Aplly this patch to ... EDIT ME</para>
+
+<screen condition="uclibc"><userinput>patch -Np1 -i ../gcc-&gcc-version;-uClibc_conf-1.patch</userinput></screen>
+
+<para>GCC will try to use <filename class="directory">/tools/${target}/include</filename>
+because it is a cross compiler. The following command directs GCC to use 
+<filename class="directory">/tools/include</filename> instead:</para>
+
+<screen><userinput>sed -e 's@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 /tools/include at g' \
+    -i gcc/Makefile.in</userinput></screen>
+    
+<para>This patch adds two configure options, <parameter>--with-dynamic-linker</parameter>
+and <parameter> --with-nostdinc</parameter>. It must be applied before the next command 
+or else the patch will fail to apply:</para>
+
+<screen><userinput>patch -Np1 -i ../gcc-&gcc-version;-specs_x86-1.patch</userinput></screen>
+
+<para>Set the start file prefix. This will default to <filename 
+class="directory">/tools/${target}/lib</filename>, but there's no need to install the 
+start files there:</para>
+
+<screen><userinput>echo "
+#undef STARTFILE_PREFIX_SPEC
+#define STARTFILE_PREFIX_SPEC \"/tools/lib/\"" >> gcc/config/linux.h</userinput></screen>
+
+<para>The GCC specs patch will check if the <parameter>--with-dynamic-linker</parameter>
+file exists, so make it exist:</para>
+
+<screen><userinput>touch ${ldso}</userinput></screen>
+
+<para>The GCC documentation recommends building GCC outside of the
+source directory in a dedicated build directory:</para>
+
+<screen><userinput>mkdir ../gcc-build
+cd ../gcc-build</userinput></screen>
+
+<para>Prepare Gcc for compilation:</para>
+
+<screen><userinput>../gcc-3.4.3/configure --prefix=/tools --target=${target} \
+    --with-local-prefix=/tools --disable-nls \
+    --disable-shared --enable-languages=c \
+    --with-dynamic-linker=${ldso} --with-nostdinc</userinput></screen>
+
+<para>Compile the package:</para>
+
+<screen><userinput>make</userinput></screen>
+
+<para>Install the package:</para>
+
+<screen><userinput>make install</userinput></screen>
+
+</sect2>
+
+<sect2 role="content"><title/>
+<para>Details on this package are located in <xref
+linkend="contents-gcc" role="."/></para>
+</sect2>
+
+</sect1>
+


Property changes on: trunk/BOOK/chapter05/gcc-cross.xml
___________________________________________________________________
Name: svn:keywords
   + "Author Date Revision Id"

Added: trunk/BOOK/chapter05/gcc.xml
===================================================================
--- trunk/BOOK/chapter05/gcc.xml	2005-02-13 13:14:20 UTC (rev 188)
+++ trunk/BOOK/chapter05/gcc.xml	2005-02-13 20:10:04 UTC (rev 189)
@@ -0,0 +1,269 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+  <!ENTITY % general-entities SYSTEM "../general.ent">
+  %general-entities;
+]>
+<sect1 id="ch-tools-gcc" role="wrap">
+<title>GCC-&gcc-version;</title>
+<?dbhtml filename="gcc.html"?>
+
+<indexterm zone="ch-tools-gcc">
+<primary sortas="a-GCC">GCC</primary>
+<secondary>tools</secondary></indexterm>
+
+<sect2 role="package"><title/>
+<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
+href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
+
+<segmentedlist>
+<segtitle>&buildtime;</segtitle>
+<segtitle>&diskspace;</segtitle>
+<seglistitem><seg>?? SBU</seg><seg>?? MB</seg></seglistitem>
+</segmentedlist>
+
+<xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
+href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
+
+</sect2>
+
+<sect2 role="installation">
+<title>Installation of GCC</title>
+
+<para>This package is known to have issues when its default
+optimization flags (including the <parameter>-march</parameter> and
+<parameter>-mcpu</parameter> options) are changed. If any environment
+variables that override default optimizations have been defined, such
+as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
+unset them when building GCC.</para>
+
+<para>Because the C and the C++ compilers will be built, unpack both
+the core and the g++ tarballs (as well as test suite, if you want to
+run the tests). By unpacking them in the working directory, they will
+all unfold into a single <filename
+class="directory">gcc-&gcc-version;/</filename> subdirectory.</para>
+
+<para condition="uclibc">Apply these patches. The locale patch is needed
+even without locales installed:</para>
+
+<screen condition="uclibc"><userinput>patch -Np1 -i ../gcc-&gcc-version;-uClibc_conf-1.patch
+patch -Np1 -i ../gcc-&gcc-version;-uClibc_libstdc++-1.patch
+patch -Np1 -i ../gcc-&gcc-version;-uClibc_locale-1.patch</userinput></screen>
+
+<para>This patch adds the stack protector code for GCC:</para>
+
+<screen><userinput>patch -Np1 -i ../gcc-&gcc-version;-ssp-3.patch</userinput></screen>
+
+<para>The bugs URL and version strings are modified as the comments in 
+<filename>version.c</filename> recommends:</para>
+
+<screen><userinput>sed -e 's at gcc.gnu.org/bugs.html at bugs.linuxfromscratch.org/@' \
+        -e 's/&gcc-version;/&gcc-version; (ssp)/' -i gcc/version.c</userinput></screen>
+
+<para>Now correct a known problem and make an essential adjustment:</para>
+
+<screen><userinput>patch -Np1 -i ../gcc-&gcc-version;-specs_x86-1.patch
+patch -Np1 -i ../gcc-&gcc-version;-no_fixincludes-1.patch</userinput></screen>
+
+<para>The first patch changes GCC's default location of the dynamic
+linker (typically <filename class="libraryfile">ld-linux.so.2</filename>). It also removes
+<filename class="directory">/usr/include</filename> from GCC's include
+search path. Patching now rather than adjusting the specs file after
+installation ensures that the new dynamic linker is used during the
+actual build of GCC. That is, all of the final (and temporary)
+binaries created during the build will link against the new
+Glibc.</para>
+
+<para>The second patch disables the GCC <command>fixincludes</command>
+script. This was briefly mentioned earlier, but a more in-depth
+explanation of the fixincludes process is warranted here. Under normal
+circumstances, the GCC <command>fixincludes</command> script scans the
+system for header files that need to be fixed. It might find that some
+Glibc header files on the host system need to be fixed, and will fix
+them and put them in the GCC private include directory. In <xref
+linkend="chapter-building-system"/>, after the newer Glibc has been
+installed, this private include directory will be searched before the
+system include directory.  This may result in GCC finding the fixed
+headers from the host system, which most likely will not match the
+Glibc version used for the LFS system.</para>
+
+<important><para>The above patches are critical in ensuring a
+successful overall build. Do not forget to apply
+them.</para></important>
+
+<para>Create a separate build directory again:</para>
+
+<screen><userinput>mkdir ../gcc-build
+cd ../gcc-build</userinput></screen>
+
+<para>Prepare GCC for compilation:</para>
+
+<screen><userinput>env CC=${target}-gcc \
+../gcc-&gcc-version;/configure --prefix=/tools \
+    --host=${target} --build=${target} --target=${target} \
+    --libexecdir=/tools/lib --with-local-prefix=/tools \
+    --enable-shared --enable-threads=posix \
+    --enable-__cxa_atexit --enable-languages=c,c++ \
+    --disable-libstdcxx-pch ${disable_nls} ${clocale} \
+    --with-dynamic-linker=${ldso} --with-nostdinc \
+    --enable-multilib=no</userinput></screen>
+
+<para>Compile the package:</para>
+
+<screen><userinput>make</userinput></screen>
+
+<para>To test the results, issue: <userinput>make -k
+check</userinput>. Consult the LFS GCC test notes for details on GCC's test results.
+<phrase condition="uclibc">There will be many failures.</phrase></para>
+
+<para>Install the package:</para>
+
+<screen><userinput>make install
+ln -s gcc /tools/bin/cc</userinput></screen>
+
+</sect2>
+
+<sect2  role="installation">
+<title>Adding Hardened Specs</title>
+
+<para>This depend on Perl. If you do not have Perl installed on your host system
+then you can skip this, and testing, and return here after Perl is installed
+later in this chapter.</para>
+
+<para>We are going to need to repeat these commands later for Binutils tests in
+chapter 6, and when GCC is reinstalled. Since these commands are ugly to
+repeat it's best to dump them into a script, as it is done below.</para>
+
+<para>This will add <parameter>-fstack-protector-all</parameter> to the default 
+for <command>gcc</command> and <command>g++</command>. The only
+filter is for <parameter>-fno-stack-protector*</parameter>:</para>
+
+<screen><userinput>cat > hardened-specs.sh << "EOF"
+<literal>#!/bin/sh
+perl -pi -e 's@\*cc1:\n@$_%(cc1_ssp) @;' \
+    $(gcc --print-file specs) &&
+perl -pi -e 's@\*cc1plus:\n@$_%(cc1_ssp) @;' \
+    $(gcc --print-file specs) &&
+echo '*cc1_ssp: %{!fno-stack-protector*: -fstack-protector-all}' \
+    >> $(gcc --print-file specs)</literal>
+EOF</userinput></screen>
+
+<para>These commands will make <command>gcc -fPIC</command>, 
+<command>ld -pie</command>, and <command>cpp -D__PIC__ -DPIC</command>
+the default. The exact default behavior for <command>gcc -pie</command> will be 
+preserved. If <parameter>-pie</parameter>, <parameter>-no-pie</parameter>, or 
+<parameter>-static</parameter> are used then the vanilla behavior will be
+used instead. Additional filters are added to the link_command spec to prevent 
+libraries from receiving the <parameter>-pie</parameter> option.
+Read <xref linkend="technotes-pie"/> for more information on this.</para>
+
+<para>We will append to the file created above:</para>
+
+<screen><userinput>cat >> hardened-specs.sh << "EOF"
+<literal>perl -pi -e 's@\*cc1:\n@$_%(cc1_pie) @;' \
+    $(gcc --print-file specs) &&
+perl -pi -e 's@\*cc1plus:\n@$_%(cc1_pie) @;' \
+    $(gcc --print-file specs) &&
+perl -pi -e 's@%{pie:-pie}@%(link_pie)@;' \
+    $(gcc --print-file specs) &&
+perl -pi -e 's at pie:@!no-pie|pie:@g;' $(gcc --print-file specs) &&
+perl -pi -e 's@\*cpp:\n@$_%(cpp_pie) @;' $(gcc --print-file specs) &&
+echo '*cpp_pie: %{!static:%{!no-pie:%{!pie: -D__PIC__ -DPIC}}}' \
+    >> $(gcc --print-file specs) &&
+echo '*cc1_pie: %{!static:%{!no-pie:%{!pie: -fPIC}}}' \
+    >> $(gcc --print-file specs) &&
+echo '*link_pie: %{pie:-pie}%{!no-pie:%{!static:%{!Bstatic:%{!i:%{!r: -z now -z relro -z combreloc %{!shared:%{!Bshareable:%{!pie: -pie}}}}}}}}' \
+    >> $(gcc --print-file specs)</literal>
+EOF</userinput></screen>
+
+<para>Now, install and run this script:</para>
+
+<screen><userinput>install hardened-specs.sh /tools/bin
+/tools/bin/hardened-specs.sh</userinput></screen>
+
+<para>You can restore the vanilla gcc specs at any time with
+<command>gcc -dumpspecs > $(gcc --print-file specs)</command>.</para>
+
+</sect2>
+
+<sect2  role="installation">
+<title>Testing</title>
+
+<para>Now we can run tests to check that the new GCC is working as expected.</para>
+
+<para>This program will create a buffer overflow with an array length 7. This
+will test that <parameter>-fstack-protector-all</parameter> is working. It will also print the
+<function> __guard[]</function> value. The <function>__guard</function> value 
+should change with each run.</para>
+
+<screen><userinput>cat > test.c << "EOF"
+<literal>#include <stdio.h>
+#include <unistd.h>
+extern long __guard[];
+int overflow(char *test) {
+  char buffer[7];
+  sprintf(buffer, "12345678901234567890123456789012345678901234567890");
+  return(1234);
+}
+int main(int argc, char **argv) {
+  printf("__guard\t=\t0x%08x;\n", __guard[0]);
+  overflow("test");
+  printf("This line should never get printed.\n");
+}</literal>
+EOF</userinput></screen>
+
+<para>Now compile and run it with <command>gcc</command>:</para>
+
+<screen><userinput>gcc -o test test.c
+./test</userinput></screen>
+
+<para>This should return something like this</para>
+
+<screen><computeroutput> __guard =       0xbd06f7b2;
+./test: stack smashing attack in function overflow()
+Aborted</computeroutput></screen>
+
+<para>Then test <command>g++</command>. The <parameter>-pie -fPIE</parameter>
+are added to check they work too:</para>
+
+<screen><userinput>g++ -pie -fPIE -o test2 test.c
+./test2</userinput></screen>
+
+<para>The <command>g++</command> test should return something very similar. 
+The <function>__guard</function> value should change, and both tests should 
+receive an abort signal. Your host system Syslog daemon should also log these events.</para>
+
+<para>Then make sure <command>gcc</command> is linking to <filename
+class="directory">tools</filename> and is creating position independent executables. 
+Also make sure the GNU_RELRO, and PAX_FLAGS program headers exist:</para>
+
+<screen><userinput>readelf -l test{,2} | grep -e ': /tools' -e 'Shared' \
+    -e 'GNU_RELRO' -e 'PAX_FLAGS'</userinput></screen>
+
+<para>This should return (twice):</para>
+
+<screen><computeroutput>Elf file type is DYN (Shared object file)
+     [Requesting program interpreter: /tools/lib/ld-something.so]
+ GNU_RELRO      0x000ef4 0x00001ef4 0x00001ef4 0x0010c 0x0010c R   0x1
+ PAX_FLAGS      0x000000 0x00000000 0x00000000 0x00000 0x00000     0x4</computeroutput></screen>
+ 
+ <para>There are two more things to check for. The BIND_NOW section should exist.
+The TEXTREL section should not exist:</para>
+
+<screen><userinput>readelf -d test{,2} | grep -e 'BIND_NOW' -e 'TEXTREL'</userinput></screen>
+
+<para>This should return (twice):</para>
+
+<screen><computeroutput>0x00000018 (BIND_NOW)</computeroutput></screen>
+
+<para>There is no way to check for combreloc. The two readelf tests should produce
+the same results on all shared executables and libraries you build.</para>
+
+</sect2>
+
+<sect2 role="content"><title/>
+<para>Details on this package are located in <xref
+linkend="contents-gcc" role="."/></para>
+</sect2>
+
+</sect1>
+


Property changes on: trunk/BOOK/chapter05/gcc.xml
___________________________________________________________________
Name: svn:keywords
   + "Author Date Revision Id"

Modified: trunk/BOOK/chapter06/chapter06.xml
===================================================================
--- trunk/BOOK/chapter06/chapter06.xml	2005-02-13 13:14:20 UTC (rev 188)
+++ trunk/BOOK/chapter06/chapter06.xml	2005-02-13 20:10:04 UTC (rev 189)
@@ -22,8 +22,8 @@
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="glibc.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="uclibc.xml"/><!--
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="readjusting.xml"/>-->
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="binutils.xml"/><!--
-<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="gcc.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="binutils.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="gcc.xml"/><!--
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="coreutils.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="zlib.xml"/>
 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="mktemp.xml"/>

Added: trunk/BOOK/chapter06/gcc.xml
===================================================================
--- trunk/BOOK/chapter06/gcc.xml	2005-02-13 13:14:20 UTC (rev 188)
+++ trunk/BOOK/chapter06/gcc.xml	2005-02-13 20:10:04 UTC (rev 189)
@@ -0,0 +1,229 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+  <!ENTITY % general-entities SYSTEM "../general.ent">
+  %general-entities;
+]>
+<sect1 id="ch-system-gcc" role="wrap">
+<title>GCC-&gcc-version;</title>
+<?dbhtml filename="gcc.html"?>
+
+<indexterm zone="ch-system-gcc">
+<primary sortas="a-GCC">GCC</primary>
+</indexterm>
+
+<sect2 role="package"><title/>
+<para>The GCC package contains the GNU compiler collection, which includes
+the C and C++ compilers.</para>
+
+<segmentedlist>
+<segtitle>&buildtime;</segtitle>
+<segtitle>&diskspace;</segtitle>
+<seglistitem><seg>?? SBU</seg><seg>?? MB</seg></seglistitem>
+</segmentedlist>
+
+<segmentedlist>
+<segtitle>GCC installation depends on</segtitle>
+<seglistitem><seg>Bash, Binutils, Coreutils, Diffutils, Findutils,
+Gawk, Gettext, Glibc, Grep, Make, Perl, Sed, and Texinfo</seg></seglistitem>
+</segmentedlist>
+
+</sect2>
+
+<sect2 role="installation">
+<title>Installation of GCC</title>
+
+<para>This package is known to have issues when its default
+optimization flags (including the <parameter>-march</parameter> and
+<parameter>-mcpu</parameter> options) are changed. If any environment
+variables that override default optimizations have been defined, such
+as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
+unset them when building GCC.</para>
+
+<para>Unpack both the gcc-core and the gcc-g++ tarballs—they will
+unpack into the same directory. Likewise, extract the gcc-testsuite
+package.  The full GCC package contains additional compilers.
+Instructions for building these can be found at <ulink
+url="&blfs-root;view/svn/general/gcc.html"/>.</para>
+
+<para condition="uclibc">Apply these patches. The locale patch is needed
+even without locales installed:</para>
+
+<screen condition="uclibc"><userinput>patch -Np1 -i ../gcc-3.4.3-uClibc_conf-1.patch
+patch -Np1 -i ../gcc-3.4.3-uClibc_libstdc++-1.patch
+patch -Np1 -i ../gcc-3.4.3-uClibc_locale-1.patch</userinput></screen>
+
+<para>Apply this set of patches:</para>
+
+<screen><userinput>patch -Np1 -i ../gcc-3.4.3-hardened_cflags-1.patch
+patch -Np1 -i ../gcc-3.4.3-specs_x86-1.patch
+patch -Np1 -i ../gcc-3.4.3-no_fixincludes-1.patch
+patch -Np1 -i ../gcc-3.4.3-ssp-3.patch
+patch -Np1 -i ../gcc-3.4.3-linkonce-1.patch</userinput></screen>
+
+<para>Fix <filename>libiberty/Makefile.in</filename>:</para>
+
+<screen><userinput>sed -e 's/install_to_$(INSTALL_DEST) //' -i libiberty/Makefile.in</userinput></screen>
+
+<para>The bugs URL and version strings are modified as the comments in 
+<filename>version.c</filename> recommends:</para>
+
+<screen><userinput>sed -e 's at gcc.gnu.org/bugs.html at bugs.linuxfromscratch.org/@' \
+        -e 's/3.4.3/3.4.3 (ssp)/' -i gcc/version.c</userinput></screen>
+
+<para>Create a separate build directory again:</para>
+
+<screen><userinput>mkdir ../gcc-build
+cd ../gcc-build</userinput></screen>
+
+<para>Prepare GCC for compilation:</para>
+
+<screen><userinput>../gcc-3.4.3/configure --prefix=/usr \
+    --host=${target} --build=${target} --target=${target} \
+    --libexecdir=/usr/lib --enable-threads=posix \
+    --enable-shared --enable-__cxa_atexit \
+    --with-dynamic-linker=${ldso} ${disable_nls} ${clocale} \
+    --enable-languages=c,c++ --enable-multilib=no</userinput></screen>
+
+<para>Compile the package:</para>
+
+<screen><userinput>make</userinput></screen>
+
+<para>To test the results, issue: <userinput>make -k check</userinput>. 
+The results should be identical to results you would typically get from an LFS build. 
+There is an SSP test in <filename class="directory">gcc.misc-tests/</filename>
+which should pass.</para>
+
+<para>Install the package:</para>
+
+<screen><userinput>make install</userinput></screen>
+
+<para>Some packages expect the C PreProcessor to be installed in the
+<filename class="directory">/lib</filename> directory.
+To support those packages, create this symlink:</para>
+
+<screen><userinput>ln -s ../usr/bin/cpp /lib</userinput></screen>
+
+<para>Many packages use the name <command>cc</command> to call the C
+compiler. To satisfy those packages, create a symlink:</para>
+
+<screen><userinput>ln -s gcc /usr/bin/cc</userinput></screen>
+
+<para>And restore the hardened specs:</para>
+
+<screen><userinput>/tools/bin/hardened-specs.sh</userinput></screen>
+
+<para>Remove the statics libs installed by GCC:</para>
+
+<screen condition="glibc"><userinput>rm /usr/lib/{libsupc++,libstdc++}.a
+rm /usr/lib/gcc/${target}/3.4.3/libgcov.a</userinput></screen>
+
+<screen condition="uclibc"><userinput>rm /usr/lib/{libsupc++,libstdc++}.a
+rm /usr/lib/gcc/${target}/3.4.3/libgcov.a
+rm /usr/lib/libstdc++_pic.a</userinput></screen>
+
+<para><filename class="libraryfile">libc.a</filename> can be removed now too:</para>
+
+<screen><userinput>rm /usr/lib/libc.a</userinput></screen>
+
+</sect2>
+
+
+<sect2 id="contents-gcc" role="content"><title>Contents of GCC</title>
+
+<segmentedlist>
+<segtitle>Installed programs</segtitle>
+<segtitle>Installed libraries</segtitle>
+<seglistitem><seg>c++, cc (link to gcc), cpp, g++, gcc, gccbug, and gcov</seg>
+<seg>libgcc.a, libgcc_eh.a, libgcc_s.so, libstdc++.[a,so], and libsupc++.a</seg></seglistitem>
+</segmentedlist>
+
+<variablelist><bridgehead renderas="sect3">Short Descriptions</bridgehead>
+<?dbfo list-presentation="list"?>
+
+<varlistentry id="cc">
+<term><command>cc</command></term>
+<listitem>
+<para>The C compiler</para>
+<indexterm zone="ch-system-gcc cc"><primary sortas="b-cc">cc</primary></indexterm>
+</listitem>
+</varlistentry>
+
+<varlistentry id="cpp">
+<term><command>cpp</command></term>
+<listitem>
+<para>The C preprocessor; it is used by the compiler to expand the
+#include, #define, and similar statements in the source files</para>
+<indexterm zone="ch-system-gcc cpp"><primary sortas="b-cpp">cpp</primary></indexterm>
+</listitem>
+</varlistentry>
+
+<varlistentry id="c">
+<term><command>c++</command></term>
+<listitem>
+<para>The C++ compiler</para>
+<indexterm zone="ch-system-gcc c"><primary sortas="b-c++">c++</primary></indexterm>
+</listitem>
+</varlistentry>
+
+<varlistentry id="g">
+<term><command>g++</command></term>
+<listitem>
+<para>The C++ compiler</para>
+<indexterm zone="ch-system-gcc g"><primary sortas="b-g++">g++</primary></indexterm>
+</listitem>
+</varlistentry>
+
+<varlistentry id="gcc">
+<term><command>gcc</command></term>
+<listitem>
+<para>The C compiler</para>
+<indexterm zone="ch-system-gcc gcc"><primary sortas="b-gcc">gcc</primary></indexterm>
+</listitem>
+</varlistentry>
+
+<varlistentry id="gccbug">
+<term><command>gccbug</command></term>
+<listitem>
+<para>A shell script used to help create useful bug reports</para>
+<indexterm zone="ch-system-gcc gccbug"><primary sortas="b-gccbug">gccbug</primary></indexterm>
+</listitem>
+</varlistentry>
+
+<varlistentry id="gcov">
+<term><command>gcov</command></term>
+<listitem>
+<para>A coverage testing tool; it is used to analyze programs to
+determine where optimizations will have the most effect</para>
+<indexterm zone="ch-system-gcc gcov"><primary sortas="b-gcov">gcov</primary></indexterm>
+</listitem>
+</varlistentry>
+
+<varlistentry id="libgcc">
+<term><filename class="libraryfile">libgcc</filename></term>
+<listitem>
+<para>Contains run-time support for <command>gcc</command></para>
+<indexterm zone="ch-system-gcc libgcc"><primary sortas="c-libgcc*">libgcc*</primary></indexterm>
+</listitem>
+</varlistentry>
+
+<varlistentry id="libstdc">
+<term><filename class="libraryfile">libstdc++</filename></term>
+<listitem>
+<para>The standard C++ library</para>
+<indexterm zone="ch-system-gcc libstdc"><primary sortas="c-libstdc++">libstdc++</primary></indexterm>
+</listitem>
+</varlistentry>
+
+<varlistentry id="libsupc">
+<term><filename class="libraryfile">libsupc++</filename></term>
+<listitem>
+<para>Provides supporting routines for the C++ programming language</para>
+<indexterm zone="ch-system-gcc libsupc"><primary sortas="c-libsupc++">libsupc++</primary></indexterm>
+</listitem>
+</varlistentry>
+</variablelist>
+
+</sect2>
+
+</sect1>
+


Property changes on: trunk/BOOK/chapter06/gcc.xml
___________________________________________________________________
Name: svn:keywords
   + "Author Date Revision Id"

Modified: trunk/BOOK/general.ent
===================================================================
--- trunk/BOOK/general.ent	2005-02-13 13:14:20 UTC (rev 188)
+++ trunk/BOOK/general.ent	2005-02-13 20:10:04 UTC (rev 189)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!ENTITY version "SVN-20050126">
-<!ENTITY releasedate "January 26th, 2005">
+<!ENTITY version "SVN-20050213">
+<!ENTITY releasedate "Febraury 13th, 2005">
 <!ENTITY milestone "0.2">
 
 <!ENTITY lfs-root "http://www.linuxfromscratch.org/">




More information about the hlfs-dev mailing list