-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
support an armv7-android-linuxeabi target #33278
Comments
But the Our current nightly has following features enabled for the arm-linux-androideabi triplet: |
I believe the current ABIs supported by Android itself are listed here and although we have not thoroughly documented what our Android target is going for, it's defacto been going towards armeabi-v7a. So in that spirit we should just update our target spec to include Thumb (as mentioned by @nagisa), but I'm also curious about the |
So there are two different choices for how to pass floating-point arguments on ARM:
What does
Thumb is very desirable...the smaller the Rust runtime libraries were, the better from the perspective of our mobile team. I think we'd want to support |
I propose to define android target instruction sets and names based on official ABI list.
I think our android target If we look at the official list of ABIs, it is clear that we will want soon to support all the flavors, with instruction sets that are defined there. The wishes what we would want android targets to be are not relevant or would at least be very inconvenient to use. I propose this path forward:
There is also a precedent here: Rust iOS targets (which have to work on similar archs) are already prepared this way and they are easy to use: Also, if we follow this approach, the addition of "hf" to the name is not necessary, because the hf requirement comes implicitly from supporting a particular ABI. |
The usual approach in android-land when working with native code is to compile native code for multiple ABIs and then combine them into single "fat" apk that can work on different devices. Is is also possible to make "split" apks to reduce apk size. But the main point I want to make here that it would be easiest to do that if there was 1:1 mapping between android ABI and Rust target. That way, we could be sure we support all range of options with optimal configurations for each. |
Aligning Rust targets with Android ABI names makes sense to me. |
@Nercury yeah I'm inclined to agree, it definitely seems simplest if everything maps 1:1 with the official ABI list. cc @larsbergstrom, this may involve changing the definition of
That way Servo should always have a nightly with "fast Android" ? |
@alexcrichton This should work fine for Servo! We already pass a special target triple to Rust different from the native dependencies on a few other ARM platforms, so we have support for mix-and-match in our driver (mach). |
The armeabi-v7a ABI requires VFPv3-D16, so this should be safe to use in the
This has one downside that may be unavoidable: The Android NDK toolchain uses the target triple Lastly, Android itself can be built with a "target variant" |
It concerns me that I don't see google defining target triples for all their ABI's - as @mbrubeck says they seem to just always use |
@brson I guess their idea is that the requested abi carries enough options for Of course, the "target variant" must match variant used for std libs. I am almost done with |
FYI, to cover all performance needs, users would be interested in these targets:
|
I think the float abi should be hard-float by default. It also seems to me like adding a different target for soft-float/hard-float distinction is not very interesting, because one can enable this by using some codegen flag when using the other target. |
@nagisa I am re-reading armeabi-v7a (armeabi-v7a-hard) section, looks like it should be ok to enable Hard-float ABI calls on However, latest docs do not mention this, except
Which leads me to conclusion that we should use the same setting for I agree that separate target for hard(er) float does not look practical. |
The tools team discussed this issue during triage yesterday, and the decision was to:
Along those lines, @Nercury could the new target be |
It was also thought that we may not want to change the current |
Can we even support |
Yes, LLVM has fallbacks which we can rely on. |
Yes, I changed latest name to be armv7, because android's LLVM configured for arm-v7a produces this header:
Which contains
I imagined to make use of rust std lib compiled with this option. However it is removed in latest android abi docs so I don't think we will make use of it. |
Yeah we can enable the "7a" features through LLVM features I think rather than having to communicate it as part of the triple name |
Add armv7-linux-androideabi target This PR adds `armv7-linux-androideabi` target that matches `armeabi-v7a` Android ABI, ~~downscales `arm-linux-androideabi` target to match `armeabi` Android ABI~~ (TBD later if needed). This should allow us to get the best performance from every [Android ABI level](http://developer.android.com/ndk/guides/abis.html). Currently existing target `arm-linux-androideabi` started gaining features out of the supported range of [android `armeabi`](http://developer.android.com/ndk/guides/abis.html). While android compiler does not use a different target for later supported `armv7` architecture, it has distinct ABI name `armeabi-v7a`. We decided to add rust target `armv7-linux-androideabi` to match it. Note that `NEON`, `VFPv3-D32`, and `ThumbEE` instruction sets are not added, because not all android devices are guaranteed to support all or some of these, and [their availability should be checked at runtime](http://developer.android.com/ndk/guides/abis.html#v7a). ~~This reduces performance of existing `arm-linux-androideabi` and may make it _much_ slower (we are talking more than order of magnitude in some random ad-hoc fp benchmark that I did).~~ Part of #33278.
This is done, and we now have nightlies, so closing. |
Hi team, I know this is closed but it seems steps 2 and 3 aren't yet implemented. Should we reopen this or open new tracking issues? |
* Remove default paths for NDK standalone toolchains. Error if they are needed by a target and undefined. * Use the newer armv7-linux-androideabi Rust target, since we are only targeting armv7. See rust-lang/rust#33278.
Firefox for Android compiles its code with
-march=armv7-a -mthumb -mfpu=vfp -mfloat-abi=softfp
. Inrustc
terms, I think this would be-C +vfp2,+v7-a,+thumb2
. AFAICT, this is somewhat different than thearm-linux-androideabi
target, which appears to not assume the existence of an FPU, and also doesn't compile as Thumb where possible. When using Rust on Android, we'd like our Rust libraries to be just as well optimized as our C++ libraries, which means either a) having an official, tier-2 supported target; or b) compiling it ourselves.One could multiply ARM targets to no end, but this seems like a pretty reasonable target for many Android devices out there. Is it possible to have this target added and supported?
cc @alexcrichton
The text was updated successfully, but these errors were encountered: