[llvm-dev] TargetTriple issue: LC_VERSION_MIN_MACOSX: Darwin kernel version vs SDK version
Benoit Belley via llvm-dev
llvm-dev at lists.llvm.org
Thu Sep 24 10:48:20 PDT 2015
Hi everyone,
I just reported the following issue: https://llvm.org/bugs/show_bug.cgi?id=24927
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/Host.inc, 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: https://llvm.org/bugs/show_bug.cgi?id=24927#if defined(OSX)
#if (LLVM_VERSION_MAJOR < 3) || ((LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 8 ))
triple = Triple(triple.getArchName(),
triple.getVendorName(),
"darwin",
triple.getEnvironmentName());
#endif
#endif
This prevents the LC_VERSION_MIN_MACOSX directives from being emitted into the LLVM generated object files.
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!
Thanks,
Benoit
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
Twitter<http://twitter.com/autodesk>
Facebook<https://www.facebook.com/Autodesk>
Autodesk, Inc.
10 Duke Street
Montreal, Quebec, Canada H3C 2L7
www.autodesk.com<http://www.autodesk.com/>
[Description: Email_Signature_Logobar]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150924/9d2d56c1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 350F40DB-4457-4455-A632-0DF05738AF15[32].png
Type: image/png
Size: 4316 bytes
Desc: 350F40DB-4457-4455-A632-0DF05738AF15[32].png
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150924/9d2d56c1/attachment.png>
More information about the llvm-dev
mailing list