Skip to content

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

Closed
@debohman

Description

@debohman

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions