Linker warning with libkmod.a and 10.13 SDK

Since updating from Xcode 8.x to 9.1, I get the following warning when linking my kext:


object file (/Applications/Xcode_9.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/lib/libkmod.a(c_start.o)) was built for newer OSX version (10.13) than being linked (10.12)


This seems to be because my deployment target is set to 10.12 but I'm now using the 10.13 SDK with Xcode 9.


Should I worry about this warning? If not, is there any way to silence it without silencing all warnings from the linker.


If I should worry about it (i.e it might cause subtle issues), what should I do about it? Try and dig out the libkmod.a file from the older 10.12 SDK and force that to be used?

Replies

Should I worry about this warning?

Yes. One of the many un-fun things about kernel development is that it does not follow the usual rules with regards deployment targets. For user space code we recommend that you:

  • Use the latest version of Xcode

  • Use the latest SDK (modern Xcodes only contain one SDK)

  • Set your deployment target back to the oldest release that you support

For kernel development the recommendation is:

Use the SDK for the oldest release you target

As Xcode 9 includes the 10.13 SDK, you can’t use it to build a KEXT that targets 10.12. You must stick with Xcode 8 for that.

The only saving grace here is that Xcode supports coexistence, so you can have Xcode 9 and Xcode 8 installed on the same Mac (using the former for your day-to-day app development and the latter for you KEXT development).

Try and dig out the libkmod.a file from the older 10.12 SDK and force that to be used?

Please don’t do that. You might be able to kludge Xcode 9 into building the KEXT you need but the end result will be a weird Frankenstein thing. That may well cause you binary compatibility problems down the line. The KEXT loading system contains various special cases to keep older KEXTs working, and your Franken-KEXT might fall through the cracks in that compatibility path.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"