php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81137 Build failure on OS X 10.11 and earlier due to use of clock_gettime_nsec_np
Submitted: 2021-06-14 11:37 UTC Modified: 2021-06-14 16:27 UTC
From: php-bugs-2021 at ryandesign dot com Assigned: krakjoe (profile)
Status: Closed Package: Compile Failure
PHP Version: 8.1.0alpha1 OS: OS X 10.11.5
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php-bugs-2021 at ryandesign dot com
New email:
PHP Version: OS:

 

 [2021-06-14 11:37 UTC] php-bugs-2021 at ryandesign dot com
Description:
------------
Hi, php 8.1.0alpha1 does not build on OS X 10.11 ("El Capitan") and earlier because of:


/path/to/php-8.1.0alpha1/ext/standard/hrtime.c:111:9: warning: implicit declaration of function 'clock_gettime_nsec_np' is invalid in C99 [-Wimplicit-function-declaration]
        return clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW);
               ^
/path/to/php-8.1.0alpha1/ext/standard/hrtime.c:111:31: error: use of undeclared identifier 'CLOCK_MONOTONIC_RAW'
        return clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW);
                                     ^
1 warning and 1 error generated.
make: *** [ext/standard/hrtime.lo] Error 1


Here's a full build log if you would like it:

https://build.macports.org/builders/ports-10.11_x86_64-builder/builds/144512/steps/install-port/logs/stdio

php 8.0.x and earlier were able to build on these older OS X versions.

clock_gettime and related functions were not in the operating system prior to macOS 10.12 ("Sierra").

In php 8.0.x, I already noticed a similar problem with just the opcache extension and I applied a workaround in MacPorts that adds a compatibility implementation of these functions via the MacPorts "legacy support" library. Here's our implementation:

https://github.com/macports/macports-legacy-support/blob/master/include/time.h
https://github.com/macports/macports-legacy-support/blob/master/src/time.c

But now in php 8.1.x the build failure affects php as a whole.

We don't have a compatibility implementation of clock_gettime_nsec_np in MacPorts legacy support yet (https://trac.macports.org/ticket/61691) so we are not able to work around it by adding our library here.

Looks like this problem was caused in php commit a3e55286a676fdf4f5919d219e2a0df93f817211 ("Using a more modern and simpler api available since Sierra (2016).")

Since you had an apparently working implementation before, perhaps you can have a configure test that checks for clock_gettime, uses it if available, and otherwise uses the older implementation.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-14 11:40 UTC] rtrtrtrtrt at dfdfdfdf dot dfd35
> Looks like this problem was caused in php commit 
> a3e55286a676fdf4f5919d219e2a0df93f817211
> "Using a more modern and simpler api available since Sierra (2016)

and why can one not update to a newer OS 5 years later or use PHP8.0 on old OS?
 [2021-06-14 11:41 UTC] cmb@php.net
See the discussion on <https://github.com/php/php-src/pull/6609>.
 [2021-06-14 12:24 UTC] krakjoe@php.net
-Assigned To: +Assigned To: krakjoe
 [2021-06-14 12:28 UTC] krakjoe@php.net
-Status: Assigned +Status: Closed
 [2021-06-14 12:28 UTC] krakjoe@php.net
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from https://github.com/php/php-src and re-test.
Thank you for the report, and for helping us make PHP better.

Fixed in 72c0deb4009e1ddfdccd2b353e0a839ffe10d81a
 [2021-06-14 16:27 UTC] php-bugs-2021 at ryandesign dot com
Thanks. As a result of this change, php81 is now available in MacPorts at least as far back as Mac OS X 10.6 ("Snow Leopard"), like previous php versions were.

I find it valuable to have php available on as many systems as possible, including older ones. There are still plenty of Macs in service that are too old to be updated to macOS 10.12 or newer. Scripting languages like php can be an important component in repurposing older machines for a second life. There may also be students who only have access to such older computers but who still want to learn php.

While it is only a small sample size, among those MacPorts users who have php 8.0.x installed and chose to submit usage statistics in the past 30 days, 44% of them were running OS X versions earlier than 10.12.

https://ports.macports.org/port/php80/stats?days=30&days_ago=0
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC