$ cat null.s .globl _main _main: retq $ llvm-mc -filetype obj -triple x86_64-apple-ios14.0.0-simulator \ -o null.o null.s $ ld64.lld -platform_version ios-simulator 14.0.0 14.0 -arch x86_64 \ -o null null.o -lSystem -syslibroot \ /Applications/Xcode_12.0.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk ld64.lld: error: /Applications/Xcode_12.0.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/system/libsystem_kernel.tbd(/usr/lib/system/libsystem_kernel.dylib) is incompatible with x86_64 (iOS Simulator) ld64.lld: error: /Applications/Xcode_12.0.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/system/libsystem_platform.tbd(/usr/lib/system/libsystem_platform.dylib) is incompatible with x86_64 (iOS Simulator) ld64.lld: error: /Applications/Xcode_12.0.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/system/libsystem_pthread.tbd(/usr/lib/system/libsystem_pthread.dylib) is incompatible with x86_64 (iOS Simulator) Repros with 12.4 and 12.5 as well (and I presume other 12.x versions). The error message seems legit, as far as I can tell. If I look at the iPhoneSimulator libSystem.tbd, libsystem_kernel indeed doesn't have x86_64-ios-simulator in its targets list. However, it's re-exported by libsystem_sim_kernel_host, which does mark it as a re-export for the x86_64-ios-simulator target (potentially a bug?). libsystem_sim_kernel_host is re-exported by libsystem_sim_kernel, which is re-exported by libSystem, which is presumably how we end up with the error. ld64 is able to handle this libSystem. Interestingly enough, even if I force a reference to __kernelrpc_mach_port_destroy_trap, which is not defined for x86_64-ios-simulator (but is defined for x86_64-macos), it's able to link. The link does fail if I reference ___aio_suspend, which is only defined for i386-macos. I don't know if ld64 is specifically treating ios-simulator and macos as equivalent, or if it's only looking at the architecture and not the platform in general.
> I don't know if ld64 is specifically treating ios-simulator and macos as equivalent, or if it's only looking at the architecture and not the platform in general. I think it's only looking at the architecture. I changed the top-level libSystem.B.dylib's x86_64 target to use watchOS, maccatalyst etc in place of ios-simulator and ld did not complain at all...
Oh... I think ld64 actually just special-cases a bunch of libsystem dylibs.