When compiling the NDK project, the compiler does not recognize the arm assembly, setting Local_arm_mode: = Arm post-issue resolution,
The instructions for Local_arm_mode on the NDK documentation are as follows:
LOCAL_ARM_MODE
By default, ARM target binaries is generated in ' thumb ' mode, where each instruction is 16-bit wide, and linked with/th UMB STL Libraries. Can define this variable to "If you want to force the generation of the arm module ' s object files in ' Arm ' (32-bit Instructions) mode. e.g.:
Note that you can also instruct the build system to only build specific sources in ARM mode by appending a ' .arm suffix To its source file name. For example, with:
Tells the build system to always compile " bar.c in ARM mode, and to build according to the foo.c value of Local_arm_mode.
Note:setting App_optim to "in your would also force the debug Application.mk generation of ARM binaries as well. This was due to bugs in the Toolchain debugger that don ' t deal too well with thumb code.
The description on the document is relatively brief, I found a good article on the Internet, as follows:
Original link: http://blog.k-res.net/archives/1291.html
< span> arm control, the NDK uses the thumb instruction set by default)
but recently, when Xcode compiled the iOS project, I noticed that the Apple device with the ARM processor was using the thumb instruction set, and it seemed to be a new version of the thumb instruction set, and a little search to see someone say this Arm The instruction set introduced by V7, called Thumb-2, is better than the arm instruction set! So we re-searched and updated the brain Knowledge Base ...
ARMV7, for Apple devices, means the CPU of devices above the iphone 3GS, and the current mainstream Android device is almost all ARMV7 processors. Perhaps the arm instruction set has an advantage over the early ARMV6 processor, but for the new V7 processor, the various data indicate that Thumb-2 is better.
In general, ARM command rallies have advantages in some areas, such as handwritten compilations (the sum ... , while the thumb can generate more streamlined code, and there's one more thing I didn't realize before: Save power! So after careful consideration, I decided to change the NDK compilation option from the original arm back to the default thumb, follow the default principle or.
For V7 and non-v7 problems, Android can do this, to slightly increase the cost of the APK, to add a separate for V7 and non-v7 version of so files, so that the APK will be installed automatically according to the target device's CPU installed the appropriate so library, so as to achieve better results, The practice is to include in the Application.mk "APP_ABI := armeabi armeabi-v7a"
In addition, as the project size increases, the code compile generation time will be greatly increased, when you can consider replacing the r8c version of the NDK new Clang compiler (Apple's compiler, the new version of Xcode using it by default), measured found clang much faster than GCC, and for warning, The display of error is also more human than GCC (some people say that gcc hints like a heavenly book, hehe), but it is said that Clang also have some shortcomings, such as the standard of support is not as good as GCC (this is how to listen to say that the MS ...) is not as good as the language supported by GCC, but it feels like nothing to do with Android native development, I just need to compile fast and run fast!
Use the Clang compiler as follows:
< Span style= "FONT-SIZE:12PT;" >NDK -build mode, you can use "Export ndk_toolchain_version= clang 3.1 "Export environment variables, Or add this environment variable setting to APPLICATION.MK.
for standalone compilation, add –llvm-version=3.1 to the make-standalone-toolchain.sh script and use <tool-path>/bin/in makefile clang and <tool-path>/bin/ clang + + replaces the CC and cxx parameters.
PS: Actual compile-time discovery Clang seems to support Chinese comments is not particularly good, such as the end of the code in the IF (...) Thanks to the//Chinese comments, resulting in the compiler processing this place directly reported the exception, delete the comments after the OK ...
Reference article:
- Producing Optimised NDK code for multiple architectures? http://stackoverflow.com/ Questions/5089783/producing-optimised-ndk-code-for-multiple-architectures
- is there A-to compile-ARM rather than Thumb in Xcode 4? http://stackoverflow.com/questions/8390606/is-there-a-way-to-compile-for-arm-rather-than-thumb-in-xcode-4
Understanding of the Android NDK compiler arm and thumb mode