Linux From Scratch is a guide meant to cover how a basic Linux System works, and how to install the very bare minimum (close to the very bare minimum, but not quite, as some packages aren't necessary in my opinion) amount of packages to get a bootable, working system, primed to be able to go forward from there and continue onto the next guide, Beyond Linux From Scratch. BLFS covers many packages for nearly everyone, except, well, gamers and those that can't do Linux without some Windows software which runs fine on Linux under Wine.
So what's the option for people like them? Going off-roading!
I would like to note that getting Steam and Wine to work on LFS are two different tasks, but I recommend installing most of the packages (as well as the lib32 versions) listed in the Steam section if you are doing a multilib installation (more on that later) if you intend to just install Wine and skip Steam. Some packages not even including multilib are still necessary for Wine to even compile, like having a display server and having OpenGL (either MESA or libglvnd). For this sake, I'll cover Steam first, then Wine. If you just wanna use Steam and be done with it, you can just skip anything covered in the Wine section. In other words, when you're done with the Steam section, you're done.
Most people following this guide should be using an x86_64 CPU and is capable of emulating 32-bit applications. In that case, Steam will complain that it cannot find the 32-bit version of libc.so.6 if you skip the lib32 branches. Please don't do this and install both the 64-bit and 32-bit versions of the packages I will lay out if you are following the Steam section. Wine users, some applications are 32-bit only, so I recommend following the lib32 branches as well. Users who just have an i*86 CPU should follow the 64-bit instructions as the instructions for you will just compile for i*86, i686 in most cases. If you have trouble following those instructions for your arch, I recommend taking a look at https://linuxfromscratch.org/blfs/view/stable and the packages listed on there that are on here. Most if not all of the packages one here (besides Steam, Wine, and the Mingw-w64 toolchain) are also on BLFS.
Those that have decided, or couldn't decide due to their architecture and Steam's requirement, that they want/need to have multilib support, it would be wise to test if you have that support or not:
echo "int main(){}" >> dummy.c
gcc -m32 dummy.c
./a.out
The output of said command should be:
Well... nothing! If there is no error, then you can both compile 32-bit binaries like executables and libraries, and also execute them. If so, you can skip this section and go to the sections you need. For most people, I would hazard a guess that the first error started when gcc -m32
was ran, which means GCC doesn't have 32-bit compilation support. Follow the proceding instructions to get multilib support.
The best resource to get general multilib support is https://linuxfromscratch.org/~thomas/multilib. This is essentially the LFS guide but with multilib. Personally, what I do is I build LFS with multilib support in mind. There probably is a way to get that support without rebuilding but I don't do this. If you want to try, be my guest. As for the guide, it has a couple issues I have found. I will rattle them off along as I go.
x32 is a format that is essentially 32-bit with some of the advantages of 64-bit. Most desktop applications don't support this and is basically useless for Steam and Wine users. Almost no-one ever uses it and I recommend against installing x32. I will cover how not to get that support as it's not needed. As a general rule, there are some packages that have the following sections: a 64-bit compilation step, a 32-bit compilation step, and a x32-bit compilation step. The x32-bit compilation steps can be skipped entirely.
mkdir -pv $LFS/usr/lib{,x}32
Should be changed to:
ln -sv usr/lib32 $LFS/lib32
ln -sv usr/libx32 $LFS/libx32
mkdir -pv $LFS/usr/lib32
ln -sv usr/lib32 $LFS/lib32
chown -v lfs $LFS/{lib32,libx32}
Should be changed to:
chown -v lfs $LFS/lib32
cat > ~/.bashrc << "EOF"
Should be changed to:
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
LFS_TGT=x86_64-lfs-linux-gnu
LFS_TGT32=i686-lfs-linux-gnu
LFS_TGTX32=x86_64-lfs-linux-gnux32
PATH=/usr/bin
if [ ! -L /bin ]; then PATH=/bin:$PATH; fi
PATH=$LFS/tools/bin:$PATH
CONFIG_SITE=$LFS/usr/share/config.site
export LFS LC_ALL LFS_TGT LFS_TGT32 LFS_TGTX32 PATH
EOF
cat > ~/.bashrc << "EOF"
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
LFS_TGT=x86_64-lfs-linux-gnu
LFS_TGT32=i686-lfs-linux-gnu
PATH=/usr/bin
if [ ! -L /bin ]; then PATH=/bin:$PATH; fi
PATH=$LFS/tools/bin:$PATH
CONFIG_SITE=$LFS/usr/share/config.site
export LFS LC_ALL LFS_TGT LFS_TGT32 PATH
EOF
With the current instructions, and this isn't just involving multilib, nscd is no longer necessary but the configure command for me always found a way to still build nscd. Therefore, I recommend including in the configure command with all passes:
--disable-nscd
I would put that in the libstdc++ configure command as well for good measure...
As for the multilib, it has the user define the env variable: mlist, and it is defined like so:
mlist=m64,m32,mx32 ../configure ...
But it should be changed to:
mlist=m64,m32 ../configure ...
Don't execute the following command if you want to avoid an error (the directory shouldn't be there), unless you like errors:
chown -R root:root $LFS/libx32
When enabling binary emulation in the Linux kernel, don't enable x32 ABI for 64-bit mode [CONFIG_X86_X32]
.
That covers the no x32-bit subsection.
lib32-GDBM is needed by some desktop packgages that you are trying to compile lib32 for, so it's a good idea to compile it so you don't need to go back later:
That covers the lib32-GDBM compilation subsection and issues with the multilib LFS guide.
CC="gcc -m32" CXX="g++ -m32" \
./configure --prefix=/usr \
--libdir=/usr/lib32 \
--disable-static \
--enable-libgdbm-compat
make
make DESTDIR=$PWD/DESTDIR install
cp -vr DESTDIR/usr/lib32/* /usr/lib32
rm -rf DESTDIR
Well, you are done with getting the tools you need for lib32 compilation and are ready for the Steam and/or Wine sections of this guide. As a general rule, this command format will compile the lib32 libraries for you:
It would be wise to also check to see if the libraries you just compiled are 32-bit, and that can be done using file. If you don't check it and it ends up being 64-bit, the package you try to compile for 32-bit that depends on the previous package will error out during the linking step because the dependency library is in an invalid format. A simple library being 64 bit in the lib32 directory won't break your system but you'll need to fix the issue before you can compile packages that depend on it.
CC="gcc -m32" CXX="g++ -m32" PKG_CONFIG_PATH=/usr/lib32/pkgconfig [configure/meson/cmake...] ... --libdir=/usr/lib32
[make / ninja]
[make DESTDIR=$PWD/DESTDIR install] / [DESTDIR=$PWD/DESTDIR ninja install]
cp -vr DESTDIR/usr/lib32/* /usr/lib32