[lfs-dev] Killing the /lib64 symlinks

DJ Lucas dj at linuxfromscratch.org
Sun Aug 7 02:17:44 PDT 2016



On 08/06/2016 05:42 PM, Ken Moffat wrote:
> On Sat, Aug 06, 2016 at 05:15:40PM -0500, Douglas R. Reno wrote:
>> I continue to build Xorg in /usr regularly. I know the advantages of
>> running it in /opt, but... binary programs!
>>
> [...]
>> I would need it, so it would probably screw up any updates that I do
>> further if we make this change. I have two binary programs that I run
>> regularly. The most important one for me is an application/game called
>> Uplink, created by Introversion Software. As it is, for that one, I have to
>> change it from a .deb file into a .tar.gz using the deb2targz script. The
>> other is a version control manager on a system I maintain for a friend of
>> mine. That is called PVSS, and it is a pain to get running in general, but
>> I always have the client installed in case I have to do anything.
>
> I've had to accept that I'm not any good at most of this stuff, even
> estimating (4 expletive-deleted months to look at fonts, allowing an
> extra month for various texlive and firefox stuff, when I assumed I'd
> get it done in 2 - and I still haven't posted my suggestions for
> changes) so, as an alternative, maybe somebody who understands this
> [ Hi Chris, Hi DJ ] could produce a hint on removing /lib64 ?

Actually, Chris already did. See the "Was" on BLFS-Dev. :-) But also see 
attached a rough sketch of the proposed changes (3rd incarnation) based 
on Chris's previous patch set. Keep in mind that this is not fully baked 
yet, and is absolutely not 100% as all of the GCC libs wound up in 
/tools/lib64 on try 2 (didn't copy over commands to modify t-linux64). 
Looks like everything else from CH5 wound up in /tools/lib as was 
intended. This is most certainly for *after* our next release. Even if I 
have it working reliably tomorrow morning, we'll need additional time to 
fully test LLVM, QT, and CMake packages, and I really don't think our 
branch time is sufficient to test this thoroughly.

> Years ago, I used to run pure64 CLFS on x86_64 - and it was clean,
> but in those days one or two source programs needed attention.  I
> really miss that cleanliness, and I suspect that a lot of the
> libtool "appears to be moved" messages are related to this - but
> then I haven't built 32-bit for perhaps a year, so maybe I'm
> mistaken about that message.

Yes, that is where those messages actually come from. I was just 
exploring. So far, no *major* changes look necessary, but binutils and 
glibc updates threw in a minor monkey wrench with my original build 
following Chris's changes, and a bunch of typos killed the first this 
morning, forgotten t-linux64 changes the second earlier this evening, so 
not tested yet. I was just curious if there was a reason for modifying 
all those files, or if left over from somewhere else.

As to binary compatibility, keeping the symlinks and modifying the 
linker path will clean those messages up, but also may not be necessary. 
I think just creating symlinks in a real /lib64 directory using both the 
real ld, and the appropriately named LSB one will do the job nicely (and 
same for /lib/ld-linux.so and /lib/ld-lsb-whatever.so.3 -> 
/lib32/ld-linux.so if you were to add multi-lib after the fact). There 
also might be some corner cases (?path) in binaries in the wild.

--DJ
-------------- next part --------------
diff -Naurp lfs-20160806/chapter05/binutils-pass1.xml lfs-20160806-no-lib64-symlinks/chapter05/binutils-pass1.xml
--- lfs-20160806/chapter05/binutils-pass1.xml	2016-05-31 21:52:10.639626000 -0500
+++ lfs-20160806-no-lib64-symlinks/chapter05/binutils-pass1.xml	2016-08-06 11:52:13.967870649 -0500
@@ -146,13 +146,6 @@ cd       build</userinput></screen>
     tests at this point are minimal since the programs from this
     first pass will soon be replaced by those from the second.</para>
 
-    <para>If building on x86_64, create a symlink to ensure the sanity of
-    the toolchain:</para>
-
-<screen><userinput remap="install">case $(uname -m) in
-  x86_64) mkdir -v /tools/lib && ln -sv lib /tools/lib64 ;;
-esac</userinput></screen>
-
     <para>Install the package:</para>
 
 <screen><userinput remap="install">make install</userinput></screen>
diff -Naurp lfs-20160806/chapter05/gcc-pass1.xml lfs-20160806-no-lib64-symlinks/chapter05/gcc-pass1.xml
--- lfs-20160806/chapter05/gcc-pass1.xml	2016-05-31 21:52:10.639626000 -0500
+++ lfs-20160806-no-lib64-symlinks/chapter05/gcc-pass1.xml	2016-08-07 04:00:37.783917765 -0500
@@ -68,19 +68,32 @@ mv -v mpc-&mpc-version; mpc</userinput><
     class="directory">/usr/include</filename> from GCC's include search path.
     Issue:</para>
 
-<screen><userinput remap="pre">for file in \
- $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
+<screen><userinput remap="pre">for file in gcc/config/{linux,i386/linux{,64}}.h
 do
   cp -uv $file{,.orig}
   sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
       -e 's@/usr@/tools at g' $file.orig > $file
+  case $(uname -m) in
+    x86_64)
+      sed -e 's@/lib/@/lib32/@g' \
+          -e 's@/lib64/@/lib/@g' -i $file
+    ;;
+  esac
   echo '
 #undef STANDARD_STARTFILE_PREFIX_1
 #undef STANDARD_STARTFILE_PREFIX_2
 #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
 #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
   touch $file.orig
-done</userinput></screen>
+done
+case $(uname -m) in
+  x86_64)
+    sed -e '/MULTILIB_OSDIRNAMES/s at lib\$@lib32$@' \
+        -e '/MULTILIB_OSDIRNAMES/s at lib64\$@lib$@' \
+        -e '/MULTILIB_OSDIRNAMES/s@,../lib\)@)@'  \
+        -i.orig gcc/config/i386/t-linux64
+  ;;
+esac</userinput></screen>
 
     <para>In case the above seems hard to follow, let's break it down a bit.
     First we find all the files under the <filename
diff -Naurp lfs-20160806/chapter05/gcc-pass2.xml lfs-20160806-no-lib64-symlinks/chapter05/gcc-pass2.xml
--- lfs-20160806/chapter05/gcc-pass2.xml	2016-05-31 21:52:10.639626000 -0500
+++ lfs-20160806-no-lib64-symlinks/chapter05/gcc-pass2.xml	2016-08-07 04:01:03.326047694 -0500
@@ -70,19 +70,32 @@ esac</userinput></screen>
     use the one installed in <filename
     class="directory">/tools</filename>.</para>
 
-<screen><userinput remap="pre">for file in \
- $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
+<screen><userinput remap="pre">for file in gcc/config/{linux,i386/linux{,64}}.h
 do
   cp -uv $file{,.orig}
   sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
       -e 's@/usr@/tools at g' $file.orig > $file
+  case $(uname -m) in
+    x86_64)
+      sed -e 's@/lib/@/lib32/@g' \
+          -e 's@/lib64/@/lib/@g' -i $file
+    ;;
+  esac
   echo '
 #undef STANDARD_STARTFILE_PREFIX_1
 #undef STANDARD_STARTFILE_PREFIX_2
 #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
 #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
   touch $file.orig
-done</userinput></screen>
+done
+case $(uname -m) in
+  x86_64)
+    sed -e '/MULTILIB_OSDIRNAMES/s at lib\$@lib32$@' \
+        -e '/MULTILIB_OSDIRNAMES/s at lib64\$@lib$@' \
+        -e '/MULTILIB_OSDIRNAMES/s@,../lib\)@)@'  \
+        -i.orig gcc/config/i386/t-linux64
+  ;;
+esac</userinput></screen>
 
     <para>As in the first build of GCC it requires the GMP, MPFR and MPC
     packages. Unpack the tarballs and move them into the required directory
diff -Naurp lfs-20160806/chapter06/creatingdirs.xml lfs-20160806-no-lib64-symlinks/chapter06/creatingdirs.xml
--- lfs-20160806/chapter06/creatingdirs.xml	2016-05-31 21:52:10.639626000 -0500
+++ lfs-20160806-no-lib64-symlinks/chapter06/creatingdirs.xml	2016-08-06 12:10:45.373547290 -0500
@@ -24,9 +24,7 @@ mkdir -v  /usr/libexec
 mkdir -pv /usr/{,local/}share/man/man{1..8}
 
 case $(uname -m) in
- x86_64) ln -sv lib /lib64
-         ln -sv lib /usr/lib64
-         ln -sv lib /usr/local/lib64 ;;
+ x86_64) mkdir -v /lib64 ;;
 esac
 
 mkdir -v /var/{log,mail,spool}
diff -Naurp lfs-20160806/chapter06/gcc.xml lfs-20160806-no-lib64-symlinks/chapter06/gcc.xml
--- lfs-20160806/chapter06/gcc.xml	2016-08-05 22:53:06.385717000 -0500
+++ lfs-20160806-no-lib64-symlinks/chapter06/gcc.xml	2016-08-07 04:02:54.410612533 -0500
@@ -45,6 +45,23 @@
 
 <screen><userinput remap="pre">patch -Np1 -i ../gcc-6.1.0-asan-1.patch</userinput></screen>
 
+    <para>If building on x86_64, change the default library path to
+    <filename>/lib,/usr/lib</filename>:</para>
+
+<screen><userinput remap="pre">case $(uname -m) in
+  x86_64)
+    for file in gcc/config/{linux,i386/linux{,64}}.h
+    do
+      sed -e 's@/lib/@/lib32/@g' \
+          -e 's@/lib64/@/lib/@g' -i $file
+    done
+    sed -e '/MULTILIB_OSDIRNAMES/s at lib\$@lib32$@' \
+        -e '/MULTILIB_OSDIRNAMES/s at lib64\$@lib$@' \
+        -e '/MULTILIB_OSDIRNAMES/s@,../lib\)@)@'  \
+        -i.orig gcc/config/i386/t-linux64
+  ;;
+esac</userinput></screen>
+
     <para>The GCC documentation recommends building GCC in a dedicated build directory:</para>
 
 <screen><userinput remap="pre">mkdir -v build
diff -Naurp lfs-20160806/chapter06/glibc.xml lfs-20160806-no-lib64-symlinks/chapter06/glibc.xml
--- lfs-20160806/chapter06/glibc.xml	2016-08-06 10:00:51.603661000 -0500
+++ lfs-20160806-no-lib64-symlinks/chapter06/glibc.xml	2016-08-07 02:42:16.572875078 -0500
@@ -57,6 +57,15 @@
 
 <screen><userinput remap="pre">patch -Np1 -i ../&glibc-fhs-patch;</userinput></screen>
 
+    <para>If building on x86_64, enusre that the <command>ldd</command> script
+    uses the dynamic linker in <filename>/lib</filename>:</para>
+
+<screen><userinput remap="pre">case $(uname -m) in
+  x86_64)
+    sed -i '/RTLDLIST/d' $(find ${srcdir}/ -name ldd-rewrite.sed)
+  ;;
+esac</userinput></screen>
+
     <para>The Glibc documentation recommends building Glibc 
     in a dedicated build directory:</para>
 
@@ -67,7 +76,8 @@ cd       build</userinput></screen>
 
 <screen><userinput remap="configure">../configure --prefix=/usr          \
              --enable-kernel=&min-kernel; \
-             --enable-obsolete-rpc</userinput></screen>
+             --enable-obsolete-rpc        \
+             libc_cv_slibdir=/lib</userinput></screen>
 
     <para>Compile the package:</para>
 
@@ -198,6 +208,15 @@ localedef -i zh_CN -f GB18030 zh_CN.GB18
     <filename>glibc-&glibc-version;/localedata/SUPPORTED</filename> file
     in the unlikely case you need them.</para>
 
+    <para>Finally, create symlinks for LSB compliance and a compatibility link
+    required by many binary programs:</para>
+
+<screen><userinput remap="install">case $(uname -m) in
+    x86_64) ln -s ../lib/ld-linux-x86-64.so.2 /lib64
+            ln -s ../lib/ld-linxu-x86-64.so.2 /lib64/ld-lsb-x86-64.so.3
+    ;;
+esac</userinput></screen>
+
   </sect2>
 
   <sect2 id="conf-glibc" role="configuration">


More information about the lfs-dev mailing list