View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002007 | Xdebug | Installation | public | 2021-08-12 06:54 | 2021-10-04 09:29 |
Reporter | ryandesign | Assigned To | derick | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | x86_64 | OS | OS X | OS Version | 10.11 |
Product Version | 3.0.4 | ||||
Target Version | 3.1dev | Fixed in Version | 3.1.0 | ||
Summary | 0002007: xdebug 3.x fails to build on OS X 10.11 or earlier due to clock_gettime_nsec_np requirement | ||||
Description | Hi, I'm the maintainer of [[https://ports.macports.org/port/php-xdebug|xdebug in MacPorts]], and [[https://trac.macports.org/ticket/63350|a user reported]] that xdebug 3.0.4 does not build on their Mac running OS X 10.11. The errors are:
The problem is that functions ''clock_gettime'', ''clock_gettime_nsec_np'', and related constants were introduced in macOS 10.12. The problem started in xdebug 3 due to [[https://github.com/xdebug/xdebug/commit/632c8a04fad70fefa5fd5e1005270f3e07c76789|this commit]] which introduced the use of ''clock_gettime'' for Linux and ''clock_gettime_nsec_np'' for macOS. It looks like on Linux xdebug allows for the situation where the OS does not support ''clock_gettime''. Might that be extended to macOS as well? | ||||
Steps To Reproduce | Build xdebug 3 or later on OS X 10.11 or earlier. | ||||
Tags | No tags attached. | ||||
Operating System | OS X 10.11 | ||||
PHP Version | 8.0.0-8.0.4 | ||||
|
Sorry, my use of Mantis formatting codes did not work as I intended and I don't see a way to edit my report to correct the problem. |
|
I don't have access to OSX 10.11 (or any OSX, beside 10.15 through Azure Pipelines), but I believe the branch issue2007-osx1011-timing on GitHub should fix the problem: Can you check that branch yourself to verify this perhaps? And also run the tests (https://github.com/xdebug/xdebug#testing)? |
|
This does build on OS X 10.11, thanks. Configure output says: checking for gettimeofday... yes and presumably the functionality based on clock_gettime or clock_gettime_nsec_np is not included. How important is this functionality? In MacPorts we have a library of compatibility functions for older systems and we do have an implementation of clock_gettime but don't have clock_gettime_nsec_np yet. If I include that library on 10.11, then configure output says: checking for gettimeofday... yes and the build still succeeds and presumably now uses clock_gettime. Is xdebug better when it can use clock_gettime such that it would be preferable for MacPorts to include this compatibility library?
I have not run the tests before so I cannot be sure that I'm doing it correctly. On 10.11 with this change I get 47 test failures but on macOS 10.13 without this change (but with more PHP extensions installed) I get 90 test failures (including the same 47 that failed on 10.11) so I do not believe this change causes any new problems. |
|
I had missed that OSX 10.11 does support clock_gettime, as although it is checked for, it is not used for OSX. It instead falls back to gettimeofday. For most purposes, this is totally usable. The ultra high precision of clock_gettime(_nsec_np) is hardly ever goign to be noticable, so I wouldn't worry about including your compatibility library. Running just the Xdebug tests with "php run-xdebug-tests.php" (and xdebug.so enabled in your standard php.ini (php --ini) with "zend_extension=xdebug.so") should not see any test failures though. So I'm kind of interesting to see the output of that command. |
|
To clarify: macOS 10.12 introduced support for clock_gettime, clock_gettime_nsec_np, and whatever other related defines and functionality exist; OS X 10.11 and earlier do not have them. MacPorts has a compatibility library that we can insert that provides an implementation of clock_gettime for 10.11 and older but we have not yet written a compatibility implementation of clock_gettime_nsec_np. Unless I misunderstand, after your changes, and with the MacPorts compatibility library providing clock_gettime on 10.11, your code will follow the "Linux/Unix with clock_gettime" code path and define a xdebug_get_nanotime_rel function that uses clock_gettime. In xdebug_nanotime_init, because defined(CLOCK_MONOTONIC) (it is defined in the modified system headers provided by the MacPorts compatibility library), context.use_rel_time will be set to 1. And in xdebug_nanotime_init and xdebug_get_nanotime, again because defined(CLOCK_MONOTONIC), xdebug_get_nanotime_rel will be called. If we do not include the MacPorts compatibility library, then there will be no clock_gettime function, no CLOCK_MONOTONIC define, and a xdebug_get_nanotime_rel function will not be defined or called, and then you fall back to using xdebug_get_nanotime_abs which calls gettimeofday. I've attached the test results from 10.11. |
|
I have now merged the PR/branch into master. I did make a few tweaks to use more of I also had a look at your test failures, and it seems to me that the tests were not run against the newly built .so file, as there are test failures, and changes in output, that are present in the new code in the master branch, but not in older versions. I am going to guess you didn't run a "make install" before running the tests. That's no big deal, but it would probably explain why you have so many failures. |
|
I had the same issue when trying to install the latest xdebug version (3.0.X) on my OS X 10.11 Mac with Homebrew. I now tested the 3.1 beta release (3.1.0beta2).
|
|
|
|
FWIW, if any of you are interested in this being fixed, I do need to some assistance, for example by answering my questions. Xdebug 3.1 is going to be released next week, and it would be a shame if this issue wasn't addressed. |
|
@derick I cloned the repo so I could try building current master. The build failed in the same way. I attached the output of configure as well as the configure.log. I then applied your diff and ran phpize, configure and make again. Sadly, make exited with the same error as described previously (Maybe not relevant but make also seemed to error out much faster than before applying the diff). I also attached the output of configure and configure.log of that try (see files with -withdiff suffix). Error output with the diff applied (just the line numbers changed):
|
|
Your config.log includes:
And your configure-output file:
Which seems plausible. If this is not found, then HAVE_CLOCK_GETTIME should not be set. The code that you say ("I cloned the repo so I could try building current master.") doesn't compile has this in the "master" branch at the moment:
Line 126 (where you see your error), doesn't have a clock_gettime line, and it also should never try to compile this code because HAVE_CLOCK_GETTIME is not set. Something seems wrong on your side. Can you show all the exact steps, from the beginning, with a cleanly checked out GIT repository in a new directory? |
|
Thank you for looking into my reported details of the issue. The error output of make I provided in my last comment was WITH the provided patch for src/lib/timing.c applied. The patch added 6 lines to the file hence the line with “clock_gettime” is offset by 6 lines (Line 126 instead of 120) when compared to master. I kept calling the patch “diff” in my previous comment, I’m sorry if that caused any confusion. I will follow up with a step by step description of my process with a freshly cloned repo (and no patch) shortly. |
|
Here are the step by step instructions of what I’m doing (also see the attachments for the full outputs):
|
|
Ok, besides the different line numbers... this is still baffling as configure output says:
Which means that HAVE_CLOCK_GETTIME does not get defined, but your preprocessor still doesn't remove the bit that uses clock_gettime, which is keyed for by HAVE_CLOCK_GETTIME. Would you mind zipping/tarring up the current state of /tmp/xdebug3, and attaching that? |
|
I found where HAVE_CLOCK_GETTIME is defined but I cannot make much sense of it. I managed to figure out that HAVE_CLOCK_GETTIME was, in fact, set to 1.
I then laced some relevant files with this snipped trying to figure out where HAVE_CLOCK_GETTIME was being set.
Since these don’t exist in the project I searched my php installations. I found the file that set HAVE_CLOCK_GETTIME: /usr/local/Cellar//php/8.0.10/include/php/main/php_config.h
Changing that line to the following let make compile xdebug without an issue.
With that the problem lies somewhat out of the scope of xdebug I think. But I don’t understand why this was set in my PHP installation in the first place. |
|
Thanks for doing that investigation. I think I might have a way to solve this without having to "hack" the PHP include files. I've prepared the "better-clock-checks" branch, which I think should solve this problem. Could you:
|
|
Thank you for the update. Make built successfully with only one warning (see attachments for full outputs):
But even doe xdebug was successfully compiled, after enabling it, php was throwing the following error whenever called:
Output of the grep command (step 5):
|
|
I think I have just pushed a fix for this. Could you check again with the same steps? There is an extra commit on the branch, so a "git pull" should fetch that. |
|
It'd be great of you could have a look @MergeMarc — I'd love to have this in this week's Xdebug 3.1.0 release. |
|
Sorry for the delayed response. I just started college and it can take me a few days sometimes to test things again. I pulled the changes. Sadly, make now outputs a bunch of errors:
|
|
OK, that was my bad and I forgot to update a line. I suppose I couldn't have temporary access to a user account if the commit that I've just pushed didn't resolve this? |
|
I pulled the fix. The compilation and install works fine now! I also tested line by line debugging with it and that also works without any issues. Here are the answers to questions you asked earlier: Output of “php -r 'xdebug_info();' | grep Clock”:
Output of “grep -r XDEBUG_CLOCK config.h”:
|
|
Excellent! I'll merge and close this then. |
|
|
Date Modified | Username | Field | Change |
---|---|---|---|
2021-08-12 06:54 | ryandesign | New Issue | |
2021-08-12 06:55 | ryandesign | Note Added: 0005974 | |
2021-08-12 17:59 | derick | Assigned To | => derick |
2021-08-12 17:59 | derick | Status | new => feedback |
2021-08-12 17:59 | derick | Note Added: 0005975 | |
2021-08-12 17:59 | derick | Description Updated | |
2021-08-13 11:00 | ryandesign | Note Added: 0005976 | |
2021-08-13 11:00 | ryandesign | Status | feedback => assigned |
2021-08-13 13:14 | derick | Status | assigned => feedback |
2021-08-13 13:14 | derick | Note Added: 0005977 | |
2021-08-13 13:45 | ryandesign | Note Added: 0005978 | |
2021-08-13 13:45 | ryandesign | File Added: php_test_results_20210813_1039.txt.bz2 | |
2021-08-13 13:45 | ryandesign | Status | feedback => assigned |
2021-08-15 18:26 | derick | Status | assigned => feedback |
2021-08-15 18:26 | derick | Note Added: 0005979 | |
2021-09-14 16:00 | MergeMarc | Note Added: 0006005 | |
2021-09-16 08:47 | derick | Status | feedback => acknowledged |
2021-09-16 08:47 | derick | Target Version | => 3.1dev |
2021-09-19 09:26 | derick | Status | acknowledged => feedback |
2021-09-19 09:26 | derick | Note Added: 0006019 | |
2021-09-19 09:27 | derick | Note Edited: 0006005 | |
2021-09-22 13:25 | derick | Note Added: 0006031 | |
2021-09-23 10:11 | MergeMarc | Note Added: 0006035 | |
2021-09-23 10:11 | MergeMarc | File Added: config.log | |
2021-09-23 10:11 | MergeMarc | File Added: config.log-withdiff | |
2021-09-23 10:11 | MergeMarc | File Added: configure-output | |
2021-09-23 10:11 | MergeMarc | File Added: configure-output-withdiff | |
2021-09-23 12:50 | derick | Note Added: 0006036 | |
2021-09-23 13:25 | MergeMarc | Note Added: 0006038 | |
2021-09-23 13:52 | MergeMarc | Note Added: 0006039 | |
2021-09-23 13:52 | MergeMarc | File Added: config-2.log | |
2021-09-23 13:52 | MergeMarc | File Added: output-configure | |
2021-09-23 13:52 | MergeMarc | File Added: output-make | |
2021-09-23 13:52 | MergeMarc | File Added: output-phpize | |
2021-09-23 14:32 | derick | Note Added: 0006040 | |
2021-09-23 16:54 | MergeMarc | Note Added: 0006044 | |
2021-09-24 13:50 | derick | Note Added: 0006048 | |
2021-09-24 16:26 | MergeMarc | Note Added: 0006049 | |
2021-09-24 16:26 | MergeMarc | File Added: config-3.log | |
2021-09-24 16:26 | MergeMarc | File Added: output-configure_clock-checks | |
2021-09-24 16:26 | MergeMarc | File Added: output-make_clock-checks | |
2021-09-24 16:26 | MergeMarc | File Added: output-make-install_clock-checks | |
2021-09-24 16:26 | MergeMarc | File Added: output-phpize_clock-checks | |
2021-09-26 16:00 | derick | Note Added: 0006051 | |
2021-09-28 13:55 | derick | Note Added: 0006055 | |
2021-09-29 14:14 | MergeMarc | Note Added: 0006059 | |
2021-09-29 14:14 | MergeMarc | File Added: config-4.log | |
2021-09-29 14:14 | MergeMarc | File Added: output-configure-2 | |
2021-09-29 14:14 | MergeMarc | File Added: output-make-2 | |
2021-09-29 14:14 | MergeMarc | File Added: output-phpize-2 | |
2021-09-29 15:03 | derick | Note Added: 0006060 | |
2021-09-29 15:24 | MergeMarc | Note Added: 0006061 | |
2021-09-29 16:58 | derick | Note Added: 0006062 | |
2021-09-29 17:00 | derick | Status | feedback => closed |
2021-09-29 17:00 | derick | Resolution | open => fixed |
2021-09-29 17:00 | derick | Fixed in Version | => 3.1dev |
2021-09-29 17:00 | derick | Note Added: 0006063 | |
2021-09-30 12:29 | derick | File Deleted: configure-output-withdiff | |
2021-09-30 12:29 | derick | File Deleted: config.log | |
2021-09-30 12:29 | derick | File Deleted: output-phpize-2 | |
2021-09-30 12:30 | derick | File Deleted: output-make-2 | |
2021-09-30 12:30 | derick | File Deleted: output-configure-2 | |
2021-09-30 12:30 | derick | File Deleted: config-4.log | |
2021-09-30 12:30 | derick | File Deleted: output-phpize_clock-checks | |
2021-09-30 12:30 | derick | File Deleted: output-make-install_clock-checks | |
2021-09-30 12:30 | derick | File Deleted: output-make_clock-checks | |
2021-09-30 12:30 | derick | File Deleted: output-configure_clock-checks | |
2021-09-30 12:30 | derick | File Deleted: config-3.log | |
2021-09-30 12:31 | derick | File Deleted: config.log-withdiff | |
2021-09-30 12:31 | derick | File Deleted: configure-output | |
2021-09-30 12:31 | derick | File Deleted: config-2.log | |
2021-09-30 12:31 | derick | File Deleted: output-configure | |
2021-09-30 12:31 | derick | File Deleted: output-phpize | |
2021-09-30 12:31 | derick | File Deleted: output-make | |
2021-10-04 09:29 | derick | Fixed in Version | 3.1dev => 3.1.0 |