Skip to content

Basic iOS cross compiling support #13574

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

Closed
wants to merge 23 commits into from
Closed

Conversation

vhbit
Copy link
Contributor

@vhbit vhbit commented Apr 17, 2014

Allows to crosscompile and run on iOS (armv7) devices.
Doesn't yet support builds for simulator and for ARM64.
Might miss some functionality but so far experience is pretty good.

vhbit added 17 commits April 17, 2014 10:32
Added following triplets:
i386-apple-ios for simulator
arm-apple-ios for armv7 (for now), arm64 planned in future

Marked iOS ABI to be compatible with MacOS ABI
Unfortunately LLVM code generation for ARM doesn't allow segmented stack
on non-ELF ARM targets
LLVM currently doesn’t support them on DWARF
A little bit cumbersome but for now much easier to configure than
Makefile based
Experimenting with build flags, linker flags and TLS storage

Note: libuv was switched to be built using xcodebuild instead of make as
it was much easier to start. Later it should be changed back to make
just for consistency (although xcodebuild shouldn't be a problem for a
developer, trying to reach out iOS device compiler)

Switched to TLS emulation as it works much better for ARM architecture.
Alternative would be do the same through LLVM but since it requires
additional patching and maintaining it - for now it should be enough to
use this one.

Also, for now iOS is marked just as Macos with ARM target. That
definitely is a temporary workaround to get it working quickly. It
should be changed soon as anyway building for simulator will by still
iOS targeting for i386 which will be confusing if it is considered as
MacOS
Correct naming + stub implementation for iOS
Some unwinding functions are missing on iOS so implemented simply stubs
for them. May be there is a way to simulate their behavior using
existing API. Will check it later
iOS sandboxing mode doesn't allow using /dev/random and /dev/urandom and
the only way to get it working is to use SecCopyBytes function provided
by Security.framework
Considering other code samples, framework suffix is redundant
Deleted some TODOs, commented code and redundant whitespaces
vhbit added 6 commits April 17, 2014 15:37
It should give more compatibility for Android
- Initializing Unsafe with a safer construct
- Updated documentation where possible
- using native Unwind_DeleteException
- forwarding Unwind_RaiseException to native Unwind_SjLj_RaiseException
- still no luck with Unwind_Backtrace
// get all hardware potential via VFP3 (hardware floating point)
// and NEON (SIMD) instructions supported by LLVM.
// Note that without those flags various linking errors might
// arise as some of intrinsicts are converted into function calls
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: intrinsics

_Unwind_SjLj_RaiseException(exc)
}

// On iOS there is no any backtrace function available in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove any

@vhbit
Copy link
Contributor Author

vhbit commented Apr 28, 2014

Just a quick explanation on what happens now: I've got working segmented stack support and unwinding. But both do not work out of box and require patches to LLVM and compiler-rt. Patches were submitted almost a week ago and I hope to get some feedback on them soon.

@alexcrichton
Copy link
Member

Awesome! For reference, do you have links to the patches?

@vhbit
Copy link
Contributor Author

vhbit commented Apr 29, 2014

LLVM: llvm-commits or web-review (I've changed slot from 150 to 149 since our last talk)

compiler-rt: I have no public link as I've sent patch to code owner directly by email, his initial estimation of handling patch queue was Friday but it seems it was over-optimistic. Will ping him again. If you want to see patch itself anyway here is it

@alexcrichton
Copy link
Member

Closing due to inactivity, but feel free to reopen with a rebase, it would be quite nice to have support for ios!

@vhbit vhbit deleted the ios-pr-clean branch June 27, 2014 17:58
flip1995 pushed a commit to flip1995/rust that referenced this pull request Dec 15, 2024
Closes rust-lang#13574

Make sure that `needless_match` doesn't simplify:

```
if let Some(_) = a() {
// ..
} else let Some(_) = b() {
// ..
}
```

to:

```
a()
```

changelog: [`needless_match`]: Fix false-positive on if lets
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.

4 participants