Modify

#12617 closed Bugs (fixed)

clock_gettime not available on OS X 10.11

Reported by: djh Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.61.0 Severity: Problem
Keywords: Cc:

Description

Looks like the Boost.Interprocess check for clock_gettime does not correctly handle OS X 10.11.

(see os_thread_functions.hpp)

Here is a small self-contained test case triggering on OS X 10.11 with xcode8:

$ xcodebuild -version
Xcode 8.1
Build version 8B62
#include <iostream>
#include <boost/interprocess/detail/os_thread_functions.hpp>

int main() {
    boost::interprocess::ipcdetail::get_current_system_highres_count();
    std::clog << "hello" << "\n";
    return 0;
}
$ clang++ -o t t.cpp -Imason_packages/headers/boost/1.61.0/include/ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -Wl,-bind_at_load

$ ./t
dyld: Symbol not found: _clock_gettime
  Referenced from: /Users/dane/projects/osrm-backend/./t (which was built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib
 in /Users/dane/projects/osrm-backend/./t
Trace/BPT trap: 5

Downstream ticket is at: https://github.com/Project-OSRM/osrm-backend/issues/3297#issuecomment-262037848

Seems like is does not trigger on OS X 10.12, though.

Attachments (0)

Change History (4)

comment:1 Changed 12 months ago by Ion Gaztañaga

In theory clock_gettime is used if BOOST_INTERPROCESS_CLOCK_MONOTONIC is defined. This is defined if one of the following is defined:

CLOCK_MONOTONIC_PRECISE bsd

CLOCK_MONOTONIC_RAW linux

CLOCK_HIGHRES solaris

Is any of those defined in macos 10.11? In theory the implementation should use a mac-os specific code calling match kernel functions (BOOST_INTERPROCESS_MATCH_ABSOLUTE_TIME should be defined).

Could you please check why BOOST_INTERPROCESS_MATCH_ABSOLUTE_TIME is not defined in mac os 10.11?

comment:2 Changed 10 months ago by Chris Newbold

It appears that the macOS 10.12 SDK, which is what is used with XCode 8, defines both CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW which then causes Boost.Interprocess to follow the Linux branch and reach for clock_gettime. That works fine when actually running on a 10.12 machine, but 10.11 does not have clock_gettime so you get a busted executable that dies at runtime with an unresolved external.

Unfortunately Apple does not condition the definition of these macros on the deployment target, so even telling XCode 8 that you're targeting 10.11 results in references to clock_gettime.

comment:3 Changed 10 months ago by rjain

We applied the following patch. So even if CLOCK_MONOTINIC and CLOCK_MONOTONIC_RAW are defined we explicitly include "mach_time.h". Hence no reference to _clock_gettime()

//Xcode 8 fix due to ::clock_gettime issue
#  if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__))
#     include <mach/mach_time.h>  // mach_absolute_time, mach_timebase_info_data_t
#     define BOOST_INTERPROCESS_MATCH_ABSOLUTE_TIME
#  elif defined(CLOCK_MONOTONIC_PRECISE)   //BSD
#     define BOOST_INTERPROCESS_CLOCK_MONOTONIC CLOCK_MONOTONIC_PRECISE
#  elif defined(CLOCK_MONOTONIC_RAW)     //Linux
#     define BOOST_INTERPROCESS_CLOCK_MONOTONIC CLOCK_MONOTONIC_RAW
#  elif defined(CLOCK_HIGHRES)           //Solaris
#     define BOOST_INTERPROCESS_CLOCK_MONOTONIC CLOCK_HIGHRES
#  elif defined(CLOCK_MONOTONIC)         //POSIX (AIX, BSD, Linux, Solaris)
#     define BOOST_INTERPROCESS_CLOCK_MONOTONIC CLOCK_MONOTONIC

comment:4 Changed 10 months ago by Ion Gaztañaga

Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ion Gaztañaga.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.