Opened 5 years ago

Closed 13 months ago

Last modified 10 months ago

#61691 closed enhancement (fixed)

legacy-support: add clock_gettime_nsec_np and CLOCK_UPTIME_RAW

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: fhgwright (Fred Wright)
Priority: Normal Milestone:
Component: legacy-support Version:
Keywords: Cc: snowflake (Dave Evans), mascguy (Christopher Nielsen)
Port: legacy-support, php-xdebug

Description

php-xdebug 3.0.0 fails to build on OS X 10.11 and earlier, even when legacysupport is used:

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);
               ^
src/lib/timing.c:111:31: error: use of undeclared identifier 'CLOCK_UPTIME_RAW'
        return clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
                                     ^

Is adding support for clock_gettime_nsec_np and CLOCK_UPTIME_RAW feasible?

Change History (17)

comment:1 Changed 5 years ago by kencu (Ken)

As of OS X 10.12, the clock handling in darwin became more finely resolved. There is also an issue now building libcxx-11 (which is part of building clang-11) on < 10.12 due to this clock issue.

The libcxx source code had a fallback that was used until recently, when it was deleted here here.

To get newer clangs building on older systems we'll have to reinstate that fallback, and perhaps it might in the end be done in legacysupport... have to look at it closely to see how it fits in with what we already have there, and whether it might serve as the basis for this missing function.

comment:2 Changed 5 years ago by snowflake (Dave Evans)

Can I put in a request for these from sbcl?

runtime.c:401:5: warning: implicit declaration of function 'clock_gettime' is invalid in C99 [-Wimplicit-function-declaration]
    clock_gettime(
    ^
runtime.c:405:9: error: use of undeclared identifier 'CLOCK_MONOTONIC'
        CLOCK_MONOTONIC
        ^

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

Cc: snowflake added

Dave, legacy support already implements clock_gettime and CLOCK_MONOTONIC.

comment:4 Changed 5 years ago by kencu (Ken)

making sbcl use legacysupport is hard, so I patched it instead...did I not push that patch yet? Silly me.

comment:6 Changed 5 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:7 Changed 5 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:8 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Port: libbson added

libbson is now affected by this as well.

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

Port: libbson removed

Eh, only because their code is stupid. They also support clock_gettime so including legacysupport fixed it.

comment:10 Changed 19 months ago by mascguy (Christopher Nielsen)

Cc: mascguy fhgwright added

Fred, what are your thoughts on this?

comment:11 in reply to:  10 ; Changed 19 months ago by fhgwright (Fred Wright)

Replying to mascguy:

Fred, what are your thoughts on this?

Seems plausible in principle, though I haven't looked at the details yet. Feel free to assign it to me, though I don't want to worry about it for this release cycle. Given that it's a four-year old ticket, I don't imagine there's a rush. :-)

I was planning to review old tickets at some point. There's also one PR that's almost two years old, and may or may not still be relevant.

BTW, in spite of what's claimed in the "their code is stupid" link, clock_gettime wasn't introduced until 10.12.

Last edited 19 months ago by fhgwright (Fred Wright) (previous) (diff)

comment:12 in reply to:  11 ; Changed 16 months ago by mascguy (Christopher Nielsen)

Cc: fhgwright removed
Owner: set to fhgwright
Status: newassigned

Replying to fhgwright:

Replying to mascguy:

Fred, what are your thoughts on this?

Seems plausible in principle, though I haven't looked at the details yet. Feel free to assign it to me, though I don't want to worry about it for this release cycle.

Support for this would definitely be useful, as we need it for new port mozjs128:

mozjs128/work/mozjs-128.1.0/mozglue/misc/AwakeTimeStamp.cpp:64:25: error: use of undeclared identifier 'clock_gettime_nsec_np'

comment:13 in reply to:  12 Changed 16 months ago by fhgwright (Fred Wright)

Replying to mascguy:

Replying to fhgwright:

Replying to mascguy:

Fred, what are your thoughts on this?

Seems plausible in principle, though I haven't looked at the details yet. Feel free to assign it to me, though I don't want to worry about it for this release cycle.

Support for this would definitely be useful, as we need it for new port mozjs128:

mozjs128/work/mozjs-128.1.0/mozglue/misc/AwakeTimeStamp.cpp:64:25: error: use of undeclared identifier 'clock_gettime_nsec_np'

My intent, after finishing some mostly "cleanup" changes, is to review the open tickets (and PR) to see which might be straightforward enough to include in this release cycle. One problem with anything clock-related is that it's hard to write an automated test for something that's a moving target, and the existing clock test is mainly just a manual test masquerading as an automated test, requiring manual scrutiny of the output for validity. At least the rewritten version no longer treats out-and-out failures of the functions being tested as a "pass" (exposing one real bug in the process). :-)

comment:14 Changed 13 months ago by fhgwright (Fred Wright)

Resolution: fixed
Status: assignedclosed

In 8e3a750ba4e6f238d476c353c39ae6a549e08605/macports-legacy-support (master):

Implement interim clock_gettime_nsec_np().

Closes: #61691

Since a proper implementation of clock_gettime_nsec_np() would be
significant work, and should be accompanied by some needed rework of
time.c and test_time.c in general, for now we just provide a wrapper
around clock_gettime(). This is functionally correct but suboptimal
in performance.

It also cleans up the scale factors, converting the fairly pointless
THOUSAND to a number, removing the unused MILLIONS, and replacing
BILLIONS with separate 32- and 64-bit versions, both now explictly
unsigned.

It also cleans up some include issues.

TESTED:
Passes all tests on all platforms, including added test.

comment:15 Changed 13 months ago by fhgwright (Fred Wright)

In e5cdc7ae6e22afebb2a5df15e7588dfdc2662fd9/macports-ports (master):

legacy-support-devel: Update to latest master.

Notable changes since last -devel version:

  • Fixes 10.4 Rosetta bug in fstatx_np()
  • Makes renameat() available via stdio.h See: #71842
  • Implements interim clock_gettime_nsec_np() See: #61691
  • Implements clock_settime() See: #71399
  • Adds net/if_tun.h for <10.6 See: #70231
  • Provides pthread_[f]chdir_np() for 10.5+ See: #71265
  • Adds CPU_TYPE_ARM definition for 10.4 See: #71621

Also adds Portfile comments regarding suggested github.tarball_from
change.

Also, the prior addition of vdprintf() in v20241026 neglected to close
the related tickets:

Closes: #67598
Closes: #70118

TESTED:
Tested both normal and -devel versions -/+universal on 10.4-10.5 ppc,
10.5-10.6 ppc (i386 Rosetta), 10.4-10.6 i386, 10.4-12.x x86_64, and
11.x-15.x arm64.
Builds and passes all tests on all tested platforms.

comment:16 Changed 12 months ago by fhgwright (Fred Wright)

In a784d15ced04e75724ee259cec1f7a3d1ab696d3/macports-ports (master):

legacy-support: update to v1.4.0.

Notable changes since v1.3.0:

  • Works around Apple's broken versioning in the macOS 15 SDK
  • Implements scandir() compatibility feature
  • Fixes dprintf() bug and implements vdprintf() See: #67598 See: #70118
  • Mismatched SDK compatibility is extended to include 15.x SDK.
  • Broken 10.4 CLOCK_MONOTONIC is fixed.
  • Fixes stat inconsistency in some 32-bit 10.4 builds.
  • Adds stat64 header support for 10.4 SDK.
  • Adds INODE64 support for *stat*() on 10.4.
  • Reworks fstatat*() support, similar to previous item, fixing buffer overrun in some cases.
  • Backports 10.5 'which' to 10.4.
  • Adds support for code that can't tolerate the normal scandir() compatibility feature.
  • Replaces broken 10.4/10.5 copyfile wrapper with full 10.6 copyfile.
  • Extends 10.4 INODE64 support to *statx_np() functions.
  • Expands TARGET_* defaults. See: #70824
  • Fixes 10.4 Rosetta bug in fstatx_np()
  • Makes renameat() available via stdio.h See: #71842
  • Implements interim clock_gettime_nsec_np() See: #61691
  • Implements clock_settime() See: #71399
  • Adds net/if_tun.h for <10.6 See: #70231
  • Provides pthread_[f]chdir_np() for 10.5+ See: #71265
  • Adds CPU_TYPE_ARM definition for 10.4 See: #71621

TESTED:
Tested both normal and -devel versions -/+universal on 10.4-10.5 ppc,
10.5-10.6 ppc (i386 Rosetta), 10.4-10.6 i386, 10.4-12.x x86_64, and
11.x-15.x arm64.
Builds and passes all tests on all tested platforms.

comment:17 Changed 10 months ago by mascguy (Christopher Nielsen)

Component: portslegacy-support

Recategorize existing legacy-support lib tickets, to use new component definition.

Note: See TracTickets for help on using tickets.