[Guide] HowTo: Multilib LFS
I'm successfully make multilib LFS with a little modifications from original LFS book. So i'm gonna share it with anyone wanna try it or its gonna be future reference. All this method i got from https://www.williamfeely.info/lfs-multilib/ which i'm simplified it and some google around. I've been using this method few times to build my LFS based distro, so far wine and steam work great :)
First you gonna need make multilib toolchain (chapter 5) then make final system multilib (chapter 6). Affected package need change build command is binutils, glibc, gcc and libstdc++. At the end all 32bit libraries is placed in /usr/lib32 directory. On chapter 5, 1) binutils pass1, on configure cmd, replace: Code:
--with-lib-path=/tools/lib Code:
--with-lib-path=/tools/lib:/tools/lib32 Code:
mkdir -p /tools/lib32 Code:
case $(uname -m) in Code:
sed -i -e 's@/lib/ld-linux.so.2@/lib32/ld-linux.so.2@g' gcc/config/i386/linux64.h Code:
--disable-multilib Code:
--with-multilib-list=m32,m64 for 32bit lib build using this cmd: Code:
mkdir -v build32 Code:
echo 'int main(){}' > dummy.c Code:
[Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2] Code:
mkdir -v build32 5) binutils pass2, build like in the book then replace: Code:
make -C ld LIB_PATH=/usr/lib:/lib Code:
make -C ld LIB_PATH=/usr/lib:/lib:/usr/lib32:/lib32 Code:
case $(uname -m) in Code:
sed -i -e 's@/lib/ld-linux.so.2@/lib32/ld-linux.so.2@g' gcc/config/i386/linux64.h Code:
--disable-multilib Code:
--with-multilib-list=m32,m64 7) strip section, strip debugging symbols from 32bit libraries and remove libtool (*.la) files. Code:
strip --strip-debug /tools/lib32/* 1) glibc, for 64bit build, add to configure cmd: Code:
--enable-multi-arch --enable-obsolete-rpc Code:
mkdir -v ../build32 Code:
--enable-multilib --with-lib-path=/usr/lib:/lib:/usr/lib32 Code:
--enable-multilib for 64bit: Quote:
Quote:
Now you should have multilib LFS :D for future build of any 32bit lib should build using: Code:
CC="gcc -m32" \ some package in BLFS need modification to make it work with its 32 version side by side 1) python 64bit (both v2.7 and v3.7), rename pyconfig.h to pyconfig-64.h Code:
mv /usr/include/python2.7/pyconfig{,-64}.h Code:
/* pyconfig.h stub */ 2) llvm 64bit, rename llvm-config.h to llvm-config-64.h Code:
mv /usr/include/llvm/Config/llvm-config{,-64}.h Code:
#include <bits/wordsize.h> Code:
mv ../cfe-$version.src tools/clang for more 32bit package you can check here: https://github.com/emmett1/ports I hope someone can make it work too using this method. I already use this method many times but with my own script and package manager. Anyway, if you faced any problem you can check my script to bootstrap my distro here: https://github.com/emmett1/venom Or you can try out my LFS based distro which is used BSD-style init and port system for packages. Get the installable iso here: https://sourceforge.net/projects/venomlinux/ Edit: add sanity test result and strip symbols from 32bit libraries (/tools/lib32) |
Looks like a good job I'll give this a go when I get the chance, well done.
|
Pity I've just built my new LFS 8.4! It would have been nice to do it this way, then I could have used my printer, which has 32-bit filters, in LFS.
|
Quote:
|
Quote:
|
Thank you! I was seriously considering a complete new build on one of my spare partitions.
btw I think this thread should be a sticky. |
Quote:
I dont think you need complete rebuild, i already convert pure64 lfs to multilib before, so it should work. Quote:
|
OK, primary toolkit from chapter 5 completed. The sanity check in 5.7 is repeated in 5.10 with a slightly different syntax for the compilation step. You might want to include that in your instructions.
I plan to do the chapter 6 primary toolkit tomorrow. There are more detailed sanity tests there, which I assume must be carried out both with and without the -m32 option. Is there anything new that I need to know about running the "official" test suites on these packages? |
I've hit a snag, but I think I know what caused it. In the book (section 6.9) you are told to remove /usr/include/limits.h if it exists before building glibc. So I duly did. But the build then broke with this error:
Code:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include-fixed/syslimits.h:7, Think of me as the "naive user" who tests your instructions ;) PS: Yes, that's the directory that gives the fault. Here is the print-out from a -j1 build Code:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include-fixed/syslimits.h:7, |
It's just occurred to me. Since I have 64-bit gcc and binutils already installed on this partition, wouldn't they be used in preference to the multilib ones in /tools? Perhaps I need to have /tools/bin at the head of my path rather than at the tail?
|
Maybe you dont need that limits.h file when rebuild. I also faced this problem before, then i'm remove rm -f /usr/include/limits.h from my build script, since then everything just fine. Maybe the book should remove rm -f /usr/include/limits.h line, its obsolete.
Yeah maybe its caused by --enable-obsolete-rpc, you just play around a bit with it. My script still has it and build just fine. Ofcourse you need /tools/bin at the head of your path, not at the tail, so it will use toolchain in /tools/bin not other directory in your path. Quote:
|
I've found out what was wrong. The chroot instructions in the book assume an almost empty system, but mine already has a functioning root account with .bashrc and .bash_profile. So when I chrooted with "bash --login" those scripts were run and it mucked up my environment. That's why I didn't have the path set correctly. I have to set the correct environmental variables by hand, then it works. I've built the 64-bit version successfully and tested it. 4 tests failed and that's the same result as I got with the standard 64-bit glibc.
I'll install it, then build and test the 32-bit version next. |
You could also install subversion and do an SVN checkout of the book and apply this patch: https://io.ax.lt/LFS/lfs/patch-multilib-SVN.diff (apply it like any other patch: cd BOOK && patch -p1 -i ../That-Patch. Read carefully the two files in there about what you need to render the book to html. Now you have an "official" un-official version of LFS for multilib.
I did that for LFS-svn 20190301 (i wanted the gcc-8.3 compiler update). I haven't compiled all programs with the new compiler, but I've compiled many (including all of KDE) with no problems. My 32-bit brother printer driver now work with LFS - finally. Arch AUR has a PKGBUILD for my printer (hl2240d) but it didn't work right (margins off). Instead i just ran the scripts from the RPM after installing the drivers. That version of the book will also include x32 support (subset of x86_64 architecture). I suppose you could omit that part - it's interesting but not really practical now. I went ahead and included it, so i have usr/lib, usr/lib32, and usr/libx32 for libraries. |
1 Attachment(s)
You don't mention running any tests on the software apart from the LFS sanity tests. I ran the glibc package tests on both the 32-bit and 64-bit libraries; the results for 64-bit were exactly the same as when building from the book, but the 32-bit library failed a lot of tests. I'm attaching the relevant part of the log for interest.
Most of the failures (114 out of 142) are in nptl, the threads library, which is probably not relevant for running a small simple program like a printer driver. It doesn't look good though if you want full multilib capacity. Postscript: Sanity checks yield two additional SEARCH_DIR entries compared with the Book: /lib32 and /usr/lib32. The latter I expected but I'm surprised to find /lib32, a directory that doesn't actually exist. |
Toolchain complete. Both binutils and gcc passed all the expected tests in their respective test suites. But in carrying out the final sanity tests, I found one significant difference from the Book: in the search directories from both the 32-bit and 64-bit dummy compilations, the directories /lib64 and /usr/lib64 were missing. Now this makes a kind of sense because /lib64 contains no libraries, only linkers, and /usr/lib64 doesn't actually exist. All the same, it is a difference and I think you should include this in any final write-up of instructions.
The real test of course is if I can get my printer to work and I won't know that until I have installed cups. |
All times are GMT -5. The time now is 02:28 PM. |