您当前的位置: 首页 > 

NDK revision 9 发布了。

发布时间:2013-08-31 14:22:06 ,浏览量:0

The NDK is a toolset that allows you to implement parts of your app using native-code languages such as C and C++. For certain types of apps, this can be helpful so you can reuse existing code libraries written in these languages, but most apps do not need the Android NDK.

Before downloading the NDK, you should understand that the NDK will not benefit most apps. As a developer, you need to balance its benefits against its drawbacks. Notably, using native code on Android generally does not result in a noticable performance improvement, but it always increases your app complexity. In general, you should only use the NDK if it is essential to your app—never because you simply prefer to program in C/C++.

Typical good candidates for the NDK are self-contained, CPU-intensive operationsthat don't allocate much memory, such as signal processing, physics simulation, and so on. When examining whether or not you should develop in native code, think about your requirements and see if the Android framework APIsprovide the functionality that you need.

http://developer.android.com/tools/sdk/ndk/index.html#Installing

With NDK revision 9 and higher, the release packages have been split to reduce download size.The first download for each platform contains the default NDK toolchain. The second download containslegacyNDK toolchains for that platform, which is only required if you are not using the current, recommended toolchain for your NDK builds.

难道legacy的是需要自己配置的NDK编译工具?

Revisions

The following sections provide information about releases of the NDK.

Android NDK, Revision 9 (July 2013)

Important changes:
  • Added support for Android 4.3 (API level 18). For more information, see STABLE-APIS.html and new code examples in samples/gles3jni/README.
  • Added headers and libraries forOpenGL ES 3.0, which is supported by Android 4.3 (API level 18) and higher. 支持OPEGLES3.0
  • Added GNU Compiler Collection (GCC) 4.8 compiler to the NDK. Since GCC 4.6 is still the default, you must explicitly enable this option:
    • For ndk-build builds,export NDK_TOOLCHAIN_VERSION=4.8 or add it in Application.mk. 手动打开使用4.8,默认4.6
    • For standalone builds, use the --toolchain= option in make-standalone-toolchain.sh, for example: --toolchain=arm-linux-androideabi-4.8

    Note: The -Wunused-local-typedefs option is enabled by -Wall. Be sure to add __attribute__((unused)) if you use compile-time asserts like sources/cxx-stl/stlport/stlport/stl/config/features.h, line #311. For more information, see Change 55460

    Note: In the GCC 4.7 release and later, ARM compilers generateunaligned access code by default for ARMv6 and higher build targets.ARM的编译器为armv6和更高版本的目标,默认产生未对齐的访问代码You may need to add the -mno-unaligned-access build option when building forkernels that do not support this feature.  编译内核的时候,要注意了。

  • Added Clang 3.3 support. The NDK_TOOLCHAIN_VERSION=clang build option now picks Clang 3.3 by default.

    Note: Both GCC 4.4.3 and Clang 3.1 are deprecated, and will be removed from the next NDK release.

  • Updated GNU Project Debugger (GDB) to support python 2.7.5.
  • Added MCLinker to support Windows hosts. Since ld.gold is the default where available, you must add -fuse-ld=mcld in LOCAL_LDFLAGS or APP_LDFLAGS to enable MCLinker.
  • Added ndk-depends tool which printsELF library dependencies. For more information, see NDK-DEPENDS.html. (Issue 53486) 可以打印ELF库的依赖性信息了,因为有ndk-depends工具了。
Important bug fixes:
  • Fixed potential event handling issue in android_native_app_glue. (Issue 41755)
  • Fixed ARM/GCC-4.7 build to generate sufficient alignment for NEON load and store instructions VST and VLD. (GCC Issue 57271)
  • Fixed a GCC 4.4.3/4.6/4.7 internal compiler error (ICE) for a constant negative index value on a string literal. (Issue 54623)
  • Fixed GCC 4.7 segmentation fault for constant initialization with an object address. (Issue 56508)
  • Fixed GCC 4.6 ARM segmentation fault for -O values when using Boost 1.52.0. (Issue 42891)
  • Fixed libc.so and libc.a to support the wait4() function. (Issue 19854)
  • Updated the x86 libc.so and libc.a files to include the clone() function.
  • Fixed LOCAL_SHORT_COMMANDS bug where the linker.list file is empty or not used.
  • Fixed GCC MIPS build on Mac OS to use CFI directives, without which ld.mcld --eh-frame-hdr fails frequently.
  • Fixed Clang 3.2 X86/MIPS internal compiler error in llvm/lib/VMCore/Value.cpp. (Change 59021)
  • Fixed GCC 4.7 64-bit Windows assembler crash. (Error: out of memory allocating 4294967280 bytes).
  • Updated ndk-gdb script so that the --start or --launch actions now wait for the GNU Debug Server, so that it can more reliably hit breakpoints set early in the execution path (such as breakpoints in JNI code). (Issue 41278)

    Note: This feature requires jdb and produces warning about pending breakpoints. Specify the --nowaitoption to restore previous behavior.

  • Fixed GDB crash when library list is empty.
  • Fixed GDB crash when using a stepi command past a bx pc or blx pc Thumb instruction. (Issue 56962, Issue 36149)
  • Fixed MIPS gdbserver to look for DT_MIPS_RLD_MAP instead of DT_DEBUG. (Issue 56586)
  • Fixed a circular dependency in the ndk-build script, for example: If A->B and B->B, then B was dropped from build. (Issue 56690)
Other bug fixes:
  • Fixed the ndk-build script to enable you to specify a version of Clang as a command line option (e.g.,NDK_TOOLCHAIN_VERSION=clang3.2). Previously, only specifying the version as an environment variable worked.
  • Fixed gabi++ size of _Unwind_Exception to be 24 for MIPS build targets when using the Clang compiler. (Change 54141)
  • Fixed the ndk-build script to ensure that built libraries are actually removed from projects that include prebuilt static libraries when using the ndk-build clean command. (Change 54461, Change 54480)
  • Modified the NDK_ANALYZE=1 option to be less verbose.
  • Fixed gnu-libstdc++/Android.mk to include a backward/ path for builds that use backward compability. (Issue 53404)
  • Fixed a problem where stlport new sometimes returned random values.
  • Fixed ndk-gdb to match the order of CPU_ABIS, not APP_ABIS. (Issue 54033)
  • Fixed a problem where the NDK 64-bit build on MacOSX choses the wrong path for compiler. (Issue 53769)
  • Fixed build scripts to detect 64-bit Windows Vista. (Issue 54485)
  • Fixed x86 ntonl/swap32 error: invalid 'asm': operand number out of range. (Issue 54465, Change 57242)
  • Fixed ld.gold to merge string literals.
  • Fixed ld.gold to handle large symbol alignment.
  • Updated ld.gold to enable the --sort-section=name option.
  • Fixed GCC 4.4.3/4.6/4.7 to suppress the -export-dynamic option for statically linked programs. GCC no longer adds an .interp section for statically linked programs.
  • Fixed GCC 4.4.3 stlport compilation error about inconsistent typedef of _Unwind_Control_Block. (Issue 54426)
  • Fixed awk scripts to handle AndroidManifest.xml files created on Windows which may contain trailing \rcharacters and cause build errors. (Issue 42548)
  • Fixed make-standalone-toolchain.sh to probe the prebuilts/ directory to detect if the host is 32 bit or 64 bit.
  • Fixed the Clang 3.2 -integrated-as option.
  • Fixed the Clang 3.2 ARM EHABI compact model pr1 and pr2 handler data.
  • Added clang -mllvm -arm-enable-ehabi option to fix the following clang error:
    clang: for the -arm-enable-ehabi option: may only occur zero or one times!
  • Fixed build failure when there is no uses-sdk element in application manifest. (Issue 57015)
Other changes:
  • Header Fixes
    • Modified headers to make __set_errno an inlined function, since __set_errno in errno.h is deprecated, andlibc.so no longer exports it.
    • Modified elf.h to include stdint.h. (Issue 55443)
    • Fixed sys/un.h to be included independently of other headers. (Issue 53646)
    • Fixed all of the MotionEvent_getHistorical API family to take the const AInputEvent* motion_event. (Issue 55873)
    • Fixed malloc_usable_size to take const void*. (Issue 55725)
    • Fixed stdint.h to be more compatible with C99. (Change 46821)
    • Modified wchar.h to not redefine WCHAR_MAX and WCHAR_MIN
    • Fixed  declaration for pointer-related PRI and SCN macros. (Issue 57218)
    • Changed the sys/cdefs.h header so that __WCHAR_TYPE__ is 32-bit for API levels less than 9, which means that wchat_t is 32-bit for all API levels. To restore the previous behavior, define the _WCHAR_IS_8BIT boolean variable. (Issue 57267)
  • Added more formatting in NDK docs/ and miscellaneous documentation fixes.
  • Added support for a thin archive technique when building static libraries. (Issue 40303)
  • Updated script make-standalone-toolchain.sh to support the stlport library in addition to gnustl, when you specify the option --stl=stlport. For more information, see STANDALONE-TOOLCHAIN.html.
  • Updated the make-standalone-toolchain.sh script so that the --llvm-version= option creates the$TOOLCHAIN_PREFIX-clang and $TOOLCHAIN_PREFIX-clang++ scripts in addition to clang and clang++, to avoid using the host's clang and clang++ definitions by accident.
  • Added two flags to re-enable two optimizations in upstream Clang but disabled in NDK for better compatibility with code compiled by GCC:
    • Added a -fcxx-missing-return-semantics flag to re-enable missing return semantics in Clang 3.2+. Normally, all paths should terminate with a return statement for a value-returning function. If this is not the case, clang inserts an undefined instruction (or trap in debug mode) at the path without a return statement. If you are sure your code is correct, use this flag to allow the optimizer to take advantage of the undefined behavior. If you are not sure, do not use this flag. The caller may still receive a random incorrect value, but the optimizer will not exploit it and make your code harder to debug.
    • Added a -fglobal-ctor-const-promotion flag to re-enable promoting global variables with static constructor to be constants. With this flag, the global variable optimization pass of LLVM tries to evaluate the global variables with static constructors and promote them to global constants. Although this optimization is correct, it may cause some incompatability with code compiled by GCC. For example, code may do const_cast to cast the constant to mutable and modify it. In GCC, the variable is in read-write and the code is run by accident. In Clang, the const variable is in read-only memory and may cause your application to crash.
  • Added -mldc1-sdc1 to the MIPS GCC and Clang compilers. By default, compilers align 8-byte objects properly and emit the ldc1 and sdc1 instructions to move them around. If your app uses a custom allocator that does not always align with a new object's 8-byte boundary in the same way as the default allocator, your app may crash due to ldc1 and sdc1 operations on unaligned memory. In this case, use the -mno-ldc1-sdc1 flag to workaround the problem.
  • Downgraded the event severity from warning to info if APP_PLATFORM_LEVEL is larger thanAPP_MIN_PLATFORM_LEVEL. The APP_PLATFORM_LEVEL may be lower than APP_PLATFORM in jni/Application.mkbecause the NDK does not have headers for all levels. In this case, the actual level is shifted downwards.TheAPP_MIN_PLATFORM_LEVEL is specified by the android:minSdkVersion in your application's manifest. (Issue 39752)
  • Added the android_getCpuIdArm() and android_setCpuArm() methods to cpu-features.c. This addition enables easier retrieval of the ARM CPUID information. (Issue 53689)
  • Modified ndk-build to use GCC 4.7's as/ld for Clang compiling.

    Note: In GCC 4.7, monotonic_clock and is_monotonic have been renamed to steady_clock and is_steady, respectively.

  • Added the following new warnings to the ndk-build script:
    • Added warnings if LOCAL_LDLIBS/LDFLAGS are used in static library modules.
    • Added a warning if a configuration has no module to build.
    • Added a warning for non-system libraries being used in LOCAL_LDLIBS/LDFLAGS of a shared library or executable modules.
  • Updated build scripts, so that if APP_MODULES is not defined and only static libraries are listed in Android.mk, the script force-builds all of them. (Issue 53502)
  • Updated ndk-build to support absolute paths in LOCAL_SRC_FILES.
  • Removed the *-gdbtui executables, which are duplicates of the *-gdb executables with the -tui option enabled.
  • Updated the build scripts to warn you when the Edison Design Group (EDG) compiler front-end turns_STLP_HAS_INCLUDE_NEXT back on. (Issue 53646)
  • Added the environment variable NDK_LIBS_OUT to allow overriding of the path for libraries/gdbserver from the default $PROJECT/libs. For more information, see OVERVIEW.html.
  • Changed ndk-build script defaults to compile code with format string protection -Wformat -Werror=format-security. You may set LOCAL_DISABLE_FORMAT_STRING_CHECKS=true to disable it. For more information, seeANDROID-MK.html
  • Added STL pretty-print support in ndk-gdb-py. For more information, see NDK-GDB.html.
  • Added tests based on the googletest frameworks.
  • Added a notification to the toolchain build script that warns you if the current shell is not bash.
  • The NDK is a toolset that allows you to implement parts of your app using native-code languages such as C and C++. For certain types of apps, this can be helpful so you can reuse existing code libraries written in these languages, but most apps do not need the Android NDK.

    Before downloading the NDK, you should understand that the NDK will not benefit most apps. As a developer, you need to balance its benefits against its drawbacks. Notably, using native code on Android generally does not result in a noticable performance improvement, but it always increases your app complexity. In general, you should only use the NDK if it is essential to your app—never because you simply prefer to program in C/C++.

    Typical good candidates for the NDK are self-contained, CPU-intensive operations that don't allocate much memory, such as signal processing, physics simulation, and so on. When examining whether or not you should develop in native code, think about your requirements and see if the Android framework APIs provide the functionality that you need.

关注
打赏
1688896170
查看更多评论

暂无认证

  • 0浏览

    0关注

    114465博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0806s