TargetTriple issue: LC_VERSION_MIN_MACOSX: Darwin kernel version vs SDK version

Hi everyone,

I just reported the following issue:

Using the Xcode 7 linker, one gets messages such as the following when linking objects generated using llvm:

__*ld: warning: object file (foo.o) was built for newer OS X version (14.5) than being linked (10.9)*__

The issue is the following:

a) In lib/Support/Unix/, sys::getDefaultTargetTriple() sets the OS name to darwin14.5 when running on MaxOS X 10.10. 14.5 is the Darwin kernel version as reported by uname.

b) In lib/CodeGen/AsmPrinter.cpp, AsmPrinter::doInitialization() writes out this version number to the LC_VERSION_MIN_MACOSX of the generated object.

c) The XCode 7 linker seems to expect that LC_VERSION_MIN_MACOSX contains the minimum version number of the MacOS X SDK (10.9, 10.11, ...), NOT the Darwin kernel version number! 

_**AFAICT, LLVM had this wrong behaviour for a long time. The only new thing with Xcode 7 is that the linker is now reporting a warning for the version mismatch.**_
As a workaround, we are temporarily stripping out the darwin kernel version number from the triple in our project code. Something like:
// FIXME: LLVM confuses Darwin Kernel version numbers with MacOS X SDK
// version. By stripping out the kernel version number, we prevent the
// LC_VERSION_MIN_MACOSX directive from being emitted. Hopefully, that
// will get fixed by LLVM 3.8...
// See LLVM bug 24927: defined(OSX)
        triple = Triple(triple.getArchName(),
This prevents the LC_VERSION_MIN_MACOSX directives from being emitted into the LLVM generated object files.

<b>*Any suggestions how to go about fixing LLVM to generate the correct  LC_VERSION_MIN_MACOSX minimum SDK version number ? There seems to be no way to pass this information correctly through the Triple!*</b>


Benoit Belley

Sr Principal Developer

M&E-Product Development Group

MAIN +1 514 393 1616

DIRECT +1 438 448 6304

FAX +1 514 393 0110



Autodesk, Inc.

10 Duke Street

Montreal, Quebec, Canada H3C 2L7


Using ‘clang -target …-darwin10.10 …’ or configuring LLVM’s default triple at configure-time (-DLLVM_DEFAULT_TARGET_TRIPLE=…-darwin10.10 for CMake) should work. I do the latter for MIPS32 toolchains on a MIPS64 host.


(Re-added the list)

I don’t know much about OSX so I’m not sure how much I can help with figuring out the fine detail. That said, I’ve noticed that AsmPrinter::doInitialization() is calling Triple::getOSVersion(). There’s also a Triple::getMacOSXVersion() which claims to ‘translate generic “darwin” versions to the corresponding OS X versions’. Could it be that AsmPrinter::doInitialization() should be calling getMacOSXVersion() for OSX?