Skip to content

Use Homebrew include directory for pcre2.h on macOS if necessary - #626

Merged
madmajestro merged 1 commit into
krakjoe:masterfrom
madmajestro:add-macos-to-ci
Jun 20, 2026
Merged

Use Homebrew include directory for pcre2.h on macOS if necessary#626
madmajestro merged 1 commit into
krakjoe:masterfrom
madmajestro:add-macos-to-ci

Conversation

@madmajestro

@madmajestro madmajestro commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

When pcre2 is installed via Homebrew on macOS, the header file pcre2.h is typically located in the Homebrew include directory. This leads to build errors since the compiler does not use this directory by default. Therefore, the Homebrew include directory is now added as include directory for the compiler if it contains pcre2.h. In addition, the CI has been extended to check the build on macOS.

Closes #572

@nikic

nikic commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Can this cause issues with wrong headers being used if pcre2 was not installed via Homebrew (but a Homebrew installation happens to exist)?

@madmajestro

Copy link
Copy Markdown
Collaborator Author

I’ve thought about that, too. I consider it quite unlikely, but possible. I’ll take a closer look at it. It probably makes sense to check harder whether adding this include path is really necessary.

@madmajestro madmajestro changed the title Use Homebrew include directory on macOS and add macOS to the CI Use Homebrew include directory for pcre2.h on macOS if necessary Jun 19, 2026
@madmajestro

Copy link
Copy Markdown
Collaborator Author

I have now revised this a bit. The directory is now added only if the compiler cannot find the file in the standard include directories and if it exists in the Homebrew include directory instead.

@madmajestro

Copy link
Copy Markdown
Collaborator Author

I think this approach should work well. I plan to run a few more tests and merge it in a couple of days. If you have any concerns, please let me know.

@nikic nikic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

When pcre2 is installed via Homebrew on macOS, the header file pcre2.h
is typically located in the Homebrew include directory. This leads to
build errors since the compiler does not use this directory by default.
Therefore, the Homebrew include directory is now added as include
directory for the compiler if it contains pcre2.h. In addition, the CI
has been extended to check the build on macOS.
@madmajestro

Copy link
Copy Markdown
Collaborator Author

While testing, I found another issue:
If APCu is built in-tree and the PHP build system uses the built-in PCRE library, the new logic is now skipped because the external pcre2.h is not used in this case.

@madmajestro
madmajestro merged commit f640054 into krakjoe:master Jun 20, 2026
51 checks passed
@madmajestro
madmajestro deleted the add-macos-to-ci branch June 20, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fatal error: 'pcre2.h' file not found

2 participants