build: Drop the internal_pcre option in favour of the subproject

This should maintain equivalent functionality, apart from that now you
have to pass `--force-fallback-for libpcre` to `meson configure` in
order to use the subproject; rather than specifying
`-Dinternal_pcre=true` to use the internal copy.

This also fixes #642, as the wrapdb copy of libpcre is version 8.37.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #962
Fixes: #642
This commit is contained in:
Philip Withnall 2021-06-09 12:26:30 +01:00
parent 1d952150e6
commit 9fbd7f3dc1
7 changed files with 34 additions and 103 deletions

View File

@ -270,7 +270,7 @@ cross-android_api21_arm64:
# FIXME: add --werror # FIXME: add --werror
# We use -Diconv=auto to test that we successfully detect that iconv is not # We use -Diconv=auto to test that we successfully detect that iconv is not
# provided by android api 21, and detect the external iconv instead. # provided by android api 21, and detect the external iconv instead.
- meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_android_arm64_21.txt -Diconv=auto -Dinternal_pcre=true _build - meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_android_arm64_21.txt -Diconv=auto _build
- ninja -C _build - ninja -C _build
cross-android_api28_arm64: cross-android_api28_arm64:
@ -278,7 +278,7 @@ cross-android_api28_arm64:
image: $ANDROID_IMAGE image: $ANDROID_IMAGE
script: script:
# FIXME: add --werror # FIXME: add --werror
- meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_android_arm64_28.txt -Dinternal_pcre=true _build - meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_android_arm64_28.txt _build
- ninja -C _build - ninja -C _build
cross-mingw64: cross-mingw64:

View File

@ -153,12 +153,9 @@
<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 system for regular expression matching. The system version of PCRE is used,
version of PCRE, to reduce the chances of security fixes going out unless not available (which is the case on Android), in which case a
of sync. GLib additionally provides an internal copy of PCRE in case fallback subproject is used.
the system version is too old, or does not support UTF-8; the internal
copy is patched to use GLib for memory management and to share the
same Unicode tables.
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
@ -235,45 +232,6 @@
</para> </para>
</formalpara> </formalpara>
<formalpara>
<title><option>-Dinternal_pcre=true</option></title>
<para>
Normally, GLib will be configured to use the system-supplied PCRE
library if it is suitable, falling back to an internal version
otherwise. If this option is specified, the internal version will always
be used.
</para>
<para>
Using the internal PCRE is the preferred solution if:
<itemizedlist>
<listitem>
<para>
your system has strict resource constraints; the system-supplied
PCRE has a separated copy of the tables used for Unicode
handling, whereas the internal copy shares the Unicode tables
used by GLib.
</para>
</listitem>
<listitem>
<para>
your system has PCRE built without some needed features,
such as UTF-8 and Unicode support.
</para>
</listitem>
<listitem>
<para>
you are planning to use both GRegex and PCRE API at the same
time, either directly or indirectly through a dependency; PCRE
uses some global variables for memory management and
other features, and if both GLib and PCRE try to access them
at the same time, this could lead to undefined behavior.
</para>
</listitem>
</itemizedlist>
</para>
</formalpara>
<formalpara> <formalpara>
<title><option>-Dbsymbolic_functions=false</option> and <title><option>-Dbsymbolic_functions=false</option> and
<option>-Dbsymbolic_functions=true</option></title> <option>-Dbsymbolic_functions=true</option></title>

View File

@ -22,11 +22,7 @@
#include <string.h> #include <string.h>
#ifdef USE_SYSTEM_PCRE
#include <pcre.h> #include <pcre.h>
#else
#include "pcre/pcre.h"
#endif
#include "gtypes.h" #include "gtypes.h"
#include "gregex.h" #include "gregex.h"

View File

@ -357,13 +357,8 @@ if use_pcre_static_flag
pcre_static_args = ['-DPCRE_STATIC'] pcre_static_args = ['-DPCRE_STATIC']
endif endif
if use_system_pcre pcre_deps = [pcre]
pcre_deps = [pcre] pcre_objects = []
pcre_objects = []
else
pcre_deps = []
pcre_objects = [libpcre.extract_all_objects()]
endif
glib_c_args = ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + glib_hidden_visibility_args glib_c_args = ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + glib_hidden_visibility_args
libglib = library('glib-2.0', libglib = library('glib-2.0',

View File

@ -25,11 +25,7 @@
#include <locale.h> #include <locale.h>
#include "glib.h" #include "glib.h"
#ifdef USE_SYSTEM_PCRE
#include <pcre.h> #include <pcre.h>
#else
#include "glib/pcre/pcre.h"
#endif
/* U+20AC EURO SIGN (symbol, currency) */ /* U+20AC EURO SIGN (symbol, currency) */
#define EURO "\xe2\x82\xac" #define EURO "\xe2\x82\xac"

View File

@ -1979,46 +1979,37 @@ else
endif endif
endif endif
if get_option('internal_pcre') pcre = dependency('libpcre', version: '>= 8.31', required : false) # Should check for Unicode support, too. FIXME
pcre = [] if not pcre.found()
use_system_pcre = false if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
else # MSVC: Search for the PCRE library by the configuration, which corresponds
pcre = dependency('libpcre', version: '>= 8.31', required : false) # Should check for Unicode support, too. FIXME # to the output of CMake builds of PCRE. Note that debugoptimized
if not pcre.found() # is really a Release build with .PDB files.
if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl' if vs_crt == 'debug'
# MSVC: Search for the PCRE library by the configuration, which corresponds pcre = cc.find_library('pcred', required : false)
# to the output of CMake builds of PCRE. Note that debugoptimized else
# is really a Release build with .PDB files. pcre = cc.find_library('pcre', required : false)
if vs_crt == 'debug'
pcre = cc.find_library('pcred', required : false)
else
pcre = cc.find_library('pcre', required : false)
endif
endif endif
endif endif
use_system_pcre = pcre.found()
endif endif
glib_conf.set('USE_SYSTEM_PCRE', use_system_pcre)
use_pcre_static_flag = false # Try again with the fallback
if not pcre.found()
if host_system == 'windows' pcre = dependency('libpcre', required : true, fallback : ['libpcre', 'pcre_dep'])
if not use_system_pcre use_pcre_static_flag = true
use_pcre_static_flag = true elif host_system == 'windows'
else pcre_static = cc.links('''#define PCRE_STATIC
pcre_static = cc.links('''#define PCRE_STATIC #include <pcre.h>
#include <pcre.h> int main() {
int main() { void *p = NULL;
void *p = NULL; pcre_free(p);
pcre_free(p); return 0;
return 0; }''',
}''', dependencies: pcre,
dependencies: pcre, name : 'Windows system PCRE is a static build')
name : 'Windows system PCRE is a static build') use_pcre_static_flag = pcre_static
if pcre_static else
use_pcre_static_flag = true use_pcre_static_flag = false
endif
endif
endif endif
libm = cc.find_library('m', required : false) libm = cc.find_library('m', required : false)

View File

@ -34,11 +34,6 @@ option('libmount',
value : 'auto', value : 'auto',
description : 'build with libmount support') description : 'build with libmount support')
option('internal_pcre',
type : 'boolean',
value : false,
description : 'whether to use internal PCRE')
option('man', option('man',
type : 'boolean', type : 'boolean',
value : false, value : false,