Hello,
I have an android application which has neon optimised native code. The neon instructions were written for armv7a architecture. I've read that ARMv8 arch can run in both 32bit mode and 64bit mode. I've been trying to compile the code using ndk-r10c for ARMv8 but I didn't find any compiler flag to build in 32bit mode. While I was experimenting, I changed APP_ABI from armeabi-v7a to ARM64-v8a in Application.mk and received error stating that neon is not supported. Later I disabled -mfpu=neon cflag in Android.mk, error shown was unknown mnemonics for all the neon assembly instructions
So following are my questions....
1) What are the proper flags to be set to build using ndk-r10c
2) or the code built for armeabi-v7a will run as it is on ARMv8
3) if 2 is true then can a combination of 32bit built and 64bit built so work together.
Thanks
Vidit
If I understand correctly you're trying to build NEON assembly written for armv7 into an armv8-AArch64 application. If it is the case, this is unfortunately not possible.
You can build your application as 32-bit, you're very likely to be able to run it on an armv8 platform (only very few obscure features cause difficulties).
If you want to build your application as 64-bit:
- convert your code to 64-bit NEON assembly
- or (probably) better: rewrite the code using NEON intrinsics which you can compile for 32-bit and 64-bit.
Hope this helps.
Regards,
Kévin
Thanks Kevin for the reply.
Yes I'm trying to build neon assembly code written for armv7 into armv8. But armv8 provides two mode AArch32 and AArch64 . I want to reuse(avoiding rewriting) previously written code for armv8 AArch32 mode.
Could you please clarify on this
Regards
I want to reuse(avoiding rewriting) previously written code for armv8 AArch32 mode.
That will work for NEON.
"as 32-bit" means armv7 built version?
Technically it should mean Armv8-AArch32 but I'm not aware of a NDK version that can do precisely that. The differences are very tiny for most applications so yes, in practise, you can consider it means "armv7 built".
So it means that code built for armv7 will work with armv8 with few exceptions.Can you elaborate on what are these obscure cases(any documentation or links will be helpful).
The most prominent examples are probably:
- VFP short vectors
- The SETEND and SWP instructions
- CP15 barriers
Basically, if your code has been built for v7 and you don't embed binary libraries or have assembly except NEON, you should be fine.
over here again by 32-bit do you mean intrinsic code build for armv7?
Intrinsics are a compiler-level abstraction for NEON instructions. They are presented to the programmer as C functions but most of the time compile down to one instruction. Code written with these NEON intrinsics can be built for armv7 or 64-bit armv8. Besides portability you may also get performance benefit to using intrinsics.
Thanks a lot Kévin for clearing the my doubts. Just a last query which i had stated before. Say i have a .so built in 32-bit and I want to use it along with 64 bit built code. Will it work fine. I have read that armv8 switches modes using exception levels. Will it be applicable here.
Say i have a .so built in 32-bit and I want to use it along with 64 bit built code. Will it work fine. I have read that armv8 switches modes using exception levels. Will it be applicable here.
You can't use different bitnesses in the same process. Using a 32-bit library from a 64-bit binary isn't possible. Switching between 32 and 64-bit bit can only be done by the OS, at the process level.
Thanks Kévin for your answers