[R-SIG-Mac] Building backward compatible binary packages with OS X 10.9 and Xcode 5.0?

Simon Urbanek simon.urbanek at r-project.org
Mon Jan 20 01:26:44 CET 2014

On Jan 19, 2014, at 6:43 PM, Reijo Sund <reijo.sund at helsinki.fi> wrote:

> Using the latest patched R 3.0.2 on Mac OS X Maverics (10.9.1) with Xcode 5.0.2 command line tools and clang set as a compiler, the following kind of C code somewhere in a package results in a dynamic link to symbol ___sincos_stret:
> double sincos(double n) { return(sin(n)+cos(n)); }
> It is obvious that ___sincos_stret is an LLVM optimization: if code calls sin(n) and then cos(n) and uses both results, the compiler will make one call to the structure-returning sincos method.
> The actual problem is that such symbol is available in system library /usr/lib/system/libsystem_m.dylib only since Mavericks (10.9 SDK) and a package installed from binary (.tgz) compiled on 10.9 but run on 10.8 or older fails: Symbol not found: ___sincos_stret
> One ”solution" is to make minor changes to the C code so that compiler won’t detect a need for optimization. A better solution is to use compiler flag -mmacosx-version-min=10.8. However, these solutions to a single concrete problem give only partial answers to the more general question:
> How to (maximize the possibility to) create OS X 10.6+ (i.e. R 3.0.0+) compatible .tgz binary packages using a computer with OS X 10.9 and Xcode 5.0 (and without using CRAN or RForge building services)? 

Use the 10.6 SDK (e.g. via -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk) and -mmacosx-version-min=10.6 flags for both linking and compilation.

Note, however, that 10.6 SDK is no longer supplied with Xcode 5, so you'll have to pick it from an older Xcode package.

BTW, the missing symbol is your least worry - the linker has changed since 10.8 so any binaries compiled for 10.8+ don't even load in 10.6. Using the SDKs can be problematic if you have dependent libraries, because most non-Mac tools don't know how to deal with SDKs and may pick some system library inadvertently. So if you're only concerned about your package then give it a shot and test it under 10.6 to see if it works. The most reliable way is still to run 10.6 VM in 10.9 if you want 100% guarantee.


> Any tips would be appreciated.
> Best wishes,
> Reijo Sund
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac

More information about the R-SIG-Mac mailing list