📄 glib-building.html
字号:
By default, and with <code class="systemitem">--disable-gc-friendly</code> as well, Glib does not clear the memory for certain objects before they are freed. For example, Glib may decide to recycle GList nodes by putting them in a free list. However, memory profiling and debugging tools like <a class="ulink" href="http://www.valgrind.org" target="_top">Valgrind</a> work better if an application does not keep dangling pointers to freed memory (even though these pointers are no longer dereferenced), or invalid pointers inside uninitialized memory. The <code class="systemitem">--enable-gc-friendly</code> option makes Glib clear memory in these situations: </p><div class="itemizedlist"><ul type="disc"><li><p> When shrinking a GArray, Glib will clear the memory no longer 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 and multiple elements. </p></li><li><p> </p></li><li><p> 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 be cleared. </p></li><li><p> The above applies to GPtrArray as well. </p></li><li><p> When freeing a node from a GHashTable, Glib will first clear the node, which used to have pointers to the key and the value stored at that node. </p></li><li><p> 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 right subnodes. </p></li></ul></div><p> Since clearing the memory has a cost, <code class="systemitem">--disable-gc-friendly</code> is the default. </p><p><b><code class="systemitem">--disable-mem-pools</code> and <code class="systemitem">--enable-mem-pools</code>. </b> Many small chunks of memory are often allocated via collective pools in GLib and are cached after release to speed up reallocations. For sparse memory systems this behaviour is often inferior, so memory pools can be disabled to avoid excessive caching and force atomic maintenance of chunks through the <code class="function">g_malloc()</code> and <code class="function">g_free()</code> functions. Code currently affected by this: </p><div class="itemizedlist"><ul type="disc"><li><p> <span class="structname">GList</span>, <span class="structname">GSList</span>, <span class="structname">GNode</span>, <span class="structname">GHash</span> allocations. The functions g_list_push_allocator(), g_list_pop_allocator(), g_slist_push_allocator(), g_slist_pop_allocator(), g_node_push_allocator() and g_node_pop_allocator() are not available </p></li><li><p> <span class="structname">GMemChunk</span>s become basically non-effective </p></li><li><p> <span class="structname">GSignal</span> disables all caching (potentially very slow) </p></li><li><p> <span class="structname">GType</span> doesn't honour the <span class="structname">GTypeInfo</span> <em class="structfield"><code>n_preallocs</code></em> field anymore </p></li><li><p> the <span class="structname">GBSearchArray</span> flag <code class="literal">G_BSEARCH_ALIGN_POWER2</code> becomes non-functional </p></li></ul></div><p> </p><p><b><code class="systemitem">--disable-threads</code> and <code class="systemitem">--enable-threads</code>. </b> Do not compile GLib to be multi thread safe. GLib will be slightly faster then. This is however not recommended, as many programs rely on GLib being multi thread safe. </p><p><b><code class="systemitem">--with-threads</code>. </b> Specify a thread implementation to use. </p><div class="itemizedlist"><ul type="disc"><li><p> 'posix' and 'dce' can be used interchangeable to mean the different versions of Posix threads. configure tries to find out, which one is installed. </p></li><li><p> 'none' means that GLib will be thread safe, but does not have a default thread implementation. This has to be supplied to <code class="function">g_thread_init()</code> by the programmer. </p></li></ul></div><p> </p><p><b><code class="systemitem">--disable-regex</code> and <code class="systemitem">--enable-regex</code>. </b> Do not compile GLib with regular expression support. GLib will be smaller because it will not need the PCRE library. This is however not recommended, as programs may need GRegex. </p><p><b><code class="systemitem">--with-pcre</code>. </b> Specify whether to use the internal or the system-supplied PCRE library. </p><div class="itemizedlist"><ul type="disc"><li><p> 'internal' means that GRegex will be compiled to use the internal PCRE library. </p></li><li><p> 'system' means that GRegex will be compiled to use the system-supplied PCRE library. </p></li></ul></div><p> Using the internal PCRE is the preferred solution: </p><div class="itemizedlist"><ul type="disc"><li><p> System-supplied PCRE has a separated copy of the big tables used for Unicode handling. </p></li><li><p> Some systems have PCRE libraries compiled without some needed features, such as UTF-8 and Unicode support. </p></li><li><p> PCRE uses some global variables for memory management and other features. In the rare case of a program using both GRegex and PCRE (maybe indirectly through a library), this variables could lead to problems when they are modified. </p></li></ul></div><p> </p><p><b><code class="systemitem">--disable-included-printf</code> and <code class="systemitem">--enable-included-printf</code>. </b> By default the <span class="command"><strong>configure</strong></span> script will try to auto-detect whether the C library provides a suitable set of <code class="function">printf()</code> functions. In detail, <span class="command"><strong>configure</strong></span> checks that the semantics of <code class="function">snprintf()</code> are as specified by C99 and that positional parameters as specified in the Single Unix Specification are supported. If this not the case, GLib will include an implementation of the <code class="function">printf()</code> family. These options can be used to explicitly control whether an implementation fo the <code class="function">printf()</code> family should be included or not. </p><p><b><code class="systemitem">--disable-visibility</code> and <code class="systemitem">--enable-visibility</code>. </b> By default, GLib uses ELF visibility attributes to optimize PLT table entries if the compiler supports ELF visibility attributes. A side-effect of the way in which this is currently implemented is that any header change forces a full recompilation, and missing includes may go unnoticed. Therefore, it makes sense to turn this feature off while doing GLib development, even if the compiler supports ELF visibility attributes. The <code class="option">--disable-visibility</code> option allows to do that. </p><p><b><code class="systemitem">--disable-gtk-doc</code> and <code class="systemitem">--enable-gtk-doc</code>. </b> By default the <span class="command"><strong>configure</strong></span> script will try to auto-detect whether the <span class="application">gtk-doc</span> package is installed. If it is, then it will use it to extract and build the documentation for the GLib library. These options can be used to explicitly control whether <span class="application">gtk-doc</span> should be used or not. If it is not used, the distributed, pre-generated HTML files will be installed instead of building them on your machine. </p><p><b><code class="systemitem">--disable-man</code> and <code class="systemitem">--enable-man</code>. </b> By default the <span class="command"><strong>configure</strong></span> script will try to auto-detect whether <span class="application">xsltproc</span> and the necessary Docbook stylesheets are installed. If they are, then it will use them to rebuild the included man pages from the XML sources. These options can be used to explicitly control whether man pages should be rebuilt used or not. The distribution includes pre-generated man pages. </p><p><b><code class="systemitem">--disable-xattr</code> and <code class="systemitem">--enable-xattr</code>. </b> By default the <span class="command"><strong>configure</strong></span> script will try to auto-detect whether the getxattr() family of functions is available. If it is, then extended attribute support will be included in GIO. These options can be used to explicitly control whether extended attribute support should be included or not. getxattr() and friends can be provided by glibc or by the standalone libattr library. </p><p><b><code class="systemitem">--disable-selinux</code> and <code class="systemitem">--enable-selinux</code>. </b> By default the <span class="command"><strong>configure</strong></span> script will auto-detect if libselinux is available and include SELinux support in GIO if it is. These options can be used to explicitly control whether SELinxu support should be included. </p></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -