docs: Update the "building GLib" section

The content has slowly gone out of sync with the implementation, and
some of it is also showing its age.
This commit is contained in:
Emmanuele Bassi 2018-01-01 13:48:46 +00:00
parent b1c7d2433f
commit 8ade1af707

View File

@ -43,7 +43,7 @@
</para> </para>
<para> <para>
The GTK+ documentation contains The GTK+ documentation contains
<ulink url="../gtk/gtk-building.html">further details</ulink> <ulink url="https://developer.gnome.org/gtk3/stable/gtk-building.html">further details</ulink>
about the build process and ways to influence it. about the build process and ways to influence it.
</para> </para>
</refsect1> </refsect1>
@ -52,26 +52,23 @@
<para> <para>
Before you can compile the GLib library, you need to have Before you can compile the GLib library, you need to have
various other tools and libraries installed on your system. various other tools and libraries installed on your system.
Beyond a C compiler (which must implement C90, but does not need If you are building from a release archive, you will need
to implement C99), the two tools needed during the build process <ulink url="https://wiki.gnome.org/Projects/GLib/CompilerRequirements">a compliant C toolchain</ulink>,
(as differentiated from the tools used in when creating GLib GNU Make, and <application>pkg-config</application>;
mentioned above such as <application>autoconf</application>) are if you are building directly from a Git repository clone
<command>pkg-config</command> and GNU make. of GLib, you will also need the GNU Autotools mentioned
above.
</para> </para>
<itemizedlist> <itemizedlist>
<listitem> <listitem>
<para> <para>
<ulink url="http://www.freedesktop.org/software/pkgconfig/">pkg-config</ulink> <ulink url="https://www.freedesktop.org/wiki/Software/pkg-config/">pkg-config</ulink>
is a tool for tracking the compilation flags needed for is a tool for tracking the compilation flags needed for
libraries that are used by the GLib library. (For each libraries that are used by the GLib library. (For each
library, a small <literal>.pc</literal> text file is library, a small <literal>.pc</literal> text file is
installed in a standard location that contains the compilation installed in a standard location that contains the compilation
flags needed for that library along with version number flags needed for that library along with version number
information.) The version of <command>pkg-config</command> information).
needed to build GLib is mirrored in the
<filename>dependencies</filename> directory
on the <ulink url="ftp://ftp.gtk.org/pub/gtk/v2.2/">GTK+ FTP
site.</ulink>
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
@ -107,7 +104,7 @@
<para> <para>
If your system has an <function>iconv()</function> implementation but If your system has an <function>iconv()</function> implementation but
you want to use libiconv instead, you can pass the you want to use libiconv instead, you can pass the
--with-libiconv option to configure. This forces <option>--with-libiconv</option> option to configure. This forces
libiconv to be used. libiconv to be used.
</para> </para>
<para> <para>
@ -151,20 +148,21 @@
<listitem> <listitem>
<para> <para>
GRegex uses the <ulink url="http://www.pcre.org/">PCRE library</ulink> GRegex uses the <ulink url="http://www.pcre.org/">PCRE library</ulink>
for regular expression matching. The default is to use the internal for regular expression matching. The default is to use the system
version of PCRE that is patched to use GLib for memory management version of PCRE, to reduce the chances of security fixes going out
and Unicode handling. If you prefer to use the system-supplied PCRE of sync. GLib additionally provides an internal copy of PCRE in case
library you can pass the <option>--with-pcre=system</option> option the system version is too old, or does not support UTF-8; the internal
to, but it is not recommended. copy is patched to use GLib for memory management and to share the
same Unicode tables.
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
The optional extended attribute support in GIO requires the The optional extended attribute support in GIO requires the
getxattr() family of functions that may be provided by glibc or <function>getxattr()</function> family of functions that may be
by the standalone libattr library. To build GLib without extended provided by the C library or by the standalone libattr library. To
attribute support, use the <option>--disable-xattr</option> build GLib without extended attribute support, use the
option. <option>--disable-xattr</option> option.
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
@ -187,7 +185,9 @@
The optional support for The optional support for
<ulink url="http://sourceware.org/systemtap/">SystemTap</ulink> <ulink url="http://sourceware.org/systemtap/">SystemTap</ulink>
can be disabled with the <option>--disable-systemtap</option> can be disabled with the <option>--disable-systemtap</option>
configure option. configure option. Additionally, you can control the location
where GLib installs the SystemTap probes, using the
<option>--with-tapset-install-dir=DIR</option> configure option.
</para> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
@ -203,15 +203,16 @@
</para> </para>
<formalpara> <formalpara>
<title><systemitem>--enable-debug</systemitem></title> <title><option>--enable-debug</option></title>
<para> <para>
Turns on various amounts of debugging support. Setting this to 'no' Turns on various amounts of debugging support. Setting this to 'no'
disables g_assert(), g_return_if_fail(), g_return_val_if_fail() and disables <function>g_assert()</function>, <function>g_return_if_fail()</function>,
all cast checks between different object types. Setting it to 'minimum' disables only cast checks. Setting it to 'yes' enables <function>g_return_val_if_fail()</function> and all cast checks
<link linkend="G-DEBUG:CAPS">runtime debugging</link>. between different object types. Setting it to 'minimum' disables
The default is 'minimum'. only cast checks. Setting it to 'yes' enables <link linkend="G-DEBUG:CAPS">runtime debugging</link>.
Note that 'no' is fast, but dangerous as it tends to destabilize The default is 'minimum' for stable releases, and 'yes' for development
snapshots. Note that 'no' is fast, but dangerous as it tends to destabilize
even mostly bug-free software by changing the effect of many bugs even mostly bug-free software by changing the effect of many bugs
from simple warnings into fatal crashes. Thus from simple warnings into fatal crashes. Thus
<option>--enable-debug=no</option> should <emphasis>not</emphasis> <option>--enable-debug=no</option> should <emphasis>not</emphasis>
@ -220,26 +221,26 @@
</formalpara> </formalpara>
<formalpara> <formalpara>
<title><systemitem>--disable-gc-friendly</systemitem> and <title><option>--disable-gc-friendly</option> and
<systemitem>--enable-gc-friendly</systemitem></title> <option>--enable-gc-friendly</option></title>
<para> <para>
By default, and with <systemitem>--disable-gc-friendly</systemitem> By default, and with <option>--disable-gc-friendly</option>
as well, Glib does not clear the memory for certain objects before as well, GLib does not clear the memory for certain objects before
they are freed. For example, Glib may decide to recycle GList nodes they are freed. For example, GLib may decide to recycle GList nodes
by putting them in a free list. However, memory profiling and debugging by putting them in a free list. However, memory profiling and debugging
tools like <ulink url="http://www.valgrind.org">Valgrind</ulink> work tools like <ulink url="http://www.valgrind.org">Valgrind</ulink> work
better if an application does not keep dangling pointers to freed better if an application does not keep dangling pointers to freed
memory (even though these pointers are no longer dereferenced), or memory (even though these pointers are no longer dereferenced), or
invalid pointers inside uninitialized memory. invalid pointers inside uninitialized memory.
The <systemitem>--enable-gc-friendly</systemitem> option makes Glib The <option>--enable-gc-friendly</option> option makes GLib
clear memory in these situations: clear memory in these situations:
</para> </para>
<itemizedlist> <itemizedlist>
<listitem> <listitem>
<para> <para>
When shrinking a GArray, Glib will clear the memory no longer When shrinking a GArray, GLib will clear the memory no longer
available in the array: shrink an array from 10 bytes to 7, and available in the array: shrink an array from 10 bytes to 7, and
the last 3 bytes will be cleared. This includes removals of single the last 3 bytes will be cleared. This includes removals of single
and multiple elements. and multiple elements.
@ -247,7 +248,7 @@
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
When growing a GArray, Glib will clear the new chunk of memory. When growing a GArray, GLib will clear the new chunk of memory.
Grow an array from 7 bytes to 10 bytes, and the last 3 bytes will Grow an array from 7 bytes to 10 bytes, and the last 3 bytes will
be cleared. be cleared.
</para> </para>
@ -259,14 +260,14 @@
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
When freeing a node from a GHashTable, Glib will first clear When freeing a node from a GHashTable, GLib will first clear
the node, which used to have pointers to the key and the value the node, which used to have pointers to the key and the value
stored at that node. stored at that node.
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
When destroying or removing a GTree node, Glib will clear the node, When destroying or removing a GTree node, GLib will clear the node,
which used to have pointers to the node's value, and the left and which used to have pointers to the node's value, and the left and
right subnodes. right subnodes.
</para> </para>
@ -275,13 +276,13 @@
<para> <para>
Since clearing the memory has a cost, Since clearing the memory has a cost,
<systemitem>--disable-gc-friendly</systemitem> is the default. <option>--disable-gc-friendly</option> is the default.
</para> </para>
</formalpara> </formalpara>
<formalpara> <formalpara>
<title><systemitem>--disable-mem-pools</systemitem> and <title><option>--disable-mem-pools</option> and
<systemitem>--enable-mem-pools</systemitem></title> <option>--enable-mem-pools</option></title>
<para> <para>
Many small chunks of memory are often allocated via collective pools Many small chunks of memory are often allocated via collective pools
@ -321,7 +322,7 @@
</formalpara> </formalpara>
<formalpara> <formalpara>
<title><systemitem>--with-threads</systemitem></title> <title><option>--with-threads</option></title>
<para> <para>
Specify a thread implementation to use. Available options are Specify a thread implementation to use. Available options are
@ -331,7 +332,7 @@
</formalpara> </formalpara>
<formalpara> <formalpara>
<title><systemitem>--with-pcre</systemitem></title> <title><option>--with-pcre</option></title>
<para> <para>
Specify whether to use the internal or the system-supplied Specify whether to use the internal or the system-supplied
@ -346,30 +347,34 @@
<listitem> <listitem>
<para> <para>
'system' means that GRegex will be compiled to use 'system' means that GRegex will be compiled to use
the system-supplied PCRE library. the system-supplied PCRE library; this is the default
setting.
</para> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
Using the internal PCRE is the preferred solution: Using the internal PCRE is the preferred solution if:
<itemizedlist> <itemizedlist>
<listitem> <listitem>
<para> <para>
System-supplied PCRE has a separated copy of the big tables your system has strict resource constraints; the system-supplied
used for Unicode handling. PCRE has a separated copy of the tables used for Unicode
handling, whereas the internal copy shares the Unicode tables
used by GLib.
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
Some systems have PCRE libraries compiled without some needed your system has PCRE built without some needed features,
features, such as UTF-8 and Unicode support. such as UTF-8 and Unicode support.
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
PCRE uses some global variables for memory management and you are planning to use both GRegex and PCRE API at the same
other features. In the rare case of a program using both time, either directly or indirectly through a dependency; PCRE
GRegex and PCRE (maybe indirectly through a library), uses some global variables for memory management and
this variables could lead to problems when they are modified. other features, and if both GLib and PCRE try to access them
at the same time, this could lead to undefined behavior.
</para> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
@ -377,31 +382,34 @@
</formalpara> </formalpara>
<formalpara> <formalpara>
<title><systemitem>--disable-included-printf</systemitem> and <title><option>--disable-included-printf</option> and
<systemitem>--enable-included-printf</systemitem></title> <option>--enable-included-printf</option></title>
<para> <para>
By default the <command>configure</command> script will try By default the <command>configure</command> script will try
to auto-detect whether the C library provides a suitable set to auto-detect whether the C library provides a suitable set
of printf() functions. In detail, <command>configure</command> of <function>printf()</function> functions. In detail,
checks that the semantics of snprintf() are as specified by C99 <command>configure</command> checks that the semantics of
<function>snprintf()</function> are as specified by C99
and that positional parameters as specified in the Single Unix and that positional parameters as specified in the Single Unix
Specification are supported. If this not the case, GLib will Specification are supported. If this not the case, GLib will
include an implementation of the printf() family. include an implementation of the <function>printf()</function>
family.
</para> </para>
<para> <para>
These options can be used to explicitly control whether These options can be used to explicitly control whether
an implementation of the printf() family should be included or not. an implementation of the <function>printf()</function> family
should be included or not.
</para> </para>
</formalpara> </formalpara>
<formalpara> <formalpara>
<title><systemitem>--disable-Bsymbolic</systemitem> and <title><option>--disable-Bsymbolic</option> and
<systemitem>--enable-Bsymbolic</systemitem></title> <option>--enable-Bsymbolic</option></title>
<para> <para>
By default, GLib uses the -Bsymbolic-functions linker By default, GLib uses the <option>-Bsymbolic-functions</option>
flag to avoid intra-library PLT jumps. A side-effect linker flag to avoid intra-library PLT jumps. A side-effect
of this is that it is no longer possible to override of this is that it is no longer possible to override
internal uses of GLib functions with internal uses of GLib functions with
<envar>LD_PRELOAD</envar>. Therefore, it may make <envar>LD_PRELOAD</envar>. Therefore, it may make
@ -412,8 +420,8 @@
</formalpara> </formalpara>
<formalpara> <formalpara>
<title><systemitem>--disable-gtk-doc</systemitem> and <title><option>--disable-gtk-doc</option> and
<systemitem>--enable-gtk-doc</systemitem></title> <option>--enable-gtk-doc</option></title>
<para> <para>
By default the <command>configure</command> script will try By default the <command>configure</command> script will try
@ -430,8 +438,8 @@
</formalpara> </formalpara>
<formalpara> <formalpara>
<title><systemitem>--disable-man</systemitem> and <title><option>--disable-man</option> and
<systemitem>--enable-man</systemitem></title> <option>--enable-man</option></title>
<para> <para>
By default the <command>configure</command> script will try By default the <command>configure</command> script will try
@ -446,23 +454,24 @@
</formalpara> </formalpara>
<formalpara> <formalpara>
<title><systemitem>--disable-xattr</systemitem> and <title><option>--disable-xattr</option> and
<systemitem>--enable-xattr</systemitem></title> <option>--enable-xattr</option></title>
<para> <para>
By default the <command>configure</command> script will try By default the <command>configure</command> script will try
to auto-detect whether the getxattr() family of functions to auto-detect whether the <function>getxattr()</function>
is available. If it is, then extended attribute support family of functions is available. If it is, then extended
will be included in GIO. These options can be used to attribute support will be included in GIO. These options can
explicitly control whether extended attribute support be used to explicitly control whether extended attribute
should be included or not. getxattr() and friends can support should be included or not. <function>getxattr()</function>
be provided by glibc or by the standalone libattr library. and friends can be provided by glibc or by the standalone
libattr library.
</para> </para>
</formalpara> </formalpara>
<formalpara> <formalpara>
<title><systemitem>--disable-selinux</systemitem> and <title><option>--disable-selinux</option> and
<systemitem>--enable-selinux</systemitem></title> <option>--enable-selinux</option></title>
<para> <para>
By default the <command>configure</command> script will By default the <command>configure</command> script will
@ -474,8 +483,8 @@
</formalpara> </formalpara>
<formalpara> <formalpara>
<title><systemitem>--disable-dtrace</systemitem> and <title><option>--disable-dtrace</option> and
<systemitem>--enable-dtrace</systemitem></title> <option>--enable-dtrace</option></title>
<para> <para>
By default the <command>configure</command> script will By default the <command>configure</command> script will
@ -484,8 +493,8 @@
</formalpara> </formalpara>
<formalpara> <formalpara>
<title><systemitem>--disable-systemtap</systemitem> and <title><option>--disable-systemtap</option> and
<systemitem>--enable-systemtap</systemitem></title> <option>--enable-systemtap</option></title>
<para> <para>
This option requires DTrace support. If it is available, then This option requires DTrace support. If it is available, then
@ -495,8 +504,8 @@
</formalpara> </formalpara>
<formalpara> <formalpara>
<title><systemitem>--enable-coverage</systemitem> and <title><option>--enable-coverage</option> and
<systemitem>--disable-coverage</systemitem></title> <option>--disable-coverage</option></title>
<para> <para>
Enable the generation of coverage reports for the GLib tests. Enable the generation of coverage reports for the GLib tests.
@ -508,7 +517,7 @@
</formalpara> </formalpara>
<formalpara> <formalpara>
<title><systemitem>--with-runtime-libdir=RELPATH</systemitem></title> <title><option>--with-runtime-libdir=RELPATH</option></title>
<para> <para>
Allows specifying a relative path to where to install the runtime Allows specifying a relative path to where to install the runtime
@ -516,21 +525,21 @@
GLib applications). This can be used in operating system setups where GLib applications). This can be used in operating system setups where
programs using GLib needs to run before e.g. <filename>/usr</filename> programs using GLib needs to run before e.g. <filename>/usr</filename>
is mounted. is mounted.
For example, if LIBDIR is <filename>/usr/lib</filename> and For example, if <varname>LIBDIR</varname> is <filename>/usr/lib</filename> and
<filename>../../lib</filename> is passed to <filename>../../lib</filename> is passed to
<systemitem>--with-runtime-libdir</systemitem> then the <option>--with-runtime-libdir</option> then the
runtime libraries are installed into <filename>/lib</filename> rather runtime libraries are installed into <filename>/lib</filename> rather
than <filename>/usr/lib</filename>. than <filename>/usr/lib</filename>.
</para> </para>
</formalpara> </formalpara>
<formalpara> <formalpara>
<title><systemitem>--with-python</systemitem></title> <title><option>--with-python=PATH</option></title>
<para> <para>
Allows specifying the Python interpreter to use, either as an absolute path, Allows specifying the Python interpreter to use, either as an absolute path,
or as a program name. GLib can be built with Python 2 (at least version 2.5) or as a program name. GLib can be built with Python 2 (at least version 2.7)
or Python 3. or, preferably, with Python 3.
</para> </para>
</formalpara> </formalpara>
</refsect1> </refsect1>