Intel C++ Compiler, a component of Intel System Studio, provides compatible sysroot support as gcc compiler. With the new features supported in the Intel C++ Compiler, we can use the option --sysroot and the option -gnu-prefix to cross compile the applications for embedded linux target.
--sysroot option:
This option specifies the root directory where headers and libraries are located. For example, if the headers and libraries are normally located in /usr/include and /usr/lib respectively, --sysroot=/mydir will cause the compiler to search in /mydir/usr/include and /mydir/usr/lib for the headers and libraries. For embedded target development, we can use --sysroot option to specify the target root directory of headers and libraries.
-gnu-prefix option:
This option specifies a string that prepends the name of gnu tools called from the compiler. The value depends on the gnu toolchain used for a particular operating system. For example, for Wind River* Linux 5.x, the prefix value will be i686-wrs-linux-gnu-. You must append a hyphen to prefix only if the toolchain prefix ends with a hyphen.
The developer can specify a short name or a pathname:
short name: -gnu-prefix=prefix In this case, the compiler calls prefix<gnu_utility> instead of <gnu_utility>. The utility with this name should be in the PATH environment variable.
pathname: -gnu-prefix=/directory_name/prefix In this case, the compiler calls /directory_name/prefix<gnu_utility>. The utility with this name will be invoked by its full pathname.
This option lets you specify a prefix that will be added to the names of gnu utilities called from the compiler. This option is available for Linux*-targeted compilers but the host may be either Windows* OS or Linux* OS.
By these two options, we can simply integrate the icc compiler with gcc compiler, and migrate the application build from gcc compiler to icc compiler. We don’t need to specify the path to sysroot and gnu toolchain through the environment variables which are supported by Intel C++ compiler 13.x release.
For example, to build applications on a Linux* OS host for the Yocto Project* 1.3 target:
If we use Intel C++ Compiler 13.x from Intel System Studio 2013, we need to export the YL_TOOLCHAIN and YL_SYSROOT environment variables to the right path and use option –platform=yl13 for the compilation.
export YL_TOOLCHAIN=/opt/poky/1.3/sysroots/i686-pokysdk-linux/usr/bin
export YL_SYSROOT=/opt/poky/1.3/sysroots/i586-poky-linux
icc -platform=yl13 my_source_file.c
Now with new features starting in the Intel C++ compiler 14.0 from Intel System Studio 2014, we can use the following command line for the same compilation:
icc –gnu-prefix=i586-poky-linux- --sysroot=/opt/poky/1.3/sysroots/i586-poky-linux my_source_file.c
In this case, icc will find the gnu binary utilities such as “i586-poky-linux-ld” from the PATH and perform the compilation with sysroot which is pointed to /opt/poky/1.3/sysroots/i586-poky-linux.
Here is an example to change the compiler from gcc to icc for Yocto Project 1.3 build using the option –gnu-prefix. Note that the --sysroot option is already enabled for gcc build. We only need to add the new option –gnu-prefix for icc build, and keep the other options the same.
In the file /opt/poky/1.3/environment-setup-i586-poky-linux, we can find the default GCC build settings:
export CC="i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/1.3/sysroots/i586-poky-linux"
export CXX="i586-poky-linux-g++ -m32 -march=i586 --sysroot=/opt/poky/1.3/sysroots/i586-poky-linux"
export LD="i586-poky-linux-ld --sysroot=/opt/poky/1.3/sysroots/i586-poky-linux"
export AR=i586-poky-linux-ar
change the above lines in the file environment-setup-i586-poky-linux
export CC="icc -gnu-prefix=i586-poky-linux- -m32 -march=i586 --sysroot=/opt/poky/1.3/sysroots/i586-poky-linux"
export CXX="icpc -gnu-prefix=i586-poky-linux- -m32 -march=i586 --sysroot=/opt/poky/1.3/sysroots/i586-poky-linux"
export LD="xild -qgnu-prefix=i586-poky-linux- --sysroot=/opt/poky/1.3/sysroots/i586-poky-linux"
export AR= “xiar -qgnu-prefix=i586-poky-linux-“
Now we are ready to use icc to build the applications for Yocto Project 1.3. The similar approach can be applied with the toolchain for WindRiver Linux target, or your customized cross build gnu toolchain. You may also refer to the article http://software.intel.com/en-us/articles/building-yocto-applications-using-intel-c-compiler to see details on how to use Intel C++ compiler to build Yocto applications.
Please note that starting with the Intel C++ compiler 14.0 release, we must use –gnu-prefix option together with –sysroot option, otherwise the result is undefined.
This article applies to:
Products: Intel(R) INDE; INTEL(R) System Studio
Host OS/platforms: Windows (IA-32, Intel(R) 64), Linux* (IA32, Intel(R) 64)
Target OS/platforms: Linux* (IA32, Intel(R) 64)