Building an Android AOSP module with the Intel® C++ Compiler for Android*

Published:10/02/2014   Last Updated:10/02/2014

This article describes how to build modules with the Intel C++ Compiler for Android* (ICC) and integrate them into an Android Open Source Project (AOSP) build. A module is typically a shared library or application that will be part of the Android image on the device. Examples are audio/video codecs and multimedia applications.

Building a separate module outside the AOSP build process

Building an Android module with the Intel® C++ Compiler for Android* is similar to building it with the GCC toolchain. Please follow the Getting Started guide to compile the module using the NDK build system or a standalone toolchain.

Copying the prebuilt module into the AOSP image during the build process

Once the module is compiled and linked it can be integrated into the AOSP build process as prebuild library.It will be included into the Android system image.

Create an Android.mk file below the root of the AOSP tree with the following content:

include $(CLEAR_VARS) LOCAL_MODULE := <library_name> LOCAL_MODULE_SUFFIX:=.so LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := SHARED_LIBRARIES LOCAL_SRC_FILES := <library_file_name> include $(BUILD_PREBUILT)

The two placeholders <library_name> and <library_file_name> must be filled with the library file name on the host and on the target. Usually they are the same.

Building a module as part of the AOSP build process

Intel provided versions of the AOSP source tree should be already prepared to use ICC as part of the build process. You can determine if you have an ICC enabled source tree by checking if the file <AOSP_ROOT>build/core/icc_config.mk exists.

Configuration of the build environment

Before using the compiler you need to setup the path to the compiler in the file <AOSP_ROOT>build/core/icc_config.mk. Specify the path to ICC by changing the variable TARGET_ICC_TOOLS_PREFIX. For example:

TARGET_ICC_TOOLS_PREFIX := /opt/intel/cc_android_14.0.1.017/bin/

There are a couple of configuration variables that are useful. All of the mentioned variables can be also specified directly on command line as well.

  • ICC_MODULES
    Forces the specified modules to be compiled with ICC regardless of the default compiler.
  • GCC_MODULES
    Forces the specified modules to be compiled with GCC regardless of the default compiler.
  • ICC_IPO_MODULES
    Specifies modules that should be compiled with Interprocedural Optimization (IPO) if the module is compiled with ICC
  • ICC_FREESTANDUNG_MODULES
    Specifies modules that are not linked against the standard libraries. More details can be found in the documentation. This option should not be changed.

Building a module

If the module which should be compiled with ICC is already configured in the ICC_MODULES variable there is nothing special to do. Just invoke the compilation as usual using:



	source build/envsetup.sh

	lunch

	make flashfiles

	

It's also possible to specify the module which should be compiled with ICC directly on the command line:



	source build/envsetup.sh

	lunch

	make ICC_MODULES=libskia ICC_STATIC_MODULES=libskia ICC_IPO_MODULES=libskia flashfiles

	

Troubleshooting

For compilation of modules which are part of AOSP there might be additional patches required. Please contact your Intel representative if you meet any issues.

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804