BIC-MNI / libminc

libminc is the core library and API of the MINC toolkit
Other
19 stars 29 forks source link

Use of clock_gettime() on macOS needs conditionalization #96

Closed seanm closed 5 years ago

seanm commented 6 years ago

The clock_gettime() API was (finally) added in macOS 10.12; it is not present in earlier versions.

libminc is checking that clock_gettime() is present on the machine that's doing the compiling, but that's no guarantee that it's present on the machine that runs the code. ex: if I build libminc on 10.13, but try to run the resulting executables on 10.10, they will crash.

There are a number of ways we could solve this.

1) KWSys for example doesn't merely check that clock_gettime() exists in the headers, but compiles a little test app:

https://gitlab.kitware.com/utils/kwsys/blob/master/kwsysPlatformTestsC.c

That way, HAVE_CLOCK_GETTIME will be false if the deployment target < 10.12.

2) We could directly add an Apple-only deployment target check in libminc's time.c.

seanm commented 6 years ago

@vfonov we can submit a patch once we agree on the preferred solution...

vfonov commented 6 years ago

so, i am usually building for Mac OS X 10.8 , to be compatible with people who didn't upgrade. Maybe it's better to make sure it's not used on mac builds ?

gdevenyi commented 5 years ago

When folks update their OSX version the existing minc-toolkit-v2/1.9.17 binary release no longer works with a bug about this.

vfonov commented 5 years ago

What does the bug say?

gdevenyi commented 5 years ago

From OS X Yosemite (10.10.3):

dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
Referenced from: /opt/minc/1.9.17/bin/Display
Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _clock_gettime
Referenced from: /opt/minc/1.9.17/bin/Display
Expected in: /usr/lib/libSystem.B.dylib

Trace/BPT trap: 5

Installed from: https://packages.bic.mni.mcgill.ca/minc-toolkit/MacOSX/minc-toolkit-1.9.17-20180808-Darwin-10.10-x86_64.dmg

vfonov commented 5 years ago

So, it looks like the bug is in the old build from 2018?

gdevenyi commented 5 years ago

Yes, and no. That build is old, but is also the "newest" OSX build available: https://packages.bic.mni.mcgill.ca/minc-toolkit/MacOSX/?C=M;O=D

vfonov commented 5 years ago

still, from before this bug was fixed