Skip to content
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

Merged
merged 1 commit into from
Dec 8, 2016
Merged

fix objc ABI in std::env::args #38146

merged 1 commit into from
Dec 8, 2016

Conversation

kali
Copy link
Contributor

@kali kali commented Dec 3, 2016

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.

@rust-highfive
Copy link
Collaborator

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.

@alexcrichton
Copy link
Member

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?

@kali
Copy link
Contributor Author

kali commented Dec 6, 2016

It definitely fixes the aarch64 version. Let me check the armv7 variant.

@hanna-kruppe
Copy link
Contributor

It doesn't define the symbols twice, it picks one definition each based on cfg(target_arch).

@kali
Copy link
Contributor Author

kali commented Dec 6, 2016

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.

@alexcrichton
Copy link
Member

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+

@bors
Copy link
Contributor

bors commented Dec 8, 2016

📌 Commit a1882ca has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Dec 8, 2016

⌛ Testing commit a1882ca with merge 816a34a...

bors added a commit that referenced this pull request Dec 8, 2016
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.
@bors bors merged commit a1882ca into rust-lang:master Dec 8, 2016
@kali
Copy link
Contributor Author

kali commented Dec 8, 2016

thanks!

@brson
Copy link
Contributor

brson commented Jan 10, 2017

Nice find.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants