-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
fix objc ABI in std::env::args #38146
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Thanks for the PR! I'm kinda surprised this works though because it seems like it's defining the same symbol twice with LLVM with different signatures, which has historically led to lots of aborts. Have you tested this out locally to see if it works? |
It definitely fixes the aarch64 version. Let me check the armv7 variant. |
It doesn't define the symbols twice, it picks one definition each based on cfg(target_arch). |
Ok, it's been a bit slow and painful, but I did manage to compile to armv7 and run on a phone with no complaints from LLVM. |
Hm the compiler is doing something here I'm quite surprised by and didn't expect, but seems to work. The symbol is defined once with the first signature and then casted each time it's used a different time to the different signature. In any case though it looks like it works, so let's get this in @bors: r+ |
📌 Commit a1882ca has been approved by |
fix objc ABI in std::env::args iOS use different calling convention for `objc_msgSend` depending on the platform. armv7 expect good old variadic arguments, but aarch64 wants "normal" convention: `objc_msgSend` has to be called mimicking the actual callee prototype. https://developer.apple.com/library/content/documentation/General/Conceptual/CocoaTouch64BitGuide/ConvertingYourAppto64-Bit/ConvertingYourAppto64-Bit.html#//apple_ref/doc/uid/TP40013501-CH3-SW26 This currently breaks std::env:args() on aarch64 iOS devices. As far as I can tell, in the standard library, this is the only occurrence of ObjectiveC dispatching.
thanks! |
Nice find. |
iOS use different calling convention for
objc_msgSend
depending on the platform. armv7 expect good old variadic arguments, but aarch64 wants "normal" convention:objc_msgSend
has to be called mimicking the actual callee prototype.https://developer.apple.com/library/content/documentation/General/Conceptual/CocoaTouch64BitGuide/ConvertingYourAppto64-Bit/ConvertingYourAppto64-Bit.html#//apple_ref/doc/uid/TP40013501-CH3-SW26
This currently breaks std::env:args() on aarch64 iOS devices. As far as I can tell, in the standard library, this is the only occurrence of ObjectiveC dispatching.