Created rough version of Multilib chapter and modified precursor parts

This commit is contained in:
Zeckmathederg 2024-04-17 09:03:42 -06:00
parent 33c96e4650
commit 0e01e1b689
11 changed files with 507 additions and 0 deletions

View File

@ -15,6 +15,7 @@ $Date$
<!-- Parts -->
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="introduction/introduction.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="multilib/multilib.xml"/>
<!-- Appendices -->
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="appendices/creat-comm.xml"/>

View File

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../../general.ent">
%general-entities;
]>
<sect1 id="important" xreflabel="Important Information">
<?dbhtml filename="important.html"?>
<title>Important Information</title>
<para>
BLFS has more information regarding compilation, /usr vs /usr/local,
boot scripts, etc. at
<ulink url="https://linuxfromscratch.org/blfs/view/stable/introduction/important.html"/>.
Unlike this book, this would be a chapter in BLFS.
A lot of that information has been omitted as this book is more linear
and doesn't follow how BLFS follows. However, we will cover some bases
here.
</para>
<sect2>
<title>Building software</title>
<para>
Building software on BLFS-Next is identical to how it's done in the
BLFS books, along with having lib32 compilation instructions. It
goes without saying firstmost that you should have <envar>MAKEFLAGS</envar>
set to save yourself a lot of time. This is useful for the <command>make
</command> utility to use the amount of threads that you both want
and have.
</para>
<screen><userinput>export MAKEFLAGS='-jx'</userinput></screen>
<para>
Replace <option>x</option> with the amount of threads you have.
You can check the amount of threads you have with:
</para>
<screen><userinput>grep processor /proc/cpuinfo</userinput></screen>
<important><para>
Make sure that you have enough RAM for your system!
A general method is having 2.5G per thread that is thrown at
<command>make</command>. For instance, if you want to use 6 threads,
multiply 6 by 2.5 (which is 15), then make sure you have 15G of RAM.
If you don't have that RAM, try and limit the threads you throw at
<command>make</command>.
</para></important>
<para>
Next is compiling for 32-bit. There are many packages which will have
a lib32 counterpart. If you just got done with a normal compilation
of a package and wish to do a 32-bit compilation of that same package,
make sure to clean the directory first:
</para>
<screen><userinput>make distclean</userinput></screen>
<para>Or, if you made a build directory:</para>
<screen><userinput>rm -rf build</userinput></screen>
<para>Then proceed with the 32-bit compilation instructions.</para>
<para>
Generally, the format of targetting 32-bit goes like this:
</para>
<para>For <command>./configure</command>:</para>
<screen><userinput>CC="gcc -m32" CXX="g++ -m32" PKG_CONFIG_PATH=/usr/lib32/pkgconfig \
./configure --prefix=/usr --libdir=/usr/lib32 \
--host=i686-pc-linux-gnu
make
make DESTDIR=$PWD/DESTDIR install
cp -vr DESTDIR/usr/lib32/* /usr/lib32
rm -rf DESTDIR
ldconfig
</userinput></screen>
<para>For <command>meson</command>:</para>
<screen><userinput>mkdir -v build
cd build
CC="gcc -m32" CXX="g++ -m32" PKG_CONFIG_PATH=/usr/lib32/pkgconfig \
meson setup .. --prefix=/usr --libdir=/usr/lib32
ninja
DESTDIR=$PWD/DESTDIR ninja install
cp -vr DESTDIR/usr/lib32/* /usr/lib32
rm -rf DESTDIR
ldconfig</userinput></screen>
<para>For <command>cmake</command>:</para>
<screen><userinput>export CFLAGS="-m32"
export CXXFLAGS="-m32"
export ASFLAGS="--32"
export PKG_CONFIG_PATH="/usr/lib32/pkgconfig"
mkdir -v build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib32
make
make DESTDIR=$PWD/DESTDIR install
cp -vr DESTDIR/usr/lib32/* /usr/lib32
rm -rf DESTDIR
ldconfig
unset CFLAGS CXXFLAGS ASFLAGS PKG_CONFIG_PATH</userinput></screen>
<note>
<para>
After you do a DESTDIR installation, it is recommended to
to use <command>file</command> on one of the libraries in
<filename>DESTDIR/usr/lib32</filename>. An output of such
a command for a 32-bit build of a library should be
comparable to the following:
</para>
<screen><computeroutput>ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked</computeroutput></screen>
<para>
Note the <computeroutput>32-bit LSB shared object</computeroutput> part.
A 64-bit library would show as a <computeroutput>64-bit LSB shared
object</computeroutput>.
</para>
</note>
</sect2>
</sect1>

View File

@ -34,5 +34,6 @@
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="askhelp.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="credits.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="contact.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="important.xml"/>
</chapter>

46
multilib/achievingml.xml Normal file
View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../general.ent">
%general-entities;
]>
<sect1 id="achievingml" xreflabel="Achieving Multilib">
<?dbhtml filename="achievingml.html"?>
<title>Achieving Multilib</title>
<para>
On many distros, getting multilib support is very straight
forward. There exists a guide that can act as a replacement
for LFS: compiling and configuring a system that can boot,
run, and compile software; and also have that same ability
with 32-bit. It acts to form the basis that will allow you
to follow any of the instructions laid out in the Steam
and Wine chapters.
</para>
<para>
Such a guide is maintained by Thomas Trepl at
<ulink url="https://www.&lfs-domainname;/~thomas/multilib/"/>.
It is very comprehensive and also covers how to get x32-bit
support, a format that is 32-bit with bigger registers. Such
a format is unnecessary. Most applications that is covered here
either don't: support it, require it, or is simply not necessary
to compile for, for any sort of interest. Therefore, any mention
of x32-bit, x32, mx32, and x32-bit instructions can be skipped.
Most users will not need it and the extra support in the compilers
and libraries on the system will serve as dead weight, taking up
disk space.
</para>
<para>
The same principles of compiling for 32-bit in that book will also
apply to this book as well. If you haven't already, read
<xref linkend="important"/>
to check what basic principles still apply in this book when targeting
32-bit.
</para>
</sect1>

24
multilib/coveringml.xml Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../general.ent">
%general-entities;
]>
<chapter id="coveringml">
<?dbhtml filename="coveringml.html"?>
<title>Covering Multilib</title>
<para>
In this chapter, we cover multilib, from explaining what it is,
if you need it, and how to get multilib support. Please do not
skip this chapter and read through most of it carefully.
</para>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="whatisml.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="needml.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="achievingml.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="pkgconf.xml"/>
</chapter>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE part PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../general.ent">
%general-entities;
]>
<part id="multilib" xreflabel="Multilib">
<?dbhtml filename="multilib.html" dir="multilib"?>
<title>Multilib</title>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="coveringml.xml"/>
</part>

90
multilib/needml.xml Normal file
View File

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../general.ent">
%general-entities;
]>
<sect1 id="needml" xreflabel="Do I Need Multilib?">
<?dbhtml filename="needml.html"?>
<title>Do I Need Multilib?</title>
<para>
If you have a CPU that is capable of multilib, it is time
to decide whether to go for it or not. Depending on the
circumstance, it may be necessary to go for it.
</para>
<sect2>
<title>Steam</title>
<para>
Most gamers would not know this unless they push the
limits of the game they play, but many games on Steam
are 32-bit. Some games are no longer receiving updates
while some are still being updated but are still 32-bit
to this day. A good example of this is Geometry Dash,
the developer of GD, RobTop, made plans to switch to
64-bit, but that hasn't come to fruition yet, and thus
leads to many issues such as online levels having too
many objects that require a big amount of RAM but the
32-bit application can't use that much RAM, which
results in a crash.
</para>
<para>
Not only are a lot of games 32-bit, but Steam itself
requires that you have 32-bit libraries. If the 32-bit
libraries aren't on the system, Steam will quit, saying
it needs a library, libc.so.6 being the most common
example. So if you have a 64-bit CPU, you will need the
ability to execute 32-bit applications as well as all the
libraries necessary which is laid out in Chapter 3.
</para>
<para>
If you have a 32-bit CPU, you can skip the 32-bit libraries
and compile everything normally as they will build for your
architecture.
</para>
<important>
<para>
Steam will eventually kill off 32-bit CPU support so be wary
that while you can run Steam with a 32-bit CPU, in the future
perhaps sometime soon, you will no longer be able to do this.
</para>
</important>
</sect2>
<sect2>
<title>Wine</title>
<para>
Unlike Steam, Wine does not require that you have 32-bit libraries
or the i686-w64-mingw32 toolchain. Moreover, to get multilib
support in Wine, it must be compiled twice: a w64 build and a w32
w/ w64 build. However, it was discussed eariler in the Steam
section that many games are 32-bit and are no longer maintained or
will take a while to switch to 64-bit. This is the case with
Windows applications as well. This means that if you do a 64-bit
only build, compatabilty for all those 32-bit applications will
be lost.
</para>
<para>
A Wine WoW64 (can run 32-bit and 64-bit applications) build is
recommended. If you do not have a 64-bit CPU, then follow only
the i686 build instructions. Likewise, if you have a 64-bit
CPU, then you can follow only the x86_64 build instructions.
The mingw-w64 toolchain is also really helpful for developers,
so if you don't want full support with Wine but full support
for the mingw-w64 toolchain, then by all means: go for it.
</para>
</sect2>
</sect1>

99
multilib/pkgconf.xml Normal file
View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../general.ent">
%general-entities;
]>
<sect1 id="pkgconf" xreflabel="Pkgconf Personalties">
<?dbhtml filename="pkgconf.html"?>
<title>Pkgconf Personalties</title>
<para>
The <command>pkgconf</command> compilation in the multilib
mirror does not cover <command>pkgconf</command> personalities
which are needed for some lib32 variants of packages such as
Gstreamer. This part is not necessary if you only intend to
follow the Steam chapter and not the Wine chapter.
</para>
<para>
The <command>pkgconf</command> personalities allow for
<command>pkgconf</command> to be ran without having to specify
the pkgconfig path.
</para>
<sect2>
<title>Creating the personalites</title>
<para>
Create the following personalties as the
<systemitem class="username">root</systemitem>
user:
</para>
<screen role="root"><userinput>mkdir -v /usr/share/pkgconfig/personality.d
cat &gt; /usr/share/pkgconfig/x86_64-pc-linux-gnu.personality &lt;&lt; "EOF"
<literal>Triplet: x86_64-pc-linux-gnu
SysrootDir: /
DefaultSearchPaths: /usr/lib/pkgconfig:/usr/share/pkgconfig
SystemIncludePaths: /usr/include
SystemLibraryPaths: /usr/lib</literal>
EOF
cat &gt; /usr/share/pkgconfig/i686-pc-linux-gnu.personality &lt;&lt; "EOF"
<literal>Triplet: i686-pc-linux-gnu
SysrootDir: /
DefaultSearchPaths: /usr/lib32/pkgconfig:/usr/share/pkgconfig
SystemIncludePaths: /usr/include
SystemLibraryPaths: /usr/lib32</literal>
EOF</userinput></screen>
<para>
Again as the <systemitem class="username">root</systemitem> user,
create the symlinks that enable pkgconf to find the personalites:
</para>
<screen role="root"><userinput>ln -sv pkgconf /usr/bin/x86_64-pc-linux-gnu-pkg-config
ln -sv pkgconf /usr/bin/i686-pc-linux-gnu-pkg-config</userinput></screen>
<para>
Now verify that the x86_64 pkg-config is using the right
personality:
</para>
<screen><userinput>x86_64-pc-linux-gnu-pkg-config --dump-personality</userinput></screen>
<para>
The result should be:
</para>
<screen><computeroutput>Triplet: x86_64-pc-linux-gnu
SysrootDir: /
DefaultSearchPaths: /usr/lib/pkgconfig /usr/share/pkgconfig
SystemIncludePaths: /usr/include
SystemLibraryPaths: /usr/lib</computeroutput></screen>
<para>
Then verify the i686 pkg-config is using the right personality:
</para>
<screen><userinput>i686-pc-linux-gnu-pkg-config --dump-personality</userinput></screen>
<para>
The result should be:
</para>
<screen><computeroutput>Triplet: i686-pc-linux-gnu
SysrootDir: /
DefaultSearchPaths: /usr/lib32/pkgconfig /usr/share/pkgconfig
SystemIncludePaths: /usr/include
SystemLibraryPaths: /usr/lib32</computeroutput></screen>
</sect2>
</sect1>

64
multilib/whatisml.xml Normal file
View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../general.ent">
%general-entities;
]>
<sect1 id="whatisml" xreflabel="What is Multilib?">
<?dbhtml filename="whatisml.html"?>
<title>What is Multilib?</title>
<para>
Multilib is essentially the ability to at least execute software
that was built for another architecture different from your own.
For example, and most common: the user has a x86_64 CPU that is
wanting to execute software built to run on a x86 CPU. To better
establish terms, x86_64 is 64-bit and amd64, whereas x86 is
32-bit and ix86 where <option>x</option> can vary from 3 to 6
usually.
</para>
<sect2>
<title>How Does it Work?</title>
<para>
Multilib can be achieved firstmost by having the hardware
capable of x86 emulation, then having libraries built for x86.
We will get into how to compile x86 libraries and software and
their execution later, but know the general process for LFS
and BLFS is to almost always compile software and that's what
we'll be doing.
</para>
<note>
<para>
It is worth nothing that when covering multilib, we mean
emulation of 32-bit software on a 64-bit CPU and this
is the case for most users nowadays, but the future is heading
towards ARM64 slowly. We will not be covering ARM at this time.
</para>
</note>
</sect2>
<sect2>
<title>Am I Capable of Multilib?</title>
<para>
If you are on a 32-bit CPU, you are not capable of multilib.
If you are on a 64-bit CPU, and are capable of 32-bit emulation,
then you are capable of multilib.
</para>
<para>
Run <command>uname -m</command> to find out if you are on a
capable CPU.
</para>
</sect2>
</sect1>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE part PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../general.ent">
%general-entities;
]>
<part id="introduction" xreflabel="Introduction">
<?dbhtml filename="introduction.html" dir="introduction"?>
<title>Introduction</title>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="welcome/welcome.xml"/>
</part>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE part PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../general.ent">
%general-entities;
]>
<part id="introduction" xreflabel="Introduction">
<?dbhtml filename="introduction.html" dir="introduction"?>
<title>Introduction</title>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="welcome/welcome.xml"/>
</part>