Skip to content
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

PHP 8.2.0RC1: Configuring on macOS: CommonCrypto/CommonRandom.h present but configuration fails #9464

Closed
debohman opened this issue Sep 2, 2022 · 3 comments

Comments

@debohman
Copy link
Contributor

debohman commented Sep 2, 2022

Description

When configuring to build on macOS 10.12.6, the following is observed:

checking CommonCrypto/CommonRandom.h usability... no
checking CommonCrypto/CommonRandom.h presence... yes
configure: WARNING: CommonCrypto/CommonRandom.h: present but cannot be compiled
configure: WARNING: CommonCrypto/CommonRandom.h:     check for missing prerequisite headers?
configure: WARNING: CommonCrypto/CommonRandom.h: see the Autoconf documentation
configure: WARNING: CommonCrypto/CommonRandom.h:     section "Present But Cannot Be Compiled"
configure: WARNING: CommonCrypto/CommonRandom.h: proceeding with the compiler's result
configure: WARNING:     ## ---------------------------------------------------- ##
configure: WARNING:     ## Report this to https://github.com/php/php-src/issues ##
configure: WARNING:     ## ---------------------------------------------------- ##
checking for CommonCrypto/CommonRandom.h... no

Even though the header is present, configuration of it fails.

I was able to fix it with the following:

diff --git a/ext/random/config.m4 b/ext/random/config.m4
index 7bd432c911..a8e6d5a568 100644
--- a/ext/random/config.m4
+++ b/ext/random/config.m4
@@ -7,7 +7,12 @@ dnl
 dnl Check for CCRandomGenerateBytes
 dnl header absent in previous macOs releases
 dnl
-AC_CHECK_HEADERS([CommonCrypto/CommonRandom.h])
+AC_CHECK_HEADERS([CommonCrypto/CommonRandom.h], [], [],
+[
+	#include <sys/types.h>
+	#include <Availability.h>
+	#include <CommonCrypto/CommonCryptoError.h>
+])
 
 dnl
 dnl Setup extension
diff --git a/ext/standard/config.m4 b/ext/standard/config.m4
index fb9d8e5415..8e77e75134 100644
--- a/ext/standard/config.m4
+++ b/ext/standard/config.m4
@@ -407,7 +407,12 @@ dnl
 dnl Check for CCRandomGenerateBytes
 dnl header absent in previous macOs releases
 dnl
-AC_CHECK_HEADERS([CommonCrypto/CommonRandom.h])
+AC_CHECK_HEADERS([CommonCrypto/CommonRandom.h], [], [],
+[
+	#include <sys/types.h>
+	#include <Availability.h>
+	#include <CommonCrypto/CommonCryptoError.h>
+])
 
 dnl
 dnl Check for argon2

With the patch, php builds, and the "random" module is present.

PHP Version

PHP 8.2.0RC1

Operating System

macOS 10.12.6

@devnexen
Copy link
Member

devnexen commented Sep 3, 2022

would you be able to create a PR ?

@debohman
Copy link
Contributor Author

debohman commented Sep 3, 2022

Okay, I will do that now.

debohman added a commit to debohman/php-src that referenced this issue Sep 3, 2022
macOS. Must also pull in sys/types.h for size_t, Availability.h for
__OSX_AVAILABLE_STARTING, and CommonCrypto/CommonCryptoError.h for
CCCryptorStatus. Fixes GH php#9464.
devnexen pushed a commit that referenced this issue Sep 4, 2022
A simple check for CommonCrypto/CommonRandom.h does not work on earlier macOS.
Must also pull in sys/types.h for size_t, Availability.h for __OSX_AVAILABLE_STARTING,
and CommonCrypto/CommonCryptoError.h for CCCryptorStatus.

Closes GH-9479.
@devnexen
Copy link
Member

devnexen commented Sep 4, 2022

Fix merged, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants