-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ld64.lld: Add support for _objc_msgSend stubs from Xcode 14 #56034
Comments
@llvm/issue-subscribers-lld-macho |
I've submitted a WIP version of this here https://reviews.llvm.org/D128108 for early feedback. See the diff for more info |
How can I pass -fno-objc-msgsend-selector-stubs to all clang invocations? |
That depends on your build system, but you should add that flag however you generally pass C/C++/Objective-C compiler flags |
The patch is now ready for actual review. Currently it supports x86_64 (which clang doesn't enable selector stubs by default for in Xcode 14 beta 4) and arm64 (no watchOS CPUs), and it only implements the "fast" mode for now. |
I just landed https://reviews.llvm.org/D128108 which covers all except the cases mentioned above, I will leave this issue open to track those |
Clang will by default emit objc_msgSend stubs in Xcode 14, which ld from earlier Xcodes doesn't understand. We disable this by passing -fno-objc-msgsend-selector-stubs to clang. Ref: https://developer.apple.com/videos/play/wwdc2022/110363/ Ref: https://www.wwdcnotes.com/notes/wwdc22/110363/ Ref: llvm/llvm-project#56034 Fixes xamarin#16223.
Clang will by default emit objc_msgSend stubs in Xcode 14, which ld from earlier Xcodes doesn't understand. We disable this by passing -fno-objc-msgsend-selector-stubs to clang. Ref: https://developer.apple.com/videos/play/wwdc2022/110363/ Ref: https://www.wwdcnotes.com/notes/wwdc22/110363/ Ref: llvm/llvm-project#56034 Fixes xamarin#16223.
Clang will by default emit objc_msgSend stubs in Xcode 14, which ld from earlier Xcodes doesn't understand. We disable this by passing -fno-objc-msgsend-selector-stubs to clang. Ref: https://developer.apple.com/videos/play/wwdc2022/110363/ Ref: https://www.wwdcnotes.com/notes/wwdc22/110363/ Ref: llvm/llvm-project#56034 Fixes xamarin#16223.
Clang will by default emit objc_msgSend stubs in Xcode 14, which ld from earlier Xcodes doesn't understand. We disable this by passing -fno-objc-msgsend-selector-stubs to clang. Ref: https://developer.apple.com/videos/play/wwdc2022/110363/ Ref: https://www.wwdcnotes.com/notes/wwdc22/110363/ Ref: llvm/llvm-project#56034 Fixes xamarin#16223.
Clang will by default emit objc_msgSend stubs in Xcode 14, which ld from earlier Xcodes doesn't understand. We disable this by passing -fno-objc-msgsend-selector-stubs to clang. Ref: https://developer.apple.com/videos/play/wwdc2022/110363/ Ref: https://www.wwdcnotes.com/notes/wwdc22/110363/ Ref: llvm/llvm-project#56034 Fixes #16223.
#16223. (#16232) Clang will by default emit objc_msgSend stubs in Xcode 14, which ld from earlier Xcodes doesn't understand. We disable this by passing -fno-objc-msgsend-selector-stubs to clang. Ref: https://developer.apple.com/videos/play/wwdc2022/110363/ Ref: https://www.wwdcnotes.com/notes/wwdc22/110363/ Ref: llvm/llvm-project#56034 Fixes #16223. Backport of #16231 Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
…16236) Clang will by default emit objc_msgSend stubs in Xcode 14, which ld from earlier Xcodes doesn't understand. We disable this by passing -fno-objc-msgsend-selector-stubs to clang. Ref: https://developer.apple.com/videos/play/wwdc2022/110363/ Ref: https://www.wwdcnotes.com/notes/wwdc22/110363/ Ref: llvm/llvm-project#56034 Fixes #16223. Backport of #16231 Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Xcode build-setttings other c flags |
I set it in |
With the newest ld64.lld this should no longer be necessary though. Please report any issues you find! |
The fix is not released yet right? It didn't seem to work for me in ld64.lld 15.... |
Yea you're right. In the meantime if you'd like you can build from HEAD or use my binary releases here https://github.com/keith/ld64.lld |
I'm actually going to close this one to make it clear that this is supported in LLVM @ HEAD, and will be in LLVM 16. Please open new issues and cc me for anything you find! |
Xcode 14's Clang will emit objc_msgSend stubs by default, which ld from earlier Xcode versions will fail to understand. Disable these stubs explicitly for static libs, for as long as we support Xcode < 14. See llvm/llvm-project#56034 Pick-to: 6.5 Fixes: QTBUG-112820 Change-Id: Id762873d61b9d147bf3eb6292297e7b80b7393e1 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Xcode 14's Clang will emit objc_msgSend stubs by default, which ld from earlier Xcode versions will fail to understand. Disable these stubs explicitly for static libs, for as long as we support Xcode < 14. See llvm/llvm-project#56034 Fixes: QTBUG-112820 Change-Id: Id762873d61b9d147bf3eb6292297e7b80b7393e1 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit c91ae57) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
In Xcode 14 / ld 816 Apple implemented a size / performance optimization where they deduplicate _objc_msgSend setup infrastructure by Objective-C selectors. This comes in the form of undefined symbols in each object file:
Then the linker inserts these stubs during link, one for each selector string after the
$
(see the final symbol):This new feature is enabled by default in Apple clang 14, and doesn't seem to be in Apple's public fork. It can be disabled in the meantime by passing
-fno-objc-msgsend-selector-stubs
to all clang compiles.The reason behind this feature is explained in this WWDC session but the gist is them trying to dedup the duplicate setup code that was previously inlined for each objc_msgSend call.
The implementation of these symbols is also described in that session, the linker has 2 modes, the default mode (which is the same as passing
-objc_stubs_fast
) produces this asm on arm64:Where the other mode optimizing for size, controlled by passing
-objc_stubs_small
produces this asm on arm64:The major difference here being the extra inline instruction size, vs the extra jump to the objc_msgSend stub.
Some other various notes:
__TEXT,__objc_stubs
section__selrefs
section which lld does not currently implement-fno-objc-msgsend-selector-stubs
to all clang invocations is the only way I see to disable (note this flag is undocumented)The text was updated successfully, but these errors were encountered: