Ignore:
Timestamp:
08/08/2007 04:07:12 AM (17 years ago)
Author:
Jeremy Huntwork <jhuntwork@…>
Children:
4f56afa3
Parents:
bdd659b
Message:

Use a loop, find and sed instead of the gcc specs patch

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/jh/BOOK@8288 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chapter05/gcc-pass2.xml

    rbdd659b r5560d46  
    8585  &gt; gcc/Makefile.in</userinput></screen>
    8686
    87     <para>Apply the following patch to change the location of GCC's default
    88     dynamic linker (typically <filename
    89     class="libraryfile">ld-linux-x86-64.so.2</filename>):</para>
    90 
    91 <screen><userinput>patch -Np1 -i ../&gcc-specs-patch;</userinput></screen>
    92 
    93     <para>The above patch also removes <filename
     87    <para>The following command will change the location of GCC's default
     88    dynamic linker to use the one we installed in
     89    <filename class="directory">/tools</filename>. It also removes <filename
    9490    class="directory">/usr/include</filename> from GCC's include search path.
    95     Patching now rather than adjusting the specs file after installation
     91    Doing this now rather than adjusting the specs file after installation
    9692    ensures that the new dynamic linker is used during the actual build of
    9793    GCC. That is, all of the binaries created during the build will link
    98     against the new Glibc.</para>
    99 
    100     <important>
    101       <para>The above patch is critical in ensuring a successful overall
    102       build. Do not forget to apply it.</para>
    103     </important>
     94    against the new Glibc. Issue:</para>
     95
     96<screen><userinput>for file in $(find gcc/config -name linux64.h -o -name linux.h)
     97do
     98  cp -uv $file{,.orig}
     99  sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&amp;@g' \
     100  -e 's@/usr@/tools@g' $file.orig &gt; $file
     101  echo "
     102#undef STANDARD_INCLUDE_DIR
     103#define STANDARD_INCLUDE_DIR 0" &gt;&gt; $file
     104  touch $file.orig
     105done</userinput></screen>
     106
     107    <para>In case the above seems hard to follow, let's break it down a bit.
     108    First we find all the files under the gcc/config directory that are named
     109    either <filename>linux.h</filename> or <filename>linux64.h</filename>.
     110    For each file found, we copy it to a file of the same name but with an added
     111    suffix of <quote>.orig</quote>. Then the first sed expression prepends
     112    <quote>/tools</quote> to every instance of <quote>/lib/ld</quote>,
     113    <quote>/lib64/ld</quote> or <quote>/lib32/ld</quote>, while the second one
     114    replaces hard-coded instances of <quote>/usr</quote>. Then we add our define
     115    statments altering the include search path to the end of the file. Finally,
     116    we use <command>touch</command> to update the timestamp on the copied files.
     117    When used in conjunction with <command>cp -u</command>, this prevents unexpected
     118    changes to the original files in case the command is inadvertently run twice.
     119    </para>
    104120
    105121    <para>Unsetting the multlib spec for GCC ensures that it
    106122    won't attempt to link against libraries on the host:</para>
    107123
    108 <screen><userinput>cp gcc/config/i386/t-linux64{,.tmp}
    109 sed '/MULTILIB_OSDIRNAMES/d' gcc/config/i386/t-linux64.tmp \
    110   > gcc/config/i386/t-linux64</userinput></screen>
     124<screen><userinput>for file in $(find gcc/config -name t-linux64) ; do \
     125   cp -v $file{,.orig}
     126   sed '/MULTILIB_OSDIRNAMES/d' $file.orig &gt; $file
     127done</userinput></screen>
    111128
    112129    <para>Create a separate build directory again:</para>
Note: See TracChangeset for help on using the changeset viewer.