Changing the default compiler back from Intel C++ Compiler for Android to GCC for x86 targets

Reference number: DPD200248916

Product versions:

  • Intel® Integrated Native Developer Experience (Intel® INDE) for Android*
  • Intel® System Studio for Android*

Problem description:

After installation of Intel® Integrated Native Developer Experience (Intel® INDE) or Intel® System Studio for Android* platform, the NDK build system will choose the Intel compiler as default compiler for x86 targets. This is due to the way the NDK build system works. By setting the V=1 option you can check which compiler is actually used for compilation.

%NDK_DIR%\ndk-build V=1 -B APP_ABI=x86

C:\Intel\INDE\icc_android_15.0.0.009/bin/ia32/icc.exe -Wl,--as-needed -MMD -MP -MF ./obj/local/x86/objs-debug/hello-jni/hello-jni.o.d -ffunction-sections -m32 -O2 -g -DNDEBUG -fomit-frame-pointer -fstrict-aliasing -finline-limit=300 -O0 -UNDEBUG -fno-omit-frame-pointer -fno-strict-aliasing -Ijni -DANDROID -Wa,--noexecstack -Wformat -Werror=format-security......



Choose one of the options below to use the GCC compiler instead of the Intel compiler. (using NDK r10b, android-ndk32-r10b-windows-x86_64 as an example below, it should work for other versions of NDK similarly.)

  1. Specify the toolchain explicitly like below:
    %NDK_DIR%\ndk-build V=1 -B NDK_TOOLCHAIN=x86-4.9 APP_ABI=x86
    The toolchain x86-4.9 selects the GCC compiler version 4.9 which is the default for the NDK r10b. 

    If you want to create a FAT APK file using GCC as compiler for x86 targets use the following command sequence:
    %NDK_DIR%\ndk-build V=1 -B NDK_TOOLCHAIN=x86-4.8 APP_ABI=x86
    %NDK_DIR%\ndk-build V=1 -B APP_ABI="armeabi armeabi-v7a mips" NDK_APP.local.cleaned_binaries=true
    The option NDK_APP.local.cleaned_binaries=true is an internal NDK option to prevent the libs directory to get cleaned up. 
  2. Making GCC the default compiler as it was before the installation of the Intel® C++ Compiler for Android requires to change the make files of the NDK build system.

    The default compiler is selected by the file '%NDK_DIR%/build/core/'. Open this file in a text editor of your choice and search for the term "ifndef NDK_TOOLCHAIN". For NDK Version r10b this term can be found on line number 29. 
    		ifndef NDK_TOOLCHAIN
    			    TARGET_TOOLCHAIN_LIST := $(strip $(sort $(NDK_ABI.$(TARGET_ARCH_ABI).toolchains)))
    		    # Filter out the Clang toolchain, so that we can keep GCC as the default
    			    # toolchain.
    			    $(foreach _ver,$(LLVM_VERSION_LIST), 
    			        $(eval TARGET_TOOLCHAIN_LIST := 
    			            $(filter-out %-clang$(_ver),$(TARGET_TOOLCHAIN_LIST))))
    		    ifeq (,$(findstring 64,$(TARGET_ARCH_ABI)))
    			      # Filter out 4.7, 4.8 and 4.9 which are newer than the defaultat this moment
    			      __filtered_toolchain_list := $(filter-out %4.7 %4.8 %4.8l %4.9 %4.9l,$(TARGET_TOOLCHAIN_LIST))
    			      ifdef __filtered_toolchain_list
    			          TARGET_TOOLCHAIN_LIST := $(__filtered_toolchain_list)
    			      # Filter out 4.6, 4.7 and 4.8 which don't have good 64-bit support in all supported arch
    			      TARGET_TOOLCHAIN_LIST := $(filter-out %4.6 %4.7 %4.8 %4.8l,$(TARGET_TOOLCHAIN_LIST))

    You need to add the following two lines directly after the section you see above to filter out ICC while the NDK build system determines the default compiler:
    # Filter out x86-icc so that is will not be default compiler
    TARGET_TOOLCHAIN_LIST := $(filter-out x86-icc%,$(TARGET_TOOLCHAIN_LIST))
For more complete information about compiler optimizations, see our Optimization Notice.