Subject: Re: [PATCH] regex: not all macOS platforms seem to have REG_ENHANCED

From: Junio C Hamano <[email-masked]>
Date: Fri, 20 Mar 2026 09:33:25 -0700

René Scharfe <[email-masked]> writes:

>> The net effect is that `CC=clang` in CI now silently resolves to
>> Homebrew's LLVM 15.0.7 clang instead of Apple's system clang (Apple
>> clang 15.0.0, bundled with Xcode 15.4).  The runner image README
>> confirms this: the reported "Clang/LLVM" version flipped from 15.0.0 to
>> 15.0.7 between image releases, matching the Homebrew LLVM version
>> exactly.
>
> Good find!

Indeed.  So clang got updated pretty recently (CI runs triggered by
my pushing out happens at least once a day and yesterday was the
first time I saw this failure), and that is because Homebrew got
updated?

>> Homebrew's LLVM clang uses different include paths from Apple's clang.
>> In particular, the `regex.h` it sees does not define `REG_ENHANCED`,
>> which is an Apple-specific extension present in the macOS SDK headers
>> since at least macOS 10.12.  The Makefile unconditionally sets
>> `USE_ENHANCED_BASIC_REGULAR_EXPRESSIONS` for all Darwin builds via
>> `config.mak.uname`, which pulls in `compat/regcomp_enhanced.c`, which
>> references `REG_ENHANCED`, hence the build failure.
>
> I suspect it uses the same regex.h.  The definition of REG_ENHANCED is
> gated by a __MAC_OS_X_VERSION_MIN_REQUIRED check, though, and that fails
> because __MAC_OS_X_VERSION_MIN_REQUIRED is defined as
> __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ and that one in turn is not
> defined by the Homebrew version of clang in the runner.

> Or how about using /usr/bin/clang explicitly on macOS instead of any old
> clang from $PATH?  That would avoid user-visible changes.

If it gives us more stability of CI environment (one fewer thing
that can suddenly change the toolset), and makes the environment
closer to a typical end-user set-up (hopefully most of them would
use what is available in /usr/bin from there, instead of downloading
newer versions but possibly built with different/castrated set of
features), that does look like an attractive alternative to me.