App development

Introducing NDK r21: our first Lengthy Time period Help launch

Posted by Dan Albert, Android NDK Tech Lead

Android NDK r21 is now in beta! It’s been an extended than standard improvement cycle (4 months since NDK r20), so there’s rather a lot to debate for this launch.

We’ve the standard toolchain updates, improved defaults for higher safety and efficiency, and are making modifications to our launch course of to raised accommodate customers that want stability with out hindering people who need new options.

New Minimal System Necessities

This launch comes with new minimal system necessities. Following Android Studio and the SDK, 32-bit Home windows is now not supported. Whereas this variation is not going to have an effect on most builders, this variation does have an effect in case you use 32-bit variations of Microsoft® Home windows®. Linux customers will need to have glibc 2.17 or newer.

Launch Cycle Adjustments and LTS

One launch a 12 months might be our Lengthy Time period Help (LTS) launch for customers that need stability greater than they want new options. The discharge will bear an extended beta cycle earlier than being launched, and can obtain bug fixes as backports till subsequent 12 months’s LTS launch. Typically releasing in This autumn, our first LTS launch might be NDK r21.

The non-LTS releases annually, which we name the “rolling” launch, might be much like our present course of. These might be roughly quarterly releases of our newest set of options, which can solely be patched later for crucial toolchain fixes. If you need the newest options from Clang and libc++, that is the discharge for you.

Extra element, together with the standards we are going to use to find out what might be backported, what sorts of bugs will set off a degree launch, and the bar we maintain every launch to will be discovered documented on our GitHub Wiki.

New Options and Updates

There are various new issues on this launch, resolving bugs and serving to you write higher, safer code.

We’ve up to date GNU Make to model four.2, which permits –output-sync to keep away from interleaving output with error messages. That is enabled by default with ndk-build. This additionally contains numerous bug fixes, together with fixing the pesky CreateProcess errors on Home windows.

GDB has been up to date to model eight.three, which incorporates fixes for debugging trendy Intel CPUs.

Up to date LLVM

As at all times, we’ve up to date LLVM and all of its elements (Clang, lld, libc++, and many others) which incorporates many enhancements.

The toolchain has been up to date to r365631 (the grasp department as of 10 July 2019). This contains fixes for fairly a couple of bugs within the earlier launch, maybe most significantly LLD now not hangs when utilizing multithreaded linking on Home windows. OpenMP is now accessible as a dynamic library (and that is the brand new default conduct, so hyperlink with -static-openmp if you wish to keep on with the static runtime).

A handful of driver enhancements have been made to cut back the quantity of compiler configuration required by every construct system as properly. Construct system homeowners ought to examine the up to date Construct System Maintainers information.

libc++ has been up to date to r369764.

Fortify

Fortify is now enabled by default when utilizing ndk-build or the CMake toolchain file (this contains ExternalNativeBuild customers). Fortify permits further checks in the usual library that may assist catch bugs sooner and mitigate safety points. For instance, with out fortify the next code compiles high quality:

const char src[] = “this string is just too lengthy”;
char dst[10];
strcpy(dst, src);

With fortify, the buffer overflow is identified at compile-time:

check.cpp:10:18: error: ‘strcpy’ referred to as with string greater than buffer
strcpy(dst, src);
^

It isn’t at all times potential for the compiler to detect this concern at compile-time. In these instances, a run-time examine might be used as a substitute that may trigger this system to abort somewhat than proceed unsafely.

When you’re utilizing a construct system apart from ndk-build or CMake by way of the NDK’s toolchain file, this can not be enabled by default. To allow, merely outline _FORTIFY_SOURCE=2. Essentially the most dependable method to do that is by including -D_FORTIFY_SOURCE=2 to your compiler flags.

Clang may statically detect a few of these points through the use of -Wfortify-source (additionally new in r21). That is on by default, nevertheless it’s really helpful to implement fixing points with -Werror=fortify-source. Use this along with the C library options, not as a substitute of, because the warnings don’t cowl the identical instances because the C library extension, nor can it add run-time checks.

Word that as a result of run-time assist is required for fortify and the function was progressively added to Android over time, the precise set of APIs protected by fortify is determined by your minSdkVersion. Fortify is an enchancment, however it isn’t a alternative for good exams, ASan, and writing secure code.

See FORTIFY in Android for an in-depth clarification of fortify.

Different updates

64-bit requirement

Since August 2019, all present and new apps at the moment are required to assist 64-bit earlier than they are often launched to Google Play; there’s an extension for a restricted set of apps. For extra data and assistance on including assist for 64-bit, see our information.

Neon by default

Arm code is now constructed with Neon by default. In a earlier launch we enabled it conditionally primarily based on minSdkVersion, however given the very small variety of units that don’t assist Neon we now allow it unconditionally. This gives improved efficiency on all 32-bit Arm units (64-bit Arm at all times had this, and it doesn’t have an effect on Intel ABIs).

As earlier than, this conduct will be disabled for apps that have to proceed supporting units with out Neon. Alternatively, these units will be blacklisted within the Play Console. See https://developer.android.com/ndk/guides/cpu-arm-neon for extra data.

Up Subsequent

Take a look at our roadmap to see what we’re engaged on subsequent. The subsequent few massive issues arising are bundle administration and higher CMake integration.

asubhan
wordpress autoblog
amazon autoblog
affiliate autoblog
wordpress web site
web site improvement

Related posts

Mix: Asynchronous Programming with Swift – Final Day for Low cost! [FREE]

admin

New! Android Kotlin codelab programs are right here

admin

Supporting Google Play builders relating to native market withholding tax rules

admin

Leave a Comment