git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3] meson: disable PCRE2 dependency by default in macOS

From
Eli Schwartz <eschwartz@gentoo.org>
Date
Jul 15, 2025, 01:55 UTC
Message-ID
<2414b962-e843-4ac0-814f-bb4bc7aacda7@gentoo.org>
In-Reply-To
<20250713174807.32444-1-carenas@gmail.com>
On 7/13/25 1:48 PM, Carlo Marcelo Arenas Belón wrote:
Show 13 quoted lines
> Makefile requires the user to provide the USE_LIBPCRE2 flag to
> enable this dependency, but meson has it enabled by default,
> which can be problematic, at least in macOS.
> 
> macOS provides a PCRE2 library in base that is not usable and not
> configured properly, as it installs a pkgconf module that
> points to a non existent pcre2.h header in /usr/local/include.
> 
> Add an option that will need to be turned to true once an
> alternative PCRE2 library is installed (which hopefully provides
> its own pkgconf module earlier in PKG_CONFIG_PATH) or meson has
> been instructed to use its subproject as a suitable dependency
> by `--force-fallback-for=pcre2`.

I cannot possibly agree with any part of this. Right bug report, wrong patch.

Problem:
Meson supports three modes:
- require pcre2 and fail if missing
- automatically, optimistically use it if possible
- disable and reject it even if available
macOS has a problem:
- pcre2 (in modes 1 and 2) is detected as available via a system
  package, but upon successfully configuring a ninja file, the compile
  fails
Solution proposed here:
- v1: switch default mode from "enabled" to "disabled", leaving feature
  broken if anyone tries it out
- v2 / v3: switch default mode from "enabled" to "auto", then ignoring
  the config setting by default, and permitting users to use an ugly
  "are you sure" option to get... a failing build.

Nowhere are we checking what we got. Trying to build with pcre2 will fail in confusingly awkward ways at the worst time: compile time. We don't need a build option here to ask for this bad experience -- we should just get it correct. :)

The goal should be, if the pcre2 feature is:
- enabled, meson should *fail early* if the demand cannot be met,
  providing a clear explanation of what is wrong
- auto, meson should *detect* it cannot work and build without it
Show 20 quoted lines
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> ---
>  meson.build       | 3 ++-
>  meson_options.txt | 4 +++-
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index 7fea4a34d6..e1475be6c8 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1055,7 +1055,8 @@ else
>    build_options_config.set('NO_ICONV', '1')
>  endif
>  
> -pcre2 = dependency('libpcre2-8', required: get_option('pcre2'), default_options: ['default_library=static', 'test=false'])
> +pcre2_feature = get_option('pcre2').disable_auto_if(host_machine.system() == 'darwin' and not get_option('macos_workaround_system_pcre2'))
> +pcre2 = dependency('libpcre2-8', required: pcre2_feature, default_options: ['default_library=static', 'test=false'])
>  if pcre2.found()
>    libgit_dependencies += pcre2
>    libgit_c_args += '-DUSE_LIBPCRE2'
Instead of disable_auto_if, we should simply verify a working install.
if pcre2.found() and pcre2.type_name() != 'internal' and
host_machine.system() == 'darwin'
    # macOS installs a broken system package, double check
    if not compiler.has_header('pcre2.h', dependencies: pcre2)
        if get_option('pcre2').enabled()
            error('broken pcre2 install found but pcre2 is required')
        endif
        # Replace with not-found-dependency
        pcre2 = dependency('', required: false)
        warning('broken pcre2 install found, disabling pcre2 feature')
    endif
endif
if pcre2.found()
    libgit_dependencies += pcre2
[...]

Please double-check my work, that this compiler.has_header() is sufficient on your reproducer system to detect and disable the non-working feature.

Show 10 quoted lines
> diff --git a/meson_options.txt b/meson_options.txt
> index e7f768df24..f63ff32556 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -45,7 +45,7 @@ option('gitweb', type: 'feature', value: 'auto',
>    description: 'Build Git web interface. Requires Perl.')
>  option('iconv', type: 'feature', value: 'auto',
>    description: 'Support reencoding strings with different encodings.')
> -option('pcre2', type: 'feature', value: 'enabled',
> +option('pcre2', type: 'feature', value: 'auto',

This part is fine. We shouldn't default-fail if it isn't found, when we can't expect it to be universally available.

Show 12 quoted lines
>    description: 'Support Perl-compatible regular expressions in e.g. git-grep(1).')
>  option('perl', type: 'feature', value: 'auto',
>    description: 'Build tools written in Perl.')
> @@ -73,6 +73,8 @@ option('breaking_changes', type: 'boolean', value: false,
>    description: 'Enable upcoming breaking changes.')
>  option('macos_use_homebrew_gettext', type: 'boolean', value: true,
>    description: 'Use gettext from Homebrew instead of the slightly-broken system-provided one.')
> +option('macos_workaround_system_pcre2', type: 'boolean', value: false,
> +  description: 'A working PCRE2 library is available or will be provided by a subproject.')
>  
>  # gitweb configuration.
>  option('gitweb_config', type: 'string', value: 'gitweb_config.perl')
-- 
Eli Schwartz
Previous: Carlo Marcelo Arenas BelónNext: Patrick Steinhardt
Message 10 of 28 in “meson: disable PCRE2 dependency by default”
  1. meson: disable PCRE2 dependency by defaultCarlo Marcelo Arenas Belón, Jul 12, 2025
  2. brian m. carlsonJul 12, 2025
  3. Carlo ArenasJul 14, 2025
  4. Junio C HamanoJul 14, 2025
  5. Carlo Marcelo Arenas BelónJul 14, 2025
  6. Junio C HamanoJul 14, 2025
  7. meson: disable PCRE2 dependency by default in macOSCarlo Marcelo Arenas Belón, Jul 13, 2025
  8. Junio C HamanoJul 13, 2025
  9. meson: disable PCRE2 dependency by default in macOSCarlo Marcelo Arenas Belón, Jul 13, 2025
  10. Eli SchwartzJul 15, 2025
  11. Patrick SteinhardtJul 15, 2025
  12. Carlo ArenasJul 15, 2025
  13. Patrick SteinhardtJul 15, 2025
  14. Carlo ArenasJul 15, 2025
  15. Eli SchwartzJul 15, 2025
  16. Carlo ArenasJul 15, 2025
  17. Eli SchwartzJul 15, 2025
  18. meson: woraround broken system PCRE2 dependency in macOSCarlo Marcelo Arenas Belón, Jul 15, 2025
  19. Junio C HamanoJul 15, 2025
  20. Eric SunshineJul 15, 2025
  21. meson: work around broken system PCRE2 dependency in macOSCarlo Marcelo Arenas Belón, Jul 16, 2025
  22. Junio C HamanoJul 16, 2025
  23. Junio C HamanoJul 16, 2025
  24. Eli SchwartzJul 16, 2025
  25. Carlo ArenasJul 16, 2025
  26. meson: work around broken system PCRE2 dependency in macOSCarlo Marcelo Arenas Belón, Jul 18, 2025
  27. Junio C HamanoJul 23, 2025
  28. Patrick SteinhardtJul 24, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.