Skip to content

Fix openssl detection on Silicon Macs #1791

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Feb 19, 2025

Targeting 1.21 for this change, as it could lead to a different SSL library being picked, which I wouldn't expect in a patch release. This is consistent with #1463 which was the original attempt to prefer openssl over Secure Transport and also targeted a minor version to avoid unexpected issues on a patch update.

On Silicon Macs, the paths for homebrew have changed, so if the PKG_CHECK_MODULES macro does not find openssl on MacOS and no OPENSSL_DIR option has been provided, it usually won't be found. As a result, Secure Transport will be picked in those circumstances.

On Silicon platforms, homebrew installs openssl into /opt/homebrew/opt/openssl, so adding that path to PHP_OPENSSL_DIR fixes the issue.

To make debugging easier, I also added the selected SSL library to the configure output.

NB: I checked whether pkg-config is available on my system, and it isn't by default. A quick search through homebrew also didn't reveal it, so my assumption is that pkg-config won't be available on the typical developer machine, hence this workaround.

@alcaeus alcaeus requested a review from jmikola February 19, 2025 12:35
@alcaeus alcaeus marked this pull request as draft February 19, 2025 14:56
@jmikola
Copy link
Member

jmikola commented Feb 19, 2025

pkgconf is the Homebrew package for pkg-config. We already note that pkg-config is a requirement in the PECL install docs, but we could certainly repeat this for Homebrew and link to the specific package.

I'm not sure how the PHP formulae detect OpenSSL without pkg-config, since PHP itself has used it exclusively since 7.4 (see: php/php-src@fe8fdfa3). That was the point where PHP removed all of the legacy path detection that we still have as a fallback. But if Homebrew is all binaries, I suppose pkg-config might only be a requirement for the package maintainer(s) -- in contrast to PECL, where users are compiling the extension themselves.

@alcaeus
Copy link
Member Author

alcaeus commented Feb 24, 2025

Agree, after install the pkgconf package the detection now works as expected. I'm closing this PR and I've filed PHPC-2520 to document how to install pkg-config on MacOS. We can separately consider removing the legacy path-based detection in favour of the same mechanism used in PHP itself.

@alcaeus alcaeus closed this Feb 24, 2025
@alcaeus alcaeus deleted the fix-macos-openssl-detection branch February 24, 2025 07:27
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.

2 participants