michaeleisel / zld

A faster version of Apple's linker
MIT License
1.19k stars 50 forks source link

zld fails to link (or fallbacks to ld) when linking Watch app with bitcode enabled #71

Closed thii closed 1 year ago

thii commented 4 years ago

/Applications/Xcode-12.0.0-gm-seed.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target arm64-apple-watchos7.0-simulator -isysroot /Applications/Xcode-12.0.0-gm-seed.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator7.0.sdk -L/Users/admin/Library/Developer/Xcode/DerivedData/App2-cncnyrokyfrdldfczjlkcqyvxcfc/Build/Products/Debug-watchsimulator -F/Users/admin/Library/Developer/Xcode/DerivedData/App2-cncnyrokyfrdldfczjlkcqyvxcfc/Build/Products/Debug-watchsimulator -filelist /Users/admin/Library/Developer/Xcode/DerivedData/App2-cncnyrokyfrdldfczjlkcqyvxcfc/Build/Intermediates.noindex/App2.build/Debug-watchsimulator/App2\ WatchKit\ Extension.build/Objects-normal/arm64/App2\ WatchKit\ Extension.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/../../Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/admin/Library/Developer/Xcode/DerivedData/App2-cncnyrokyfrdldfczjlkcqyvxcfc/Build/Intermediates.noindex/App2.build/Debug-watchsimulator/App2\ WatchKit\ Extension.build/Objects-normal/arm64/App2\ WatchKit\ Extension_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fembed-bitcode-marker -fapplication-extension -fobjc-link-runtime -L/Applications/Xcode-12.0.0-gm-seed.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/watchsimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/admin/Library/Developer/Xcode/DerivedData/App2-cncnyrokyfrdldfczjlkcqyvxcfc/Build/Intermediates.noindex/App2.build/Debug-watchsimulator/App2\ WatchKit\ Extension.build/Objects-normal/arm64/App2_WatchKit_Extension.swiftmodule -fuse-ld\=/tmp/zld-09ea158 -Wl,-zld_original_ld_path,/Applications/Xcode-12.0.0-gm-seed.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld -e _WKExtensionMain -framework WatchKit -Xlinker -sectcreate -Xlinker TEXT -Xlinker entitlements -Xlinker /Users/admin/Library/Developer/Xcode/DerivedData/App2-cncnyrokyfrdldfczjlkcqyvxcfc/Build/Intermediates.noindex/App2.build/Debug-watchsimulator/App2\ WatchKit\ Extension.build/App2\ WatchKit\ Extension.appex-Simulated.xcent -Xlinker -dependency_info -Xlinker /Users/admin/Library/Developer/Xcode/DerivedData/App2-cncnyrokyfrdldfczjlkcqyvxcfc/Build/Intermediates.noindex/App2.build/Debug-watchsimulator/App2\ WatchKit\ Extension.build/Objects-normal/arm64/App2\ WatchKit\ Extension_dependency_info.dat -o /Users/admin/Library/Developer/Xcode/DerivedData/App2-cncnyrokyfrdldfczjlkcqyvxcfc/Build/Intermediates.noindex/App2.build/Debug-watchsimulator/App2\ WatchKit\ Extension.build/Objects-normal/arm64/Binary/App2\ WatchKit\ Extension

ld: in '/usr/lib/system/libsystem_kernel.dylib', building for watchOS Simulator, but linking in .tbd file (/usr/lib/system/libsystem_kernel.dylib) built for macOS/Mac Catalyst, for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

michaeleisel commented 4 years ago

this is arm64_32? zld will probably never link it on its own unless apple chooses to release the source for arm64_32 linking (no idea why they won't)

thii commented 4 years ago

How does it not fallback to the provided original ld path here?

michaeleisel commented 4 years ago

looking closer, i guess it's not arm64_32, the target says arm64-apple-watchos7.0-simulator. why would the simulator use arm64? is this a new arm mac? my watchos knowledge is limited

thii commented 4 years ago

No, it's an Intel Mac. Not a watchOS expert here either, but what I'm seeing is that when you build your parent iOS app for a simulator (x86_64), Xcode builds a universal binary watchOS app that combines two archs x86_64 and arm64.

michaeleisel commented 4 years ago

i thought watchos only used arm64_32 and armv7k, does it also now use arm64?

thii commented 4 years ago

No idea, I'm guessing that's because the watch simulator on an Apple Silicon would use arm64?

thii commented 4 years ago

Diffing the build commands, this flag was what makes it fail (it is added when you set ENABLE_BITCODE = YES in the watch target):

-fembed-bitcode-marker
michaeleisel commented 3 years ago

is this still a problem on latest master?