Skip to content

zend_hrtime: Fix build for macOS without clock_gettime_nsec_np() #17437

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

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

jorgsowa
Copy link
Contributor

One declaration was missed in #17089 and because of that complication is failing.

Example:

/Users/x/php-src/Zend/zend_hrtime.h:92:47: error: use of undeclared identifier 'zend_hrtime_timerlib_info'
92 | return (zend_hrtime_t)mach_absolute_time() * zend_hrtime_timerlib_info.numer / zend_hrtime_timerlib_info.denom;

@TimWolla
Copy link
Member

Thank you, the change looks good to me. Can you clarify which macOS version you are using on what hardware so we can add that to the commit message? My understanding is that all recent macOS systems support the ZEND_HRTIME_PLATFORM_APPLE_GETTIME_NSEC variant.

@jorgsowa
Copy link
Contributor Author

That's true, but because ZEND_HRTIME_PLATFORM_APPLE is not defined then mach/mach_time.h is not imported and the functions are not available. I'm using macOS 15.2 so the latest one.

@TimWolla
Copy link
Member

is not defined then mach/mach_time.h is not imported and the functions are not available

Yes, clock_gettime_nsec_np is sitting in time.h, so it's intentional to not import mach_time.h for use of clock_gettime_nsec_np. If the build fails for you and succeeds with this PR, then this means that clock_gettime_nsec_np is not getting used for you, which is suprising given you are running on macOS 15.2.

To double check my understanding is correct: Can you confirm that ./configure reports clock_gettime_nsec_np ... no for you?

@jorgsowa
Copy link
Contributor Author

It displays correctly checking whether clock_gettime_nsec_np is declared... yes. So everything works correctly except for cases where clock_gettime_nsec_np is not available so probably for older systems.

@TimWolla
Copy link
Member

It displays correctly checking whether clock_gettime_nsec_np is declared... yes.

Okay, then I don't understand why this bug failed the build for you. Or did you find this by reading the code?

@jorgsowa
Copy link
Contributor Author

I didn't run the script ./buildconf before I ran ./configure.... So for the first time it failed, I found the issue in the code and I created the PR.

Afterward, I ran all the setup to compile PHP and everything worked well. As I use the newset macOS I only suppose it may cause issues on older machines.

Copy link
Member

@TimWolla TimWolla left a comment

Choose a reason for hiding this comment

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

Thank you for clarifying!

@TimWolla TimWolla changed the title zend_hrtime: fix for macOS zend_hrtime: Fix build for macOS without clock_gettime_nsec_np() Jan 16, 2025
@TimWolla TimWolla merged commit ac2ce94 into php:master Jan 16, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants