-
Notifications
You must be signed in to change notification settings - Fork 704
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
Build and testing for iOS #184
Comments
The issues I had with clang 3.9 snapshot has issues with the code generated by |
armv7*-applie-ios is a dying platform, so I'm OK with just using the C implementation instead of the asm implementation for those targets. I don't want to spend extra effort on 32-bit ARM iPhones which clearly Apple is going all-Aarch64.
I'll try merging in the latest OpenSSL versions. |
My first attempt at this is in my ios branch: https://github.com/briansmith/ring/tree/ios. Let me know if/how it helps. |
I've updated my |
I've now pushed all those asm changes to master. |
Cool, I'll test them out. I was worried ring wouldn't build for android when using the clang based tooling but it uses gcc as assembler. |
Any update? If you're too busy to finish this, then could you share your partially-completed work? Your contributions have been amazing and I'm really looking forward to getting the iOS stuff done. |
FYI, I looked into automated testing on-device with iOS when working on my Gecko port, and it's a nightmare. The only real supported scenario for unit tests is XCTest run from XCode: There is There is this undocumented project I found from some brief googling which looks promising: |
OK, #315 may not work as I thought it was, but we made a cargo extension to help testing "stuff" library on device. |
I have added support for external files on iOS in dinghy starting 0.1.12. With a tiny set of changes to tests #429, we have x86_64 ios simulator and aarch64 ios devices passing! Both armv7 variant are not working. They are actually crashing without much information. Maybe dinghy eats it somewhere, I'm investigating. I also gave a quick shot at running the tests on an android phone (despite not having a strategy for copying the support files yet), but it looks like dinghy does not even manage to link the test runner. More investigations. |
mmm... back in GFp_x25519_NEON :/
|
Do you think this could be a THUMB2 issue? Maybe the iOS machine requires THUMB2? Otherwise, can we isolate the bad instruction? |
I'm not sure where this is going, but at least it's prompting me to extends Dinghy's capabilities :) Now it can run lldb interactively... Here is a lldb dump of the begin of the problematic function. TBH, I'm not even sure it makes any sense at all. WDYT ?
|
That disassembly doesn't look like it makes sense to me. I'm guessing that we have a mismatch in expectations between thumb and non-thumb mode. I think maybe the problem is the |
It does work without the thumb_func, good call. PR coming. |
With that we're down to two failing test on armv7, i'm having a look:
|
ok, once again, I'm not too sure about what is happening. Could you enlight me again ? what are we trying to check there ?
|
That test is verifying that our understanding of the alignment of C's
It seems like we need to switch the alignment factor that applies for 32-bit ARM iOS in a similar way. Note that this won't have any effect other than making the test pass. The reason for this test is to ensure we don't get surprised by alignment requirements on new architectures that are different than what we've already run into. |
“An important difference between iOS ABI and EABI is alignment of 64-bit arguments: iOS uses 4-byte alignment, while EABI uses 8.” - http://stackoverflow.com/questions/2795360/iphone-arm-calling-convention#comment17867468_13131328 |
It seems like maybe we should be preserving the |
I filed #439 about enabling Thumb-2. |
With this latest PR, I could make ring compile and pass test on the four iOS arch I have at my disposal (armv7, v7s, aarch64, and the x86_64 sim). I am not in a position to test the x86 simulator. It may need the same kind of fix than #440, but I'm not sure we care that much. |
Awesome work!
I think it was already fixed earlier, since it was already handled the same way: all(target_arch = "x86", target_os = "ios"),
all(target_arch = "arm", target_os = "ios") What about the potential register preservation issues mentioned in #184 (comment)? Are you or is anybody you know able to research and correct that? See https://bugs.chromium.org/p/boringssl/issues/detail?id=176 in addition to what I pointed out above, which shows that this code likely isn't perfect in that respect. |
Yeah, I think you're right. From my understanding, r11 must be saved and restored, r7 must at least be saved and restored, and it would be better to set it to the FP value so that debugger would not get lost. I'll try to have a look one of these days. |
About the ARM code, looking at the prolog and epilog, I notice that r11 and r7 are saved and restored (the strd and ldrd store/load two registers at a time). |
* Double 0x fix in address * fix targetSdkVersion again * project.pbxproj sync * exclude i386-apple-ios x86_64-apple-ios targets due to a ring issue briansmith/ring#184
32-bit iOS is no longer a thing so i386- and armv7- don't matter any more, IIUC. aarch64-apple-ios is now built in CI/CD but the tests are not run. This is blocked on having M1 Mac runners. My understanding is that on M1 Macs, Xcode's iOS emulator will run ARM iOS executables. We should add x86_64-apple-ios builds to CI/CD as well, I suppose, to make sure we stay compatible with the emulator on x86_64 Macs. https://medium.com/snips-ai/dinghy-painless-rust-tests-and-benches-on-ios-and-android-c9f94f81d305 notes that (prior to ring 0.16.17), cargo dinghy had trouble building ring. I think that was because they were building ring from GitHub and so the warnings that were fixed in PR #1071 were probably breaking their build. So, while the aforementioned CI/CD job will probably help ensure ring keeps working with cargo dinghy, it might be worth having a new CI/CD job for that. |
I think this is probably as complete as we can get it. |
My work on iOS is on commits: pietro/ring@b4a0141, pietro/ring@db3e647 and pietro/ring@7aec786
I don't know much about testing static libraries on iOS. But with my changes all tests pass for
i386-apple-ios
andx86_64-apple-ios
. And building works foraarch64-apple-ios
.Both
armv7-apple-ios
andarmv7s-apple-ios
fail due to differences on the syntax ofcrypto/curve25519/asm/x25519-asm-arm.S
and what the version of clang distributed by apple support.FYI:
The text was updated successfully, but these errors were encountered: