glfs/multilib/mesonfiles.xml
2024-10-20 16:41:32 -06:00

146 lines
4.2 KiB
XML

<?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="mesonfiles" xreflabel="Meson Toolchain Files">
<?dbhtml filename="mesonfiles.html"?>
<title>Meson Toolchain Files</title>
<sect2>
<title>Introduction to Meson Toolchain Files</title>
<para>
Most applications that rely on the <application>Meson</application>
build system have decent support for cross compilation, ie. compiling
32-bit binaries on a 64-bit system. It can be as easy as setting the
<envar>CC</envar>, <envar>CXX</envar>, and <envar>PKG_CONFIG_PATH
</envar> variables before using the <userinput>meson setup ..
</userinput> command to compile 32-bit binaries on a 64-bit system.
However, some projects are more complicated for many different
reasons, leading to the necessity of <application>Meson
</application> toolchain files. They specify compilers,
options that should be invoked, the <application>pkg-conf</application>
binary (or rather symlink that uses a certain personality file) to use,
<command>llvm-config</command> to use, etc. This is required for Mesa's
Nouveau and/or Swrast Vulkan drivers. It is also needed for Gstreamer
(not in the book), which is a recommended dependency of
<xref linkend="wine"/>. It can also turn into a requirement for various
packages if you are wanting to upgrade packages using Meson and you are
wanting to install 32-bit versions of those packages.
</para>
<para>
There are two <application>Meson</application> files: the cross
toolchain file and the native toolchain file. There are different situations
for using either.
</para>
<bridgehead renderas="sect3">Meson Toolchain File Dependencies</bridgehead>
<bridgehead renderas="sect4">Required</bridgehead>
<para role="required">
<xref linkend="pkgconf"/> (runtime)
</para>
</sect2>
<sect2 role="installation">
<title>Creating the Cross Toolchain File</title>
<para>
Create the following toolchain file by running the following
commands as the <systemitem class="username">root</systemitem>
user:
</para>
<screen role="root"><userinput>mkdir -pv /usr/share/meson/cross
cat &gt; /usr/share/meson/cross/lib32 &lt;&lt; "EOF"
<literal>[binaries]
c = ['gcc', '-m32']
cpp = ['g++', '-m32']
rust = ['rustc', '--target', 'i686-unknown-linux-gnu']
pkg-config = 'i686-pc-linux-gnu-pkg-config'
ar = '/usr/bin/ar'
strip = '/usr/bin/strip'
cups-config = 'cups-config'
llvm-config = 'llvm-config'
exe_wrapper = ''
[properties]
sizeof_void* = 4
sizeof_long = 4
[host_machine]
system = 'linux'
subsystem = 'linux'
kernel = 'linux'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'</literal>
EOF</userinput></screen>
</sect2>
<sect2 role="installation">
<title>Creating the Native Toolchain File</title>
<para>
Create the following toolchain file by running the following
commands as the <systemitem class="username">root</systemitem>
user:
</para>
<screen role="root"><userinput>mkdir -pv /usr/share/meson/native
cat &gt; /usr/share/meson/native/x86 &lt;&lt; "EOF"
<literal>[binaries]
c = ['gcc', '-m32']
cpp = ['g++', '-m32']
rust = ['rustc', '--target', 'i686-unknown-linux-gnu']
pkg-config = 'i686-pc-linux-gnu-pkg-config'
ar = '/usr/bin/ar'
strip = '/usr/bin/strip'
cups-config = 'cups-config'
llvm-config = 'llvm-config'
exe_wrapper = ''
[properties]
sizeof_void* = 4
sizeof_long = 4
[host_machine]
system = 'linux'
subsystem = 'linux'
kernel = 'linux'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'</literal>
EOF</userinput></screen>
</sect2>
<sect2>
<title>How to Use the File</title>
<para>
Instead of setting environment variables before invoking
<userinput>meson setup ..</userinput>, you can simply do:
</para>
<screen><userinput>meson setup .. --cross-file lib32 &lt;other-options&gt;</userinput></screen>
<para>
Or...
</para>
<screen><userinput>meson setup .. --native-file x86 &lt;other-options&gt;</userinput></screen>
</sect2>
</sect1>