Opened 3 years ago

Closed 3 years ago

#63350 closed defect (fixed)

php80-xdebug: error: use of undeclared identifier 'CLOCK_UPTIME_RAW'

Reported by: mav2287 (James) Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version:
Keywords: elcapitan Cc:
Port: php-xdebug

Description

I'm running an El Cap Xserve and can't seem to get Xdebug to compile. I am using php80-xdebug, but also went back and found out it won't compile on El Cap for any older versions of PHP as well.

Attachments (2)

main.log (521.5 KB) - added by mav2287 (James) 3 years ago.
This is the output of my main.log for the build
config.log (12.2 KB) - added by mav2287 (James) 3 years ago.
Config log for Xdebug patch that failed to compile on El Cap

Download all attachments as: .zip

Change History (13)

Changed 3 years ago by mav2287 (James)

Attachment: main.log added

This is the output of my main.log for the build

comment:1 Changed 3 years ago by mav2287 (James)

Since the error in the log was pretty vague I ran the cd and make commands it was complaining about form there terminal and go the following output:

# cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4"
# /usr/bin/make -j16 -w all 
make: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4'
Makefile:245: warning: overriding commands for target `test'
Makefile:132: warning: ignoring old commands for target `test'
/bin/sh /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/libtool --mode=compile /usr/bin/clang -I. -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4 -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/main -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4 -I/opt/local/include/php80/php -I/opt/local/include/php80/php/main -I/opt/local/include/php80/php/TSRM -I/opt/local/include/php80/php/Zend -I/opt/local/include/php80/php/ext -I/opt/local/include/php80/php/ext/date/lib -I/opt/local/include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/src  -I/opt/local/include -I/opt/local/include/LegacySupport -DHAVE_CONFIG_H  -pipe -Os -I/opt/local/include/LegacySupport -arch x86_64     -c /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/src/lib/timing.c -o src/lib/timing.lo 
/bin/sh /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/libtool --mode=compile /usr/bin/clang -I. -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4 -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/main -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4 -I/opt/local/include/php80/php -I/opt/local/include/php80/php/main -I/opt/local/include/php80/php/TSRM -I/opt/local/include/php80/php/Zend -I/opt/local/include/php80/php/ext -I/opt/local/include/php80/php/ext/date/lib -I/opt/local/include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/src  -I/opt/local/include -I/opt/local/include/LegacySupport -DHAVE_CONFIG_H  -pipe -Os -I/opt/local/include/LegacySupport -arch x86_64     -c /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/src/tracing/tracing.c -o src/tracing/tracing.lo 
 /usr/bin/clang -I. -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4 -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/main -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4 -I/opt/local/include/php80/php -I/opt/local/include/php80/php/main -I/opt/local/include/php80/php/TSRM -I/opt/local/include/php80/php/Zend -I/opt/local/include/php80/php/ext -I/opt/local/include/php80/php/ext/date/lib -I/opt/local/include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/src -I/opt/local/include -I/opt/local/include/LegacySupport -DHAVE_CONFIG_H -pipe -Os -I/opt/local/include/LegacySupport -arch x86_64 -c /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/src/lib/timing.c  -fno-common -DPIC -o src/lib/.libs/timing.o
 /usr/bin/clang -I. -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4 -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/main -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4 -I/opt/local/include/php80/php -I/opt/local/include/php80/php/main -I/opt/local/include/php80/php/TSRM -I/opt/local/include/php80/php/Zend -I/opt/local/include/php80/php/ext -I/opt/local/include/php80/php/ext/date/lib -I/opt/local/include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/src -I/opt/local/include -I/opt/local/include/LegacySupport -DHAVE_CONFIG_H -pipe -Os -I/opt/local/include/LegacySupport -arch x86_64 -c /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/src/tracing/tracing.c  -fno-common -DPIC -o src/tracing/.libs/tracing.o
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/src/lib/timing.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_UPTIME_RAW);
               ^
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4/src/lib/timing.c:111:31: error: use of undeclared identifier 'CLOCK_UPTIME_RAW'
        return clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
                                     ^
1 warning and 1 error generated.
make: *** [src/lib/timing.lo] Error 1
make: *** Waiting for unfinished jobs....
make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xdebug-3.0.4'

comment:2 Changed 3 years ago by jmroot (Joshua Root)

Owner: set to ryandesign
Status: newassigned

comment:3 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

In 4df3cf479782aef353d2e3ad44197679ad81cd0b/macports-ports (master):

php-xdebug: Remove legacy support portgroup

Remove legacy support portgroup which does not fix the build failure on
El Capitan and earlier.

See: #61691
See: #63350

comment:4 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Keywords: PHP Xdebug removed
Port: php-xdebug added; php80-xdebug removed
Status: assignedaccepted
Summary: Xdebug not building on El Capitanphp80-xdebug: error: use of undeclared identifier 'CLOCK_UPTIME_RAW'

I've reported this problem to the developers of xdebug.

On macOS, xdebug 3 and later unconditionally uses clock_gettime_nsec_np but this function, together with clock_gettime and related constants, is only in macOS 10.12 and later, therefore the port cannot build on earlier versions of macOS.

MacPorts has a legacy support library which contains implementations of several newer functions such as clock_gettime that are not in older operating systems. I added legacy support to this port in an attempt to fix this, but it didn't work because we don't have an implementation of clock_gettime_nsec_np there yet. I requested the addition of this function to legacy support but it has not yet been done. If you or anyone would like to assist in adding an implementation of this function to our legacy support library that would be welcome and would help further our ability to support newer software on older operating systems.

In fact xdebug already contains several codepaths in this area, one of which (for Linux) uses clock_gettime, so we could perhaps use that codepath together with our legacy support instead of their clock_gettime_nsec_np Mac codepath to fix this problem in MacPorts, but an upstream solution that works for all users, not just MacPorts users, is preferable.

It even looks like this entire functionality within xdebug is optional. On Linux versions without clock_gettime, it looks like no error should occur. So that may be another solution. I don't know how xdebug uses these functions so it would be up to them to decide the best solution.

xdebug's code is:

// Mac
// should be fast but can be relative
#elif __APPLE__
static uint64_t xdebug_get_nanotime_rel(xdebug_nanotime_context *nanotime_context)
{
	return clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
}

// Linux/Unix with clock_gettime
#elif defined(CLOCK_MONOTONIC)
static uint64_t xdebug_get_nanotime_rel(xdebug_nanotime_context *nanotime_context)
{
	struct timespec ts;

	if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
		return (uint64_t)ts.tv_sec * NANOS_IN_SEC + (uint64_t)ts.tv_nsec;
	}

	return 0;
}
#endif

comment:5 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

In 0ddb8ae2e33029bdaf936e3c0755693707dd1c4d/macports-ports (master):

php-xdebug: Downgrade to 2.9.8 for OS X <= 10.11

Downgrade to 2.9.8 for OS X 10.11 and earlier since xdebug 3 and later
use clock_gettime_nsec_np on macOS which is not in 10.11 or earlier nor
in legacy support.

See: #61691
See: #63350

comment:6 Changed 3 years ago by mav2287 (James)

Just tried the patch and it still doesn't want to compile. Below is the output I get and I have attached the config.log file.

Error: Failed to configure php80-xdebug: consult /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/work/xde[[Image()]]bug-2.9.8/config.log
Error: Failed to configure php80-xdebug: configure failure: command execution failed
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_php_php-xdebug/php80-xdebug/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there is a bug.
Error: Processing of port php80-xdebug failed

Changed 3 years ago by mav2287 (James)

Attachment: config.log added

Config log for Xdebug patch that failed to compile on El Cap

comment:7 Changed 3 years ago by kencu (Ken)

Chris and I had a chat about what to do about functions like clock_gettime_nsec_np that the OS version cannot support for technical/hardware reasons.

The purist response is to leave them unsupported. The practical response is to give a best-we-can microsecond version emulation.

I lean to the practical. I doubt the nanosecond version is usually needed (it's just used because it exists). But there might be cases where I'm wrong. (Even if so, anyone programming a SpaceX launch on macOS 10.8 is an idiot.)

But that's the main reason clock_gettime_nsec_np and a couple of similar functions are not yet in legacysupport.

comment:8 Changed 3 years ago by mav2287 (James)

Not sure if it counts for anything, but my vote is for the practical. There are still A LOT of apple machines that don't support 10.12+, but that are still workhorses. I have a pair of Xserves that have proven indestructible. We may use the latest and greatest in our production environment, but for development the Xserve is great.

comment:9 in reply to:  6 ; Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to mav2287:

Just tried the patch and it still doesn't want to compile.

Yes, that's correct. Per your config.log:

error: not supported. Need a PHP version >= 7.1.0 and < 8.0.0 (found 8.0.9)

Sorry, xdebug 2.9.8 is not compatible with PHP 8. You can use PHP 7.4 or earlier.

The developers of xdebug have proposed a fix which I will test out.

comment:10 in reply to:  9 Changed 3 years ago by mav2287 (James)

Replying to ryandesign:

The developers of xdebug have proposed a fix which I will test out.

Saw that they pushed some code on the XDebug project. Let me know if you me to test to see if it installs correctly.

comment:11 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Keywords: elcapitan added
Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.