Opened 18 months ago
Closed 8 months ago
#67259 closed defect (fixed)
libocca fails to build with Clang on < 10.12: clock_get_time, mach_port_deallocate
Reported by: | barracuda156 | Owned by: | barracuda156 |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.8.1 |
Keywords: | Cc: | ||
Port: | libocca |
Description
Two issues are there:
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_devel_libocca/libocca/work/occa-1.5.0/src/occa/internal/utils/sys.cpp:94:7: error: use of undeclared identifier 'clock_get_time'; did you mean 'clock_gettime'? clock_get_time(cclock, &ct); ^~~~~~~~~~~~~~ clock_gettime /opt/local/include/LegacySupport/time.h:55:12: note: 'clock_gettime' declared here extern int clock_gettime( clockid_t clk_id, struct timespec *ts ); ^ /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_devel_libocca/libocca/work/occa-1.5.0/src/occa/internal/utils/sys.cpp:94:30: error: cannot initialize a parameter of type 'struct timespec *' with an rvalue of type 'mach_timespec_t *' (aka 'mach_timespec *') clock_get_time(cclock, &ct); ^~~ /opt/local/include/LegacySupport/time.h:55:62: note: passing argument to parameter 'ts' here extern int clock_gettime( clockid_t clk_id, struct timespec *ts ); ^
And:
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_devel_libocca/libocca/work/occa-1.5.0/src/occa/internal/utils/sys.cpp:96:7: error: use of undeclared identifier 'mach_port_deallocate' mach_port_deallocate(mach_task_self(), cclock); ^
(legacysupport
currently is used for < 10.7, but with Clang build it does not help.)
Example of the log: https://build.macports.org/builders/ports-10.6_x86_64-builder/builds/146182/steps/install-port/logs/stdio
Attachments (1)
Change History (7)
comment:1 Changed 18 months ago by ryandesign (Ryan Carsten Schmidt)
comment:2 follow-up: 3 Changed 18 months ago by ryandesign (Ryan Carsten Schmidt)
Don't really know why this code is checking for __clang__
at all in either of the two places. All we care about is whether the OS has clock_gettime_nsec_np
, which was introduced in macOS 10.12 along with clock_gettime
(although legacysupport doesn't have clock_gettime_nsec_np
; see #61691).
Changed 18 months ago by ryandesign (Ryan Carsten Schmidt)
Attachment: | 0003-Check-for-CLOCK_UPTIME_RAW-on-macOS-before-using-it.patch added |
---|
untested guess of a fix
comment:3 Changed 18 months ago by barracuda156
Replying to ryandesign:
Don't really know why this code is checking for
__clang__
at all in either of the two places. All we care about is whether the OS hasclock_gettime_nsec_np
, which was introduced in macOS 10.12 along withclock_gettime
(although legacysupport doesn't haveclock_gettime_nsec_np
; see #61691).
Me neither, but I assumed there was some sense behind that. The issue was, I guess, that I should have amended the define in both places identically, and since that was not done, needed headers for clock_get_time
and mach_port_deallocate
did not get included on systems without CLOCK_UPTIME_RAW in combination with Clang. Since neither Macports CI nor my local testing machine fit this, that went unnoticed.
I will amend the patch: indeed, why check for Clang there at all.
comment:4 Changed 18 months ago by ryandesign (Ryan Carsten Schmidt)
Alternately, if you want to guard against the port's behavior possibly changing if #61691 gets implemented, instead of checking if CLOCK_UPTIME_RAW
is defined, you could check if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
as in 0001-sys.cpp-fix-for-macOS-use-numerical-constant-instead.patch.
comment:5 Changed 18 months ago by barracuda156
comment:6 Changed 8 months ago by barracuda156
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
clock_gettime
is a standard cross-platform function that made its first appearance on macOS in version 10.12. legacysupport provides an implementation of it for 10.11 and earlier systems. But this port isn't including legacysupport in order to getclock_gettime
; it's including it to getgetline
.clock_get_time
on the other hand is a macOS (Mach kernel) function available since version 10.0: https://developer.apple.com/documentation/kernel/1420035-clock_get_timemach_port_deallocate
is too: https://developer.apple.com/documentation/kernel/1578777-mach_port_deallocateIf the build says these functions are undeclared, the fix might simply be to include the header where they're declared, which is <mach/mach_port.h>. However I see there is also a <mach/mach.h> which includes mach_port.h among other things; maybe it is preferred to include mach.h.
I see that occa already does include Mach headers in src/occa/internal/utils/sys.cpp, and around there I see another instance if
#ifdef __clang__
that might need the same fix as the one already being applied further down in the file by 0003-Check-for-CLOCK_UPTIME_RAW-on-macOS-before-using-it.patch.