Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xz broken on OSX 10.11.6 Beta (15G24b) with XCode 8 Beta #2674

Closed
x8x opened this issue Jul 3, 2016 · 33 comments
Closed

xz broken on OSX 10.11.6 Beta (15G24b) with XCode 8 Beta #2674

x8x opened this issue Jul 3, 2016 · 33 comments
Labels
clock_gettime CI fails due to clock_gettime symbol

Comments

@x8x
Copy link

x8x commented Jul 3, 2016

xz installs fine, but when called it crashes with:

Dyld Error Message:
  Symbol not found: _clock_gettime
  Referenced from: /usr/local/opt/xz/bin/xz
  Expected in: /usr/lib/libSystem.B.dylib

commenting out this line:

#undef HAVE_CLOCK_GETTIME

in xz-5.2.2/config.h.in fixes it.

I see here #1957 that there are known issues about clock_gettime related to OSX 10.12 but not sure why they also apply to OSX 10.11.6 Beta.

Unrelated (sorry!) , have some issue with python3 but didn't dig in further:

==> Upgrading httpie
==> Installing dependencies for httpie: python3
==> Installing httpie dependency: python3
==> Downloading https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
Already downloaded: /Users/alpha/Library/Caches/Homebrew/python3-3.5.2.tar.xz
==> ./configure --prefix=/usr/local/Cellar/python3/3.5.2 --enable-ipv6 --datarootdir=/usr/local/Cellar/python3/3.5.2/share --datadir=/usr/local/Cellar
==> make
Last 15 lines from /Users/alpha/Library/Logs/Homebrew/python3/02.make:
  Expected in: /usr/lib/dyld: Symbol not found: _getentropy
  Referenced from: /private/tmp/python3-20160703-71169-isiobw/Python-3.5.2/./Programs/_freeze_importlib
  Expected in: /usr/lib/libSystem.B.dylib

libSystem.B.dylib

dyld: Symbol not found: _getentropy
  Referenced from: /private/tmp/python3-20160703-71169-isiobw/Python-3.5.2/./Programs/_freeze_importlib
  Expected in: /usr/lib/libSystem.B.dylib

/bin/sh: line 1: 78637 Trace/BPT trap: 5       ./Programs/_freeze_importlib ./Lib/importlib/_bootstrap.py Python/importlib.h
make: *** [Python/importlib.h] Error 133
make: *** Waiting for unfinished jobs....
/bin/sh: line 1: 78636 Trace/BPT trap: 5       ./Programs/_freeze_importlib ./Lib/importlib/_bootstrap_external.py Python/importlib_external.h
make: *** [Python/importlib_external.h] Error 133
@DomT4
Copy link
Member

DomT4 commented Jul 3, 2016

So, running the Xcode 8 beta on 10.11 is possible but you may see issues that impact 10.12 suddenly start hitting you as well. @mistydemeo Do you have feelings on changing the Sierra patches to apply to El Cap as well, or do we want to essentially shun Xcode 8 for 10.11 until stable?

Edit - typo, sigh.

@DomT4 DomT4 added the user configuration User configuration rather than a Homebrew issue label Jul 3, 2016
@mistydemeo
Copy link
Member

I wonder if this is possibly a 10.12 SDK on 10.11 issue? I wouldn't expect 10.11.6 to actually define clock_gettime.

@x8x Can you provide the logs from brew gist-logs xz for a failed build?

@DomT4
Copy link
Member

DomT4 commented Jul 4, 2016

Could this be a reincarnation of the issue @UniqMartin (I think) identified before with the single SDK for both macOS/OS X versions, where the .tbd file declares a symbol unconditionally despite that symbol actually only being available in the library for one version of the possible macOS/OS X release.

So in this case libSystem.tbd in Xcode 8 Beta would declare there's a _clock_gettime symbol, which xz then expects, but because the .tbd files are almost glorified symlinks when the actual runtime link of /usr/lib/libSystem.B.dylib is called the executable goes "Huh, where did _clock_gettime go?".

@mistydemeo
Copy link
Member

I don't have the Xcode 8 beta installed, only the CLT; can someone who has it provide the .tbd?

@DomT4
Copy link
Member

DomT4 commented Jul 4, 2016

libSystem.B.tbd

--- !tapi-tbd-v2
archs:           [ i386, x86_64 ]
uuids:           [ 'i386: B2A4618E-5D19-3897-A7E8-DECD759A56BE', 'x86_64: F3A36220-3968-3E23-8CB4-00E5864FB868' ]
platform:        macosx
install-name:    /usr/lib/libSystem.B.dylib
current-version: 1237.0
objc-constraint: none
exports:         
  - archs:           [ i386, x86_64 ]
    re-exports:      [ /usr/lib/system/libcache.dylib, /usr/lib/system/libcommonCrypto.dylib, 
                       /usr/lib/system/libcompiler_rt.dylib, /usr/lib/system/libcopyfile.dylib, 
                       /usr/lib/system/libcorecrypto.dylib, /usr/lib/system/libdispatch.dylib, 
                       /usr/lib/system/libdyld.dylib, /usr/lib/system/libkeymgr.dylib, 
                       /usr/lib/system/liblaunch.dylib, /usr/lib/system/libmacho.dylib, 
                       /usr/lib/system/libquarantine.dylib, /usr/lib/system/libremovefile.dylib, 
                       /usr/lib/system/libsystem_asl.dylib, /usr/lib/system/libsystem_blocks.dylib, 
                       /usr/lib/system/libsystem_c.dylib, /usr/lib/system/libsystem_configuration.dylib, 
                       /usr/lib/system/libsystem_coreservices.dylib, /usr/lib/system/libsystem_coretls.dylib, 
                       /usr/lib/system/libsystem_dnssd.dylib, /usr/lib/system/libsystem_info.dylib, 
                       /usr/lib/system/libsystem_kernel.dylib, /usr/lib/system/libsystem_m.dylib, 
                       /usr/lib/system/libsystem_malloc.dylib, /usr/lib/system/libsystem_network.dylib, 
                       /usr/lib/system/libsystem_networkextension.dylib, /usr/lib/system/libsystem_notify.dylib, 
                       /usr/lib/system/libsystem_platform.dylib, /usr/lib/system/libsystem_pthread.dylib, 
                       /usr/lib/system/libsystem_sandbox.dylib, /usr/lib/system/libsystem_secinit.dylib, 
                       /usr/lib/system/libsystem_symptoms.dylib, /usr/lib/system/libsystem_trace.dylib, 
                       /usr/lib/system/libunwind.dylib, /usr/lib/system/libxpc.dylib ]
    symbols:         [ 'R8289209$_close', 'R8289209$_fork', 'R8289209$_fsync', 'R8289209$_getattrlist', 
                       'R8289209$_getrlimit', 'R8289209$_getxattr', 'R8289209$_open', 
                       'R8289209$_pthread_attr_destroy', 'R8289209$_pthread_attr_init', 
                       'R8289209$_pthread_attr_setdetachstate', 'R8289209$_pthread_create', 
                       'R8289209$_pthread_mutex_lock', 'R8289209$_pthread_mutex_unlock', 
                       'R8289209$_pthread_self', 'R8289209$_ptrace', 'R8289209$_read', 
                       'R8289209$_setattrlist', 'R8289209$_setrlimit', 'R8289209$_sigaction', 
                       'R8289209$_stat', 'R8289209$_sysctl', 'R8289209$_time', 'R8289209$_unlink', 
                       'R8289209$_write', ___System_BVersionNumber, ___System_BVersionString, 
                       ___crashreporter_info__, _libSystem_atfork_child, _libSystem_atfork_parent, 
                       _libSystem_atfork_prepare, _mach_init_routine ]
...

Referenced libsystem_c.tdb

--- !tapi-tbd-v2
archs:           [ i386, x86_64 ]
uuids:           [ 'i386: 1844DBE2-514C-3CE8-97FD-04862D90F4F3', 'x86_64: 7EB6BC9C-E7DE-3F0F-890E-0FC478A6F034' ]
platform:        macosx
install-name:    /usr/lib/system/libsystem_c.dylib
current-version: 1138.0
objc-constraint: none
parent-umbrella: System
exports:         
  - archs:           [ i386 ]
    symbols:         [ __NSSetProgramVars, ___fdnlist, '___opendir2$INODE64$UNIX2003', 
                       '___opendir2$UNIX2003', '___strtodg$UNIX2003', '__seekdir$INODE64$UNIX2003', 
                       '__seekdir$UNIX2003', __tztab, '_clock$UNIX2003', '_closedir$UNIX2003', 
                       '_confstr$UNIX2003', '_creat$NOCANCEL$UNIX2003', '_creat$UNIX2003', 
                       '_encrypt$UNIX2003', '_fdopen$UNIX2003', '_fdopendir$INODE64$UNIX2003', 
                       '_fdopendir$UNIX2003', '_fnmatch$UNIX2003', '_fopen$UNIX2003', 
                       '_fputs$UNIX2003', '_freopen$UNIX2003', '_ftw$INODE64$UNIX2003', 
                       '_ftw$UNIX2003', '_fwrite$UNIX2003', '_getopt$UNIX2003', '_killpg$UNIX2003', 
                       _kvm_close, _kvm_getargv, _kvm_getenvv, _kvm_geterr, _kvm_getfiles, 
                       _kvm_getloadavg, _kvm_getprocs, _kvm_nlist, _kvm_open, _kvm_openfiles, 
                       _kvm_read, _kvm_uread, _kvm_write, '_lockf$NOCANCEL$UNIX2003', 
                       '_lockf$UNIX2003', '_mktime$UNIX2003', _msgctl, '_nanosleep$NOCANCEL$UNIX2003', 
                       '_nanosleep$UNIX2003', '_nftw$INODE64$UNIX2003', '_nftw$UNIX2003', 
                       '_nice$UNIX2003', _nlist, '_opendir$INODE64$UNIX2003', '_opendir$UNIX2003', 
                       '_pause$NOCANCEL$UNIX2003', '_pause$UNIX2003', '_popen$UNIX2003', 
                       '_putenv$UNIX2003', '_realpath$UNIX2003', '_recv$NOCANCEL$UNIX2003', 
                       '_recv$UNIX2003', '_regcomp$UNIX2003', '_rewinddir$INODE64$UNIX2003', 
                       '_rewinddir$UNIX2003', '_seekdir$INODE64$UNIX2003', '_seekdir$UNIX2003', 
                       _semctl, '_send$NOCANCEL$UNIX2003', '_send$UNIX2003', '_setenv$UNIX2003', 
                       '_setkey$UNIX2003', '_setmode$UNIX2003', '_setpgrp$UNIX2003', 
                       _setregid, _setreuid, _shmctl, '_sigaltstack$UNIX2003', '_sigpause$NOCANCEL$UNIX2003', 
                       '_sigpause$UNIX2003', '_sleep$NOCANCEL$UNIX2003', '_sleep$UNIX2003', 
                       '_strerror$UNIX2003', '_strftime$UNIX2003', '_strftime_l$UNIX2003', 
                       '_strptime$UNIX2003', '_strptime_l$UNIX2003', '_strtod$UNIX2003', 
                       '_strtod_l$UNIX2003', '_strtof$UNIX2003', '_strtof_l$UNIX2003', 
                       '_system$NOCANCEL$UNIX2003', '_system$UNIX2003', '_tcdrain$NOCANCEL$UNIX2003', 
                       '_tcdrain$UNIX2003', '_telldir$INODE64$UNIX2003', '_telldir$UNIX2003', 
                       '_tempnam$UNIX2003', '_timezone$UNIX2003', '_ttyname_r$UNIX2003', 
                       '_unsetenv$UNIX2003', '_usleep$NOCANCEL$UNIX2003', '_usleep$UNIX2003', 
                       '_wait$NOCANCEL$UNIX2003', '_wait$UNIX2003', '_waitpid$NOCANCEL$UNIX2003', 
                       '_waitpid$UNIX2003', '_wcsftime$UNIX2003', '_wcsftime_l$UNIX2003' ]
  - archs:           [ x86_64 ]
    symbols:         [ '___opendir2$INODE64', '__seekdir$INODE64', '_creat$NOCANCEL', 
                       '_fdopendir$INODE64', '_ftw$INODE64', '_lockf$NOCANCEL', '_nanosleep$NOCANCEL', 
                       '_nftw$INODE64', _off32, _off64, '_opendir$INODE64', '_pause$NOCANCEL', 
                       '_recv$NOCANCEL', '_rewinddir$INODE64', '_seekdir$INODE64', 
                       '_send$NOCANCEL', _setpgrp, _sigaltstack, '_sigpause$NOCANCEL', 
                       _skip, '_sleep$NOCANCEL', '_system$NOCANCEL', '_tcdrain$NOCANCEL', 
                       '_telldir$INODE64', '_usleep$NOCANCEL', '_wait$NOCANCEL', 
                       '_waitpid$NOCANCEL' ]
  - archs:           [ i386, x86_64 ]
    symbols:         [ __CurrentRuneLocale, __DefaultRuneLocale, __Exit, __NSGetArgc, 
                       __NSGetArgv, __NSGetEnviron, __NSGetMachExecuteHeader, __NSGetProgname, 
                       __PathLocale, __Read_RuneMagi, ___Balloc_D2A, ___Bfree_D2A, 
                       ___ULtod_D2A, ____mb_cur_max, ____mb_cur_max_l, ____runetype, 
                       ____runetype_l, ____tolower, ____tolower_l, ____toupper, ____toupper_l, 
                       ___add_ovflpage, ___addel, ___any_on_D2A, ___assert_rtn, ___b2d_D2A, 
                       ___big_delete, ___big_insert, ___big_keydata, ___big_return, 
                       ___big_split, ___bigtens_D2A, ___bt_close, ___bt_cmp, ___bt_defcmp, 
                       ___bt_defpfx, ___bt_delete, ___bt_dleaf, ___bt_fd, ___bt_free, 
                       ___bt_get, ___bt_new, ___bt_open, ___bt_pgin, ___bt_pgout, 
                       ___bt_put, ___bt_ret, ___bt_search, ___bt_seq, ___bt_setcur, 
                       ___bt_split, ___bt_sync, ___buf_free, ___cVersionNumber, ___cVersionString, 
                       ___call_hash, ___cleanup, ___cmp_D2A, ___collate_equiv_match, 
                       ___collate_load_error, ___collate_lookup, ___copybits_D2A, 
                       ___cxa_atexit, ___cxa_finalize, ___cxa_finalize_ranges, ___cxa_thread_atexit, 
                       ___d2b_D2A, ___dbpanic, ___decrement_D2A, ___default_hash, 
                       ___default_utx, ___delpair, ___diff_D2A, ___dtoa, ___expand_table, 
                       ___fflush, ___fgetwc, ___find_bigpair, ___find_last_page, 
                       ___fix_locale_grouping_str, ___fread, ___free_ovflpage, ___freedtoa, 
                       ___gdtoa, ___gdtoa_locks, ___get_buf, ___get_page, ___gethex_D2A, 
                       ___getonlyClocaleconv, ___hash_open, ___hdtoa, ___hexdig_D2A, 
                       ___hexdig_init_D2A, ___hexnan_D2A, ___hi0bits_D2A, ___hldtoa, 
                       ___i2b_D2A, ___ibitmap, ___increment_D2A, ___isctype, ___istype, 
                       ___istype_l, ___ldtoa, ___libc_init, ___lo0bits_D2A, ___log2, 
                       ___lshift_D2A, ___maskrune, ___maskrune_l, ___match_D2A, ___mb_cur_max, 
                       ___mb_sb_limit, ___memccpy_chk, ___memcpy_chk, ___memmove_chk, 
                       ___memset_chk, ___mult_D2A, ___multadd_D2A, ___nrv_alloc_D2A, 
                       ___opendir2, ___ovfl_delete, ___ovfl_get, ___ovfl_put, ___pow5mult_D2A, 
                       ___put_page, ___quorem_D2A, ___ratio_D2A, ___rec_close, ___rec_delete, 
                       ___rec_dleaf, ___rec_fd, ___rec_fmap, ___rec_fpipe, ___rec_get, 
                       ___rec_iput, ___rec_open, ___rec_put, ___rec_ret, ___rec_search, 
                       ___rec_seq, ___rec_sync, ___rec_vmap, ___rec_vpipe, ___reclaim_buf, 
                       ___rshift_D2A, ___rv_alloc_D2A, ___s2b_D2A, ___sF, ___sclose, 
                       ___sdidinit, ___set_ones_D2A, ___setonlyClocaleconv, ___sflags, 
                       ___sflush, ___sfp, ___sfvwrite, ___sglue, ___sinit, ___slbexpand, 
                       ___smakebuf, ___snprintf_chk, ___split_page, ___sprintf_chk, 
                       ___sread, ___srefill, ___srget, ___sseek, ___stack_chk_fail, 
                       ___stack_chk_guard, ___stderrp, ___stdinp, ___stdoutp, ___stpcpy_chk, 
                       ___stpncpy_chk, ___strcat_chk, ___strcp_D2A, ___strcpy_chk, 
                       ___strlcat_chk, ___strlcpy_chk, ___strncat_chk, ___strncpy_chk, 
                       ___strtodg, ___strtopdd, ___strtopx, ___sum_D2A, ___svfscanf, 
                       ___swbuf, ___swhatbuf, ___swrite, ___swsetup, ___tens_D2A, 
                       ___tinytens_D2A, ___tolower, ___tolower_l, ___toupper, ___toupper_l, 
                       ___trailz_D2A, ___ulp_D2A, ___ungetc, ___ungetwc, ___vsnprintf_chk, 
                       ___vsprintf_chk, ___wcwidth, ___wcwidth_l, __allocenvstate, 
                       __atexit_receipt, __c_locale, __cleanup, __closeutx, __copyenv, 
                       __cthread_init_routine, __deallocenvstate, __endutxent, __flockfile_debug_stub, 
                       __fseeko, __ftello, __fwalk, __getenvp, __getutxent, __getutxid, 
                       __getutxline, __inet_aton_check, __init_clock_port, __int_to_time, 
                       __libc_fork_child, __libc_initializer, __long_to_time, __mkpath_np, 
                       __mktemp, __openutx, __os_assert_log, __os_assert_log_ctx, 
                       __os_assumes_log, __os_assumes_log_ctx, __os_avoid_tail_call, 
                       __os_crash, __os_crash_callback, __os_debug_log, __os_debug_log_error_str, 
                       __putenvp, __pututxline, __rand48_add, __rand48_mult, __rand48_seed, 
                       __readdir_unlocked, '__readdir_unlocked$INODE64', __reclaim_telldir, 
                       __seekdir, __setenvp, __setutxent, __sigaction_nobind, __sigintr, 
                       __signal_nobind, __sigvec_nobind, __sread, __sseek, __swrite, 
                       __time32_to_time, __time64_to_time, __time_to_int, __time_to_long, 
                       __time_to_time32, __time_to_time64, __unsetenvp, __utmpxname, 
                       _a64l, _abort, _abort_report_np, _abs, _acl_add_flag_np, _acl_add_perm, 
                       _acl_calc_mask, _acl_clear_flags_np, _acl_clear_perms, _acl_copy_entry, 
                       _acl_copy_ext, _acl_copy_ext_native, _acl_copy_int, _acl_copy_int_native, 
                       _acl_create_entry, _acl_create_entry_np, _acl_delete_def_file, 
                       _acl_delete_entry, _acl_delete_fd_np, _acl_delete_file_np, 
                       _acl_delete_flag_np, _acl_delete_link_np, _acl_delete_perm, 
                       _acl_dup, _acl_free, _acl_from_text, _acl_get_entry, _acl_get_fd, 
                       _acl_get_fd_np, _acl_get_file, _acl_get_flag_np, _acl_get_flagset_np, 
                       _acl_get_link_np, _acl_get_perm_np, _acl_get_permset, _acl_get_permset_mask_np, 
                       _acl_get_qualifier, _acl_get_tag_type, _acl_init, _acl_maximal_permset_mask_np, 
                       _acl_set_fd, _acl_set_fd_np, _acl_set_file, _acl_set_flagset_np, 
                       _acl_set_link_np, _acl_set_permset, _acl_set_permset_mask_np, 
                       _acl_set_qualifier, _acl_set_tag_type, _acl_size, _acl_to_text, 
                       _acl_valid, _acl_valid_fd_np, _acl_valid_file_np, _acl_valid_link, 
                       _addr2ascii, _alarm, _alphasort, '_alphasort$INODE64', _arc4random, 
                       _arc4random_addrandom, _arc4random_buf, _arc4random_stir, 
                       _arc4random_uniform, _ascii2addr, _asctime, _asctime_r, _asprintf, 
                       _asprintf_l, _asxprintf, _asxprintf_exec, _atexit, _atexit_b, 
                       _atof, _atof_l, _atoi, _atoi_l, _atol, _atol_l, _atoll, _atoll_l, 
                       _backtrace, _backtrace_symbols, _backtrace_symbols_fd, _basename, 
                       _bcmp, _bcopy, _brk, _bsd_signal, _bsearch, _bsearch_b, _btowc, 
                       _btowc_l, _bzero, _catclose, _catgets, _catopen, _cfgetispeed, 
                       _cfgetospeed, _cfmakeraw, _cfsetispeed, _cfsetospeed, _cfsetspeed, 
                       _cgetcap, _cgetclose, _cgetent, _cgetfirst, _cgetmatch, _cgetnext, 
                       _cgetnum, _cgetset, _cgetstr, _cgetustr, _chmodx_np, _clearerr, 
                       _clearerr_unlocked, _clock, _clock_getres, '_clock_getres$DARWIN_EXTSN', 
                       _clock_gettime, '_clock_gettime$DARWIN_EXTSN', _clock_gettime_nsec_np, 
                       _clock_port, _clock_sem, _clock_settime, _closedir, _compat_mode, 
                       _confstr, _copy_printf_domain, _creat, _crypt, _ctermid, _ctermid_r, 
                       _ctime, _ctime_r, _daemon, '_daemon$1050', _daylight, _dbm_clearerr, 
                       _dbm_close, _dbm_delete, _dbm_dirfno, _dbm_error, _dbm_fetch, 
                       _dbm_firstkey, _dbm_nextkey, _dbm_open, _dbm_store, _dbopen, 
                       _devname, _devname_r, _difftime, _digittoint, _digittoint_l, 
                       _dirfd, _dirname, _div, _dprintf, _dprintf_l, _drand48, _duplocale, 
                       _dxprintf, _dxprintf_exec, _ecvt, _encrypt, _endttyent, _endusershell, 
                       _endutxent, _endutxent_wtmp, _erand48, _err, _err_set_exit, 
                       _err_set_exit_b, _err_set_file, _errc, _errx, _execl, _execle, 
                       _execlp, _execv, _execvP, _execvp, _exit, _f_prealloc, _fchmodx_np, 
                       _fclose, _fcvt, _fdopen, '_fdopen$DARWIN_EXTSN', _fdopendir, 
                       _feof, _feof_unlocked, _ferror, _ferror_unlocked, _fflagstostr, 
                       _fflush, _fgetc, _fgetln, _fgetpos, _fgetrune, _fgets, _fgetwc, 
                       _fgetwc_l, _fgetwln, _fgetwln_l, _fgetws, _fgetws_l, _fileno, 
                       _fileno_unlocked, _filesec_dup, _filesec_free, _filesec_get_property, 
                       _filesec_init, _filesec_query_property, _filesec_set_property, 
                       _filesec_unset_property, _flockfile, _fmtcheck, _fmtmsg, _fnmatch, 
                       _fopen, '_fopen$DARWIN_EXTSN', _fork, _forkpty, _fparseln, 
                       _fprintf, _fprintf_l, _fpurge, _fputc, _fputrune, _fputs, 
                       _fputwc, _fputwc_l, _fputws, _fputws_l, _fread, _free_printf_comp, 
                       _free_printf_domain, _freelocale, _freopen, _fscanf, _fscanf_l, 
                       _fseek, _fseeko, _fsetpos, _fstatvfs, _fstatx64_np, _fstatx_np, 
                       '_fstatx_np$INODE64', _fsync_volume_np, _ftell, _ftello, _ftime, 
                       _ftok, _ftrylockfile, _fts_children, '_fts_children$INODE64', 
                       _fts_close, '_fts_close$INODE64', _fts_open, '_fts_open$INODE64', 
                       _fts_open_b, '_fts_open_b$INODE64', _fts_read, '_fts_read$INODE64', 
                       _fts_set, '_fts_set$INODE64', _ftw, _fungetrune, _funlockfile, 
                       _funopen, _fwide, _fwprintf, _fwprintf_l, _fwrite, _fwscanf, 
                       _fwscanf_l, _fxprintf, _fxprintf_exec, _gcvt, _getbsize, _getc, 
                       _getc_unlocked, _getchar, _getchar_unlocked, _getcwd, _getdate, 
                       _getdate_err, _getdelim, _getdiskbyname, _getenv, '_getgroups$DARWIN_EXTSN', 
                       _gethostid, _gethostname, _getipv4sourcefilter, _getlastlogx, 
                       _getlastlogxbyname, _getline, _getloadavg, _getlogin, _getlogin_r, 
                       _getmntinfo, '_getmntinfo$INODE64', _getmntinfo64, _getmode, 
                       _getopt, _getopt_long, _getopt_long_only, _getpagesize, _getpass, 
                       _getpeereid, _getprogname, _gets, _getsourcefilter, _getsubopt, 
                       _gettimeofday, _getttyent, _getttynam, _getusershell, _getutmp, 
                       _getutmpx, _getutxent, _getutxent_wtmp, _getutxid, _getutxline, 
                       _getvfsbyname, _getw, _getwc, _getwc_l, _getwchar, _getwchar_l, 
                       _getwd, _glob, '_glob$INODE64', _glob_b, '_glob_b$INODE64', 
                       _globfree, _gmtime, _gmtime_r, _grantpt, _hash_create, _hash_destroy, 
                       _hash_purge, _hash_search, _hash_stats, _hash_traverse, _hcreate, 
                       _hdestroy, _heapsort, _heapsort_b, _hsearch, _imaxabs, _imaxdiv, 
                       _index, _inet_addr, _inet_aton, _inet_lnaof, _inet_makeaddr, 
                       _inet_net_ntop, _inet_net_pton, _inet_neta, _inet_netof, _inet_network, 
                       _inet_nsap_addr, _inet_nsap_ntoa, _inet_ntoa, _inet_ntop, 
                       _inet_ntop4, _inet_ntop6, _inet_pton, _initstate, _insque, 
                       _isalnum, _isalnum_l, _isalpha, _isalpha_l, _isascii, _isatty, 
                       _isblank, _isblank_l, _iscntrl, _iscntrl_l, _isdigit, _isdigit_l, 
                       _isgraph, _isgraph_l, _ishexnumber, _ishexnumber_l, _isideogram, 
                       _isideogram_l, _islower, _islower_l, _isnumber, _isnumber_l, 
                       _isphonogram, _isphonogram_l, _isprint, _isprint_l, _ispunct, 
                       _ispunct_l, _isrune, _isrune_l, _isspace, _isspace_l, _isspecial, 
                       _isspecial_l, _isupper, _isupper_l, _iswalnum, _iswalnum_l, 
                       _iswalpha, _iswalpha_l, _iswascii, _iswblank, _iswblank_l, 
                       _iswcntrl, _iswcntrl_l, _iswctype, _iswctype_l, _iswdigit, 
                       _iswdigit_l, _iswgraph, _iswgraph_l, _iswhexnumber, _iswhexnumber_l, 
                       _iswideogram, _iswideogram_l, _iswlower, _iswlower_l, _iswnumber, 
                       _iswnumber_l, _iswphonogram, _iswphonogram_l, _iswprint, _iswprint_l, 
                       _iswpunct, _iswpunct_l, _iswrune, _iswrune_l, _iswspace, _iswspace_l, 
                       _iswspecial, _iswspecial_l, _iswupper, _iswupper_l, _iswxdigit, 
                       _iswxdigit_l, _isxdigit, _isxdigit_l, _jrand48, _kOSThermalNotificationPressureLevelName, 
                       _killpg, _l64a, _labs, _lchflags, _lchmod, _lcong48, _ldiv, 
                       _lfind, _link_addr, _link_ntoa, _llabs, _lldiv, _localeconv, 
                       _localeconv_l, _localtime, _localtime_r, _lockf, _login, _login_tty, 
                       _logout, _logwtmp, _lrand48, _lsearch, _lstatx64_np, _lstatx_np, 
                       '_lstatx_np$INODE64', _lutimes, _mblen, _mblen_l, _mbmb, _mbrlen, 
                       _mbrlen_l, _mbrrune, _mbrtowc, _mbrtowc_l, _mbrune, _mbsinit, 
                       _mbsinit_l, _mbsnrtowcs, _mbsnrtowcs_l, _mbsrtowcs, _mbsrtowcs_l, 
                       _mbstowcs, _mbstowcs_l, _mbtowc, _mbtowc_l, _memccpy, _memchr, 
                       _memcmp, _memcpy, _memmem, _memmove, _memset, _memset_pattern16, 
                       _memset_pattern4, _memset_pattern8, _memset_s, _mergesort, 
                       _mergesort_b, _mkdirx_np, _mkdtemp, _mkfifox_np, _mkostemp, 
                       _mkostemps, _mkpath_np, _mkstemp, _mkstemp_dprotected_np, 
                       _mkstemps, _mktemp, _mktime, _monaddition, _moncontrol, _moncount, 
                       _moninit, _monitor, _monoutput, _monreset, _monstartup, _mpool_close, 
                       _mpool_filter, _mpool_get, _mpool_new, _mpool_open, _mpool_put, 
                       _mpool_sync, _mrand48, _nanosleep, _new_printf_comp, _new_printf_domain, 
                       _newlocale, _nextwctype, _nextwctype_l, _nftw, _nice, _nl_langinfo, 
                       _nl_langinfo_l, _nrand48, _nvis, _offtime, _opendev, _opendir, 
                       _openpty, _openx_np, _optarg, _opterr, _optind, _optopt, _optreset, 
                       _pause, _pclose, _perror, _popen, '_popen$DARWIN_EXTSN', _posix2time, 
                       _posix_openpt, _posix_spawnp, _printf, _printf_l, _psignal, 
                       _psort, _psort_b, _psort_r, _ptsname, _putc, _putc_unlocked, 
                       _putchar, _putchar_unlocked, _putenv, _puts, _pututxline, 
                       _putw, _putwc, _putwc_l, _putwchar, _putwchar_l, _qsort, _qsort_b, 
                       _qsort_r, _querylocale, _radixsort, _raise, _rand, _rand_r, 
                       _random, _rb_tree_count, _rb_tree_find_node, _rb_tree_find_node_geq, 
                       _rb_tree_find_node_leq, _rb_tree_init, _rb_tree_insert_node, 
                       _rb_tree_iterate, _rb_tree_remove_node, _readdir, '_readdir$INODE64', 
                       _readdir_r, '_readdir_r$INODE64', _readpassphrase, _reallocf, 
                       _realpath, '_realpath$DARWIN_EXTSN', _recv, _regcomp, _regcomp_l, 
                       _regerror, _regexec, _regfree, _register_printf_domain_function, 
                       _register_printf_domain_render_std, _regncomp, _regncomp_l, 
                       _regnexec, _regwcomp, _regwcomp_l, _regwexec, _regwncomp, 
                       _regwncomp_l, _regwnexec, _remove, _remque, _rewind, _rewinddir, 
                       _rindex, _sbrk, _scandir, '_scandir$INODE64', _scandir_b, 
                       '_scandir_b$INODE64', _scanf, _scanf_l, _seed48, _seekdir, 
                       _send, _setbuf, _setbuffer, _setenv, _sethostid, _sethostname, 
                       _setinvalidrune, _setipv4sourcefilter, _setkey, _setlinebuf, 
                       _setlocale, _setlogin, _setmode, _setprogname, _setrgid, _setruid, 
                       _setrunelocale, _setsourcefilter, _setstate, _settimeofday, 
                       _setttyent, _setusershell, _setutxent, _setutxent_wtmp, _setvbuf, 
                       _sigaction, _sigaddset, _sigblock, _sigdelset, _sigemptyset, 
                       _sigfillset, _sighold, _sigignore, _siginterrupt, _sigismember, 
                       _signal, _sigpause, _sigrelse, _sigset, _sigsetmask, _sigvec, 
                       _sl_add, _sl_find, _sl_free, _sl_init, _sleep, _snprintf, 
                       _snprintf_l, _snvis, _sockatmark, _sprintf, _sprintf_l, _sradixsort, 
                       _srand, _srand48, _sranddev, _srandom, _srandomdev, _sscanf, 
                       _sscanf_l, _statvfs, _statx64_np, _statx_np, '_statx_np$INODE64', 
                       _stpcpy, _stpncpy, _strcasecmp, _strcasecmp_l, _strcasestr, 
                       _strcasestr_l, _strcat, _strchr, _strcmp, _strcoll, _strcoll_l, 
                       _strcpy, _strcspn, _strdup, _strenvisx, _strerror, _strerror_r, 
                       _strfmon, _strfmon_l, _strftime, _strftime_l, _strlcat, _strlcpy, 
                       _strlen, _strmode, _strncasecmp, _strncasecmp_l, _strncat, 
                       _strncmp, _strncpy, _strndup, _strnlen, _strnstr, _strnunvis, 
                       _strnunvisx, _strnvis, _strnvisx, _strpbrk, _strptime, _strptime_l, 
                       _strrchr, _strsenvisx, _strsep, _strsignal, _strsnvis, _strsnvisx, 
                       _strspn, _strstr, _strsvis, _strsvisx, _strtod, _strtod_l, 
                       _strtof, _strtof_l, _strtofflags, _strtoimax, _strtoimax_l, 
                       _strtok, _strtok_r, _strtol, _strtol_l, _strtold, _strtold_l, 
                       _strtoll, _strtoll_l, _strtoq, _strtoq_l, _strtoul, _strtoul_l, 
                       _strtoull, _strtoull_l, _strtoumax, _strtoumax_l, _strtouq, 
                       _strtouq_l, _strunvis, _strunvisx, _strvis, _strvisx, _strxfrm, 
                       _strxfrm_l, _suboptarg, _svis, _swab, _swprintf, _swprintf_l, 
                       _swscanf, _swscanf_l, _sxprintf, _sxprintf_exec, _sync_volume_np, 
                       _sys_errlist, _sys_nerr, _sys_siglist, _sys_signame, _sysconf, 
                       _sysctl, _sysctlbyname, _sysctlnametomib, _system, _tcdrain, 
                       _tcflow, _tcflush, _tcgetattr, _tcgetpgrp, _tcgetsid, _tcsendbreak, 
                       _tcsetattr, _tcsetpgrp, _tdelete, _telldir, _tempnam, _tfind, 
                       _thread_stack_pcs, _time, _time2posix, _timegm, _timelocal, 
                       _timeoff, _times, _timezone, _tmpfile, _tmpnam, _toascii, 
                       _tolower, _tolower_l, _toupper, _toupper_l, _towctrans, _towctrans_l, 
                       _towlower, _towlower_l, _towupper, _towupper_l, _tre_ast_new_catenation, 
                       _tre_ast_new_iter, _tre_ast_new_literal, _tre_ast_new_node, 
                       _tre_ast_new_union, _tre_compile, _tre_fill_pmatch, _tre_free, 
                       _tre_mem_alloc_impl, _tre_mem_destroy, _tre_mem_new_impl, 
                       _tre_parse, _tre_stack_destroy, _tre_stack_new, _tre_stack_num_objects, 
                       _tre_tnfa_run_backtrack, _tre_tnfa_run_parallel, _tsearch, 
                       _ttyname, _ttyname_r, _ttyslot, _twalk, _tzname, _tzset, _tzsetwall, 
                       _ualarm, _ulimit, _umaskx_np, _uname, _ungetc, _ungetwc, _ungetwc_l, 
                       _unlockpt, _unsetenv, _unvis, _uselocale, _usleep, _utime, 
                       _utmpxname, _uuid_clear, _uuid_compare, _uuid_copy, _uuid_generate, 
                       _uuid_generate_random, _uuid_generate_time, _uuid_is_null, 
                       _uuid_pack, _uuid_parse, _uuid_unpack, _uuid_unparse, _uuid_unparse_lower, 
                       _uuid_unparse_upper, _vasprintf, _vasprintf_l, _vasxprintf, 
                       _vasxprintf_exec, _vdprintf, _vdprintf_l, _vdxprintf, _vdxprintf_exec, 
                       _verr, _verrc, _verrx, _vfprintf, _vfprintf_l, _vfscanf, _vfscanf_l, 
                       _vfwprintf, _vfwprintf_l, _vfwscanf, _vfwscanf_l, _vfxprintf, 
                       _vfxprintf_exec, _vis, _vprintf, _vprintf_l, _vscanf, _vscanf_l, 
                       _vsnprintf, _vsnprintf_l, _vsprintf, _vsprintf_l, _vsscanf, 
                       _vsscanf_l, _vswprintf, _vswprintf_l, _vswscanf, _vswscanf_l, 
                       _vsxprintf, _vsxprintf_exec, _vwarn, _vwarnc, _vwarnx, _vwprintf, 
                       _vwprintf_l, _vwscanf, _vwscanf_l, _vxprintf, _vxprintf_exec, 
                       _wait, _wait3, _waitpid, _warn, _warnc, _warnx, _wcpcpy, _wcpncpy, 
                       _wcrtomb, _wcrtomb_l, _wcscasecmp, _wcscasecmp_l, _wcscat, 
                       _wcschr, _wcscmp, _wcscoll, _wcscoll_l, _wcscpy, _wcscspn, 
                       _wcsdup, _wcsftime, _wcsftime_l, _wcslcat, _wcslcpy, _wcslen, 
                       _wcsncasecmp, _wcsncasecmp_l, _wcsncat, _wcsncmp, _wcsncpy, 
                       _wcsnlen, _wcsnrtombs, _wcsnrtombs_l, _wcspbrk, _wcsrchr, 
                       _wcsrtombs, _wcsrtombs_l, _wcsspn, _wcsstr, _wcstod, _wcstod_l, 
                       _wcstof, _wcstof_l, _wcstoimax, _wcstoimax_l, _wcstok, _wcstol, 
                       _wcstol_l, _wcstold, _wcstold_l, _wcstoll, _wcstoll_l, _wcstombs, 
                       _wcstombs_l, _wcstoul, _wcstoul_l, _wcstoull, _wcstoull_l, 
                       _wcstoumax, _wcstoumax_l, _wcswidth, _wcswidth_l, _wcsxfrm, 
                       _wcsxfrm_l, _wctob, _wctob_l, _wctomb, _wctomb_l, _wctrans, 
                       _wctrans_l, _wctype, _wctype_l, _wcwidth, _wcwidth_l, _wmemchr, 
                       _wmemcmp, _wmemcpy, _wmemmove, _wmemset, _wordexp, _wordfree, 
                       _wprintf, _wprintf_l, _wscanf, _wscanf_l, _wtmpxname, _xprintf, 
                       _xprintf_exec, mcount ]
...

@mistydemeo
Copy link
Member

@DomT4 Can you provide time.h too?

@mistydemeo
Copy link
Member

In the CLT, here's the ifdef which controls whether clock_gettime should be available:

#if !defined(_DARWIN_FEATURE_CLOCK_GETTIME) || _DARWIN_FEATURE_CLOCK_GETTIME != 0
#if __DARWIN_C_LEVEL >= 199309L
#if __has_feature(enumerator_attributes)
#define __CLOCK_AVAILABILITY __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
#else
#define __CLOCK_AVAILABILITY
#endif

@mistydemeo
Copy link
Member

Looks like xz tests it like this:

AC_SEARCH_LIBS([clock_gettime], [rt])
AC_CHECK_FUNCS([clock_gettime pthread_condattr_setclock])
AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include <time.h>]])

Which checks if it can link against it but not whether it's declared. Which, I believe, in this case is allowing the check to pass (because the symbol is in the .tbd and linking succeeds) where AC_CHECK_DECLS would have failed (because a 10.11 deployment target would lead to the symbol being undeclared in time.h).

@DomT4
Copy link
Member

DomT4 commented Jul 4, 2016

time.h

/*
 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
 *
 * @APPLE_LICENSE_HEADER_START@
 * 
 * This file contains Original Code and/or Modifications of Original Code
 * as defined in and that are subject to the Apple Public Source License
 * Version 2.0 (the 'License'). You may not use this file except in
 * compliance with the License. Please obtain a copy of the License at
 * http://www.opensource.apple.com/apsl/ and read it before using this
 * file.
 * 
 * The Original Code and all software distributed under the License are
 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
 * Please see the License for the specific language governing rights and
 * limitations under the License.
 * 
 * @APPLE_LICENSE_HEADER_END@
 */
/*
 * Copyright (c) 1989, 1993
 *  The Regents of the University of California.  All rights reserved.
 * (c) UNIX System Laboratories, Inc.
 * All or some portions of this file are derived from material licensed
 * to the University of California by American Telephone and Telegraph
 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
 * the permission of UNIX System Laboratories, Inc.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *  This product includes software developed by the University of
 *  California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *  @(#)time.h  8.3 (Berkeley) 1/21/94
 */

#ifndef _TIME_H_
#define _TIME_H_

#include <_types.h>
#include <Availability.h>
#include <sys/_types/_clock_t.h>
#include <sys/_types/_null.h>
#include <sys/_types/_size_t.h>
#include <sys/_types/_time_t.h>
#include <sys/_types/_timespec.h>

struct tm {
    int tm_sec;     /* seconds after the minute [0-60] */
    int tm_min;     /* minutes after the hour [0-59] */
    int tm_hour;    /* hours since midnight [0-23] */
    int tm_mday;    /* day of the month [1-31] */
    int tm_mon;     /* months since January [0-11] */
    int tm_year;    /* years since 1900 */
    int tm_wday;    /* days since Sunday [0-6] */
    int tm_yday;    /* days since January 1 [0-365] */
    int tm_isdst;   /* Daylight Savings Time flag */
    long    tm_gmtoff;  /* offset from CUT in seconds */
    char    *tm_zone;   /* timezone abbreviation */
};

#if __DARWIN_UNIX03
#define CLOCKS_PER_SEC  1000000 /* [XSI] */
#else /* !__DARWIN_UNIX03 */
#include <machine/_limits.h>    /* Include file containing CLK_TCK. */

#define CLOCKS_PER_SEC  (__DARWIN_CLK_TCK)
#endif /* __DARWIN_UNIX03 */

#ifndef _ANSI_SOURCE
extern char *tzname[];
#endif

extern int getdate_err;
#if __DARWIN_UNIX03
extern long timezone __DARWIN_ALIAS(timezone);
#endif /* __DARWIN_UNIX03 */
extern int daylight;

__BEGIN_DECLS
char *asctime(const struct tm *);
clock_t clock(void) __DARWIN_ALIAS(clock);
char *ctime(const time_t *);
double difftime(time_t, time_t);
struct tm *getdate(const char *);
struct tm *gmtime(const time_t *);
struct tm *localtime(const time_t *);
time_t mktime(struct tm *) __DARWIN_ALIAS(mktime);
size_t strftime(char * __restrict, size_t, const char * __restrict, const struct tm * __restrict) __DARWIN_ALIAS(strftime);
char *strptime(const char * __restrict, const char * __restrict, struct tm * __restrict) __DARWIN_ALIAS(strptime);
time_t time(time_t *);

#ifndef _ANSI_SOURCE
void tzset(void);
#endif /* not ANSI */

/* [TSF] Thread safe functions */
char *asctime_r(const struct tm * __restrict, char * __restrict);
char *ctime_r(const time_t *, char *);
struct tm *gmtime_r(const time_t * __restrict, struct tm * __restrict);
struct tm *localtime_r(const time_t * __restrict, struct tm * __restrict);

#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
time_t posix2time(time_t);
#if !__DARWIN_UNIX03
char *timezone(int, int);
#endif /* !__DARWIN_UNIX03 */
void tzsetwall(void);
time_t time2posix(time_t);
time_t timelocal(struct tm * const);
time_t timegm(struct tm * const);
#endif /* neither ANSI nor POSIX */

#if !defined(_ANSI_SOURCE)
int nanosleep(const struct timespec *, struct timespec *) __DARWIN_ALIAS_C(nanosleep);
#endif

#if !defined(_DARWIN_FEATURE_CLOCK_GETTIME) || _DARWIN_FEATURE_CLOCK_GETTIME != 0
#if __DARWIN_C_LEVEL >= 199309L
#if __has_feature(enumerator_attributes)
#define __CLOCK_AVAILABILITY __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
#else
#define __CLOCK_AVAILABILITY
#endif

typedef enum {
_CLOCK_REALTIME __CLOCK_AVAILABILITY = 0,
#define CLOCK_REALTIME _CLOCK_REALTIME
_CLOCK_MONOTONIC __CLOCK_AVAILABILITY = 6,
#define CLOCK_MONOTONIC _CLOCK_MONOTONIC
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
_CLOCK_MONOTONIC_RAW __CLOCK_AVAILABILITY = 4,
#define CLOCK_MONOTONIC_RAW _CLOCK_MONOTONIC_RAW
_CLOCK_MONOTONIC_RAW_APPROX __CLOCK_AVAILABILITY = 5,
#define CLOCK_MONOTONIC_RAW_APPROX _CLOCK_MONOTONIC_RAW_APPROX
_CLOCK_UPTIME_RAW __CLOCK_AVAILABILITY = 8,
#define CLOCK_UPTIME_RAW _CLOCK_UPTIME_RAW
_CLOCK_UPTIME_RAW_APPROX __CLOCK_AVAILABILITY = 9,
#define CLOCK_UPTIME_RAW_APPROX _CLOCK_UPTIME_RAW_APPROX
#endif
_CLOCK_PROCESS_CPUTIME_ID __CLOCK_AVAILABILITY = 12,
#define CLOCK_PROCESS_CPUTIME_ID _CLOCK_PROCESS_CPUTIME_ID
_CLOCK_THREAD_CPUTIME_ID __CLOCK_AVAILABILITY = 16
#define CLOCK_THREAD_CPUTIME_ID _CLOCK_THREAD_CPUTIME_ID
} clockid_t;

__CLOCK_AVAILABILITY
int clock_getres(clockid_t clock_id, struct timespec *res);

__CLOCK_AVAILABILITY
int clock_gettime(clockid_t clock_id, struct timespec *tp);

#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
__CLOCK_AVAILABILITY
__uint64_t clock_gettime_nsec_np(clockid_t clock_id);
#endif

__OSX_AVAILABLE(10.12) __IOS_PROHIBITED
__TVOS_PROHIBITED __WATCHOS_PROHIBITED
int clock_settime(clockid_t clock_id, const struct timespec *tp);

#undef __CLOCK_AVAILABILITY
#endif /* __DARWIN_C_LEVEL */
#endif /* _DARWIN_FEATURE_CLOCK_GETTIME */

__END_DECLS

#ifdef _USE_EXTENDED_LOCALES_
#include <xlocale/_time.h>
#endif /* _USE_EXTENDED_LOCALES_ */

#endif /* !_TIME_H_ */

@mistydemeo
Copy link
Member

That's the same #ifdef in Xcode, then.

@UniqMartin
Copy link
Contributor

UniqMartin commented Jul 4, 2016

That's definitely a bug with the libsystem_c.tdb file then. I previously failed to understand that there is a mechanism in place where you can scope the availability of certain exported functions to specific deployment targets. (Now I know!) That mechanism sadly hasn't been used here. The entry in a correct .tbd file should be:

$ld$add$os10.12$_clock_gettime

Alternatively, the same effect can be achieved with multiple entries in that function list:

_clock_gettime
$ld$hide$os10.11$_clock_gettime
$ld$hide$os10.10$_clock_gettime
$ld$hide$os10.9$_clock_gettime
…

(See e.g. /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/lib/system/libcompiler_rt.tbd in Xcode 7.3.1 where this mechanism has been correctly used with quite a few of the exported functions.)

Can someone with an actual Developer Program membership report this to Apple (and I guess tell them other related symbols might be affected, too)? Maybe they're willing to fix this before the release …

@x8x
Copy link
Author

x8x commented Jul 4, 2016

@mistydemeo Re: "Can you provide the logs from brew gist-logs xz for a failed build?"
The building doesn't fail, but when I brew upgrade, xz will crash at the first *.xz archive it tries to expand.
Do you still want a brew gist-logs xz ?

@mistydemeo
Copy link
Member

Submitted as rdar://27163651.

@x8x That's fine - have it all figured out now.

@DomT4 DomT4 added upstream issue An upstream issue report is needed and removed user configuration User configuration rather than a Homebrew issue labels Jul 5, 2016
@jeremyhu
Copy link

jeremyhu commented Jul 5, 2016

@mistydemeo This isn't a bug with the SDK. The availability macros correctly cause clock_gettime to be weak when you set a deployment target of 10.11.

FWIW, this is one of the main reasons why we in MacPorts have our users install the command line tools (which include the relevant headers for the major OS version) and use that instead of the SDK. So many OSS projects don't handle these cases correctly

@UniqMartin You misunderstand the purpose and use of those $ld symbols. That is not what they are for. They cause the linker to assume the symbols aren't there ($hide) or are there ($add) when the deployment target matches that value. This mechanism is for helping deal with symbols that have moved between dylibs across OS versions (and are re-exported from their old location for binary compatibility).

@UniqMartin
Copy link
Contributor

Submitted as rdar://27163651.

@mistydemeo Thanks, but I'm afraid @jeremyhu is right and my assessment of the situation wasn't correct. I'm sorry for making you file this and making you attach your name to this analysis.

This isn't a bug with the SDK. The availability macros correctly cause clock_gettime to be weak when you set a deployment target of 10.11.

@jeremyhu That's an interesting bit of information that I didn't fully understand up until now. Thanks! So the real problem is that most OSS projects expect the symbol to either exist or not and aren't prepared to handle a weakly linked symbol (that requires a runtime check) instead of it being unavailable? Are you aware of a way to tell the compiler to mark those symbols as unavailable instead of causing weak linkage? While that would mess with software that properly handles this, it won't break anything and would help tremendously with software that doesn't deal with this properly.

You misunderstand the purpose and use of those $ld symbols. That is not what they are for. They cause the linker to assume the symbols aren't there ($hide) or are there ($add) when the deployment target matches that value.

So I properly understood the mechanics of those linker-special symbols but not how they are typically used? I think in addition to the case you mentioned (moved symbol) this can also be used for adding new symbols in a backwards-compatible way, but is only done for symbols where weak linking doesn't make sense (because the symbols are not directly exposed to a developer). I think the symbols in /usr/lib/system/libcompiler_rt.dylib and /usr/lib/system/libunwind.dylib are good examples of such a case (both use $ld$hide$* extensively). Does that sound right? Thanks again for this insight!

@jeremyhu
Copy link

jeremyhu commented Jul 6, 2016

Does the autoconf macro include time.h before it's test or does it just check for the symbol's existence directly? If the former, you might be able to get the configure test to not pickup the new function by using -Werror=partial-availability. I know that many autoconf macros just do a link test without actually using the header, in which case the testcase wouldn't get the header's availability markup and would still succeed.

Most OSS projects target POSIX (or often Linux) and really expect that the headers are an exact match to the system you're targeting. Apple platforms introduce a notion of SDK in which the headers are annotated with availability markup and the compiler sets up macros such that functionality newer than the deployment target are marked as weak. Similar things are done for annotating symbols as deprecated or unavailable as well. The exact way this has been done has evolved over the years from multiple layers of macro expansion in the early days to rather nice compiler attributes.

Expecting all OSS projects to update their code to work this way isn't a reasonable expectation. If we want to support a way of doing what you are asking for, it would probably need to come at the linker stage and not the compiler stage (since we can't trust autoconf macros to actually use our headers). The issue is that the availability is encoded solely in the header. It certainly could be possible to introduce new $ld symbols to encode availability in the linker stubs (eg: $ld$available$os10.12$_clock_gettime), but to be effective, we'd want to do that for everything in an automated way. The compiler would likely need to add them at the implementation site when availability is set, and the linker would need to honor that when asked to run in a strict mode (eg: -Wl,-no_partial_availability or somesuch).

You might consider starting a bug report at http://llvm.org about this as well as that's a more appropriate place for the public side of this discussion than in a Homebrew ticket that's really about specific fallout to this larger metaproblem.

@yurikoles
Copy link
Contributor

yurikoles commented Jul 28, 2016

Seems to be fixed as of Xcode & CLT 8 beta3 on 10.12. Fixed after installing corresponding CLT.

@jeremyhu
Copy link

Yes, we added support for a new $ld directive in ld and adopted it in Libc for this particular case. It’s a manual process right now, so there may be other symbols in this category. Please file radars if you see any others. It would be nice to eventually have such $ld symbols omitted automatically by the compiler based on availability annotation.

@xurenzhong
Copy link

I have macOS 10.12 but xcode8, and I dont install .How to do?! installed xcode8 can fix it?!

@yurikoles
Copy link
Contributor

@xurenzhong have you installed command line tools for xcode8/macOS 10.12?

@xurenzhong
Copy link

@yurikoles I try it now, thank you

@justMaku
Copy link

justMaku commented Aug 2, 2016

Works fine on Xcode8 Beta 4, remember to install command line tools and run xcode-select.

@DomT4
Copy link
Member

DomT4 commented Aug 6, 2016

Presume resolved from Jeremy's comments, at least for this particular instance and providing you're keeping on top of prerelease updates. Closing here.

@achivetta
Copy link

achivetta commented Aug 9, 2016

This isn't resolved, it just never existed on 10.12 since that OS version does have the symbol. I've filed #3727 with, I hope, a clear explanation of what's going on.

@MikeMcQuaid
Copy link
Member

Now Homebrew/brew#721 was implemented these problems should be resolved at compile rather than run time.

@jgoslow
Copy link

jgoslow commented Sep 23, 2016

ala @justMaku - Make sure to run xcode-select --install

@johndubchak
Copy link

I ran into this same error while compiling percona-server56 this morning on El Capitan. Digging a little deeper, the compile error message reported:

/Applications/Xcode.app/Contents/Developer/usr/bin/make -f extra/CMakeFiles/GenError.dir/build.make extra/CMakeFiles/GenError.dir/build
[100%] Generating ../include/mysqld_error.h, ../sql/share/english/errmsg.sys
cd /tmp/percona-server56-20160929-86869-1527rh7/percona-server-5.6.28-76.1/extra && ./comp_err --charset=/tmp/percona-server56-20160929-86869-1527rh7/percona-server-5.6.28-76.1/sql/share/charsets --out-dir=/tmp/percona-server56-20160929-86869-1527rh7/percona-server-5.6.28-76.1/sql/share/ --header_file=/tmp/percona-server56-20160929-86869-1527rh7/percona-server-5.6.28-76.1/include/mysqld_error.h --name_file=/tmp/percona-server56-20160929-86869-1527rh7/percona-server-5.6.28-76.1/include/mysqld_ername.h --state_file=/tmp/percona-server56-20160929-86869-1527rh7/percona-server-5.6.28-76.1/include/sql_state.h --in_file=/tmp/percona-server56-20160929-86869-1527rh7/percona-server-5.6.28-76.1/sql/share/errmsg-utf8.txt
  dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
  Referenced from: /private/tmp/percona-server56-20160929-86869-1527rh7/percona-server-5.6.28-76.1/extra/./comp_err
  Expected in: /usr/lib/libSystem.B.dylib

And exporting the symbols of the mentioned dynamic library shows it is missing:

$ nm -gU /usr/lib/libSystem.B.dylib
0000000000001a98 T R8289209$_close
0000000000001a9d T R8289209$_fork
0000000000001aa2 T R8289209$_fsync
0000000000001aa7 T R8289209$_getattrlist
0000000000001aac T R8289209$_getrlimit
0000000000001ab1 T R8289209$_getxattr
0000000000001ab6 T R8289209$_open
0000000000001abb T R8289209$_pthread_attr_destroy
0000000000001ac0 T R8289209$_pthread_attr_init
0000000000001ac5 T R8289209$_pthread_attr_setdetachstate
0000000000001aca T R8289209$_pthread_create
0000000000001acf T R8289209$_pthread_mutex_lock
0000000000001ad4 T R8289209$_pthread_mutex_unlock
0000000000001ad9 T R8289209$_pthread_self
0000000000001ade T R8289209$_ptrace
0000000000001ae3 T R8289209$_read
0000000000001ae8 T R8289209$_setattrlist
0000000000001aed T R8289209$_setrlimit
0000000000001af2 T R8289209$_sigaction
0000000000001af7 T R8289209$_stat
0000000000001afc T R8289209$_sysctl
0000000000001b01 T R8289209$_time
0000000000001b06 T R8289209$_unlink
0000000000001b0b T R8289209$_write
0000000000001f98 S ___System_BVersionNumber
0000000000001f60 S ___System_BVersionString
00000000000022b8 S ___crashreporter_info__
0000000000001b10 T _libSystem_atfork_child
0000000000001a7a T _libSystem_atfork_parent
0000000000001a5c T _libSystem_atfork_prepare
00000000000022b0 D _mach_init_routine

Not sure if this helps, but I thought I'd share nonetheless.

John

@achivetta
Copy link

@johndubchak does it still fail if you add the linker flag I describe in #3727?

@ilovezfs
Copy link
Contributor

ilovezfs commented Oct 1, 2016

The clock issue impacts the percona-server56 formula because it's not using std_cmake_args, which passes -DHAVE_CLOCK_GETTIME:INTERNAL=0. Adding that argument fixes it:

diff --git a/percona-server56.rb b/percona-server56.rb
index 17299a9..a74584b 100644
--- a/percona-server56.rb
+++ b/percona-server56.rb
@@ -78,6 +78,10 @@ class PerconaServer56 < Formula
       -DCMAKE_BUILD_TYPE=RelWithDebInfo
     ]

+    if MacOS.version == "10.11" && MacOS::Xcode.installed? && MacOS::Xcode.version >= "8.0"
+      args << "-DHAVE_CLOCK_GETTIME:INTERNAL=0"
+    end
+
     # PAM plugin is Linux-only at the moment
     args.concat %W[
       -DWITHOUT_AUTH_PAM=1

Alternatively, the formula could be updated to use std_cmake_args.

@achivetta in this case -no_weak_imports just leads to

[ 16%] Linking CXX executable comp_err
cd /tmp/percona-server56-20160930-17778-r9kdfa/percona-server-5.6.28-76.1/extra && /usr/local/Cellar/cmake/3.6.2/bin/cmake -E cmake_link_script CMakeFiles/comp_err.dir/link.txt --verbose=1
/usr/local/Homebrew/Library/Homebrew/shims/super/clang++    -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter -Wno-null-conversion -Wno-unused-private-field -O3 -g -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.11 -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/comp_err.dir/comp_err.c.o  -o comp_err  ../mysys/libmysys.a ../mysys_ssl/libmysys_ssl.a ../mysys/libmysys.a ../dbug/libdbug.a ../mysys/libmysys.a ../dbug/libdbug.a ../strings/libstrings.a ../zlib/libzlib.a /usr/local/opt/openssl/lib/libssl.dylib /usr/local/opt/openssl/lib/libcrypto.dylib 
ld: weak import of symbol '_clock_gettime' not supported because of option: -no_weak_imports for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [extra/comp_err] Error 1
make[1]: *** [extra/CMakeFiles/comp_err.dir/all] Error 2
make: *** [all] Error 2

@johndubchak
Copy link

@achivetta Sorry for the delayed response, but I've tried a number of different ways to add the linker flag, including an interactive build, and have been unsuccessful. I still get the same error.

It's still possible I'm doing something wrong so if you have a specific way I should add the flag, let me know.

@Catchpowle
Copy link

When trying to install ruby 2.3.1 through rbenv which was itself installed via homebrew, I get the following, do you think it's related?

dyld: Symbol not found: _clock_gettime
Referenced from: /private/var/folders/12/zx7vqj5559n7pz_32mb8mg000000gn/T/ruby-build.20161005220520.42849/ruby-2.3.1/./miniruby (which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib

@johndubchak
Copy link

@Catchpowle, yes, the exact same issue.

@ilovezfs
Copy link
Contributor

ilovezfs commented Oct 6, 2016

@johndubchak I provided a solution for percona-server56 above.

In any case, since this issue is about xz and we're all now talking about other formulae, please open new formula-specific issues if you're still having any problems.

@Homebrew Homebrew locked and limited conversation to collaborators Oct 6, 2016
@ilovezfs ilovezfs added clock_gettime CI fails due to clock_gettime symbol and removed upstream issue An upstream issue report is needed labels Nov 1, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
clock_gettime CI fails due to clock_gettime symbol
Projects
None yet
Development

No branches or pull requests