From 426913ea08640343690e423fa521392d44595a9c Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Thu, 10 Feb 2022 20:13:21 +0800 Subject: [PATCH] binutils-pass2: workaround "binaries link to host libraries" issue A very old libtool copy (2009-11-29) is shipped in binutils tarball. It does not support sysroot, so the cross-built binutils binaries may link to libraries from the host distro, if certain libraries are available. The ideal solution should be updating libtool, as libtool-2.4.6 (in LFS) has sysroot support. However, updating libtool for binutils is not trivial: it would require to rerun autoconf and binutils building system sticks to autoconf-2.69. Another issue is the sysroot support for libtool has introduced a configure option "--with-sysroot", which conflicts with an already existing option with the same name in GCC and binutils building system (we are using the GCC/binutils version of --with-sysroot in chapter 5). GCC building system has --with-build-sysroot (we are using this for GCC pass 2) for this issue. Binutils copied GCC building system, but it does not respect --with-build-sysroot. So for now we just edit libtool code to prevent "-L/usr/lib" in $LFS_TGT_gcc command line. It should fix the issue about host libiberty (reported in #lfs-support) as well, but it still need to be confirmed by someone having such a host. Tested with a jhalfs run on LFS. --- chapter01/changelog.xml | 11 ++++++ chapter06/binutils-pass2.xml | 16 +++++---- chapter06/chapter06.xml | 1 - chapter06/zlib.xml | 67 ------------------------------------ 4 files changed, 21 insertions(+), 74 deletions(-) delete mode 100644 chapter06/zlib.xml diff --git a/chapter01/changelog.xml b/chapter01/changelog.xml index 97fff77a0..151814f06 100644 --- a/chapter01/changelog.xml +++ b/chapter01/changelog.xml @@ -39,6 +39,17 @@ or as appropriate for the entry or if needed the entire day's listitem. --> + + 2022-02-10 + + + [xry111] - Workaround the issue causing binaries link to + libraries from the host distro for pass 2 binutils. It's now + unnecessary to build zlib in chapter 6. + + + + 2022-02-09 diff --git a/chapter06/binutils-pass2.xml b/chapter06/binutils-pass2.xml index 414d782b3..e55bcf92b 100644 --- a/chapter06/binutils-pass2.xml +++ b/chapter06/binutils-pass2.xml @@ -43,6 +43,14 @@ Installation of Binutils + + Binutils ships an outdated libtool copy in the tarball. It lacks + sysroot support so the produced binaries will be mistakenly linked to + libraries from the host distro. Workaround this issue: + +sed '6009s/$add_dir//' -i ltmain.sh + Create a separate build directory again: mkdir -v build @@ -85,13 +93,9 @@ cd build make - Install the package, and - workaround an issue causing - libctf.so - to link against zlib from the host distribution: + Install the package: -make DESTDIR=$LFS install -install -vm755 libctf/.libs/libctf.so.0.0.0 $LFS/usr/lib +make DESTDIR=$LFS install diff --git a/chapter06/chapter06.xml b/chapter06/chapter06.xml index 1b1ee40bc..366e9a8ab 100644 --- a/chapter06/chapter06.xml +++ b/chapter06/chapter06.xml @@ -28,7 +28,6 @@ - diff --git a/chapter06/zlib.xml b/chapter06/zlib.xml deleted file mode 100644 index d3f66c8cc..000000000 --- a/chapter06/zlib.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - %general-entities; -]> - - - - - - zlib - &zlib-version; -
&zlib-url;
-
- - Zlib-&zlib-version; - - - Zlib - - - - - - <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" - href="../chapter08/zlib.xml" - xpointer="xpointer(/sect1/sect2[1]/para[1])"/> - - <segmentedlist> - <segtitle>&buildtime;</segtitle> - <segtitle>&diskspace;</segtitle> - - <seglistitem> - <seg>&zlib-tmp-sbu;</seg> - <seg>&zlib-tmp-du;</seg> - </seglistitem> - </segmentedlist> - - </sect2> - - <sect2 role="installation"> - <title>Installation of Zlib - - Prepare Zlib for compilation: - - ./configure --prefix=/usr - - Compile the package: - -make - - Install the package: - -make DESTDIR=$LFS install - - - - - - <para>Details on this package are located in - <xref linkend="contents-zlib" role="."/> - </para> - - </sect2> - -</sect1>