User Guide

  • XX.XX
  • 04/09/2020
  • Public Content

Building Yocto* Project Images and Applications from the Command Line

Intel® System Studio provides an integration layer and several recipes to integrate with the Yocto Project development environment. For more information, see https://software.intel.com/en-us/articles/using-intel-system-studio-with-the-yocto-project.

Using ICC in the Yocto Image Build Environment as a Secondary Compiler

When you have used the integration layer to integrate Intel® System Studio, you can build a Yocto image using the GNU* Compiler Collection* (GCC*) as the primary compiler, and also use the Intel® C++ Compiler as a secondary compiler. For example, when building the platform image with GCC, you can include an application, built using the Intel® C++ Compiler, as part of the image.
To enable the Intel® C++ Compiler to build a specific package, add the following line in the package recipe .bb file:
TOOLCHAIN_pn-${PN} = "icc"
The Intel® C++ Compiler is now invoked automatically when you use this recipe .bb file to build this package.

App Development: When the Yocto SDK is Built with ICC Environment Scripts

When you have used the integration layer to integrate Intel® System Studio when you build the SDK, the Intel® C++ Compiler build environment script file is automatically generated in the same folder in which the default GCC environment scripts are located.
To set up the Intel® C++ Compiler build environment and use the Intel® C++ Compiler for building, source the ICC environment script. The ICC environment script has the same name as the file for the GCC but with the extension
-icc
. Sourcing the script overwrites the environment variables CC, CXX, AR and LD. For example, on a Linux system:
source /opt/poky/2.1/environment-setup-i586-poky-linux-icc
Check the content in
environment-setup-i586-wrs-icc
and update the compiler options if necessary for your compilation.

App Development: When the Yocto SDK is Not Built with ICC Environment Scripts

Use the
--sysroot
option to specify the target root directory of headers and libraries. For example, if the headers and libraries are normally located in
/usr/include
and
/usr/lib
respectively,
--sysroot
=/mydir
causes the compiler to search in
/mydir/usr/include
and
/mydir/usr/lib
for the headers and libraries.
Use the
-gnu-prefix
option to specify a string that prepends the name of the GNU tools called from the Intel® C++ Compiler. The value depends on the GNU toolchain used for a particular operating system. For example, for the Yocto Project v2.1, the prefix value is
i586-poky-linux-
. Append a hyphen to the prefix only if the toolchain prefix ends with a hyphen.
To adapt the Intel® C++ Compiler to the Yocto Project v2.1 build environment:
  1. Make a copy of the GCC environment setup file and rename it to
    environment-setup-i586-poky-linux-icc
    .
    cp /opt/poky/2.1/environment-setup-i586-poky-linux /opt/poky/2.1/environment-setup-i586-poky-linux-icc
  2. Open the environment setup file,
    /opt/poky/2.1/environment-setup-i586-poky-linux-icc
    , and locate the following build settings:
    export CC="i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.1/sysroots/i586-poky-linux" export CXX="i586-poky-linux-g++ -m32 -march=i586 --sysroot=/opt/poky/2.1/sysroots/i586-poky-linux" export LD="i586-poky-linux-ld --sysroot=/opt/poky/2.1/sysroots/i586-poky-linux" export AR=i586-poky-linux-ar
  3. Change them to:
    export CC="icc -gnu-prefix=i586-poky-linux- -m32 -march=i586 --sysroot=/opt/poky/2.1/sysroots/i586-poky-linux" export CXX="icpc -gnu-prefix=i586-poky-linux- -m32 -march=i586 --sysroot=/opt/poky/2.1/sysroots/i586-poky-linux" export LD="xild -qgnu-prefix=i586-poky-linux- --sysroot=/opt/poky/2.1/sysroots/i586-poky-linux" export AR="xiar -qgnu-prefix=i586-poky-linux-"
  4. Save the file.
To build an application called
my_source_file.c
, on a Linux OS host for the Yocto Project v2.1 target, use the following commands:
source /opt/intel/system_studio_yyyy.x.y/bin/compilervars.sh ia32 source /opt/poky/2.1/environment-setup-i586-poky-linux-icc $CC my_source_file.c
You can also use
icc
directly from the command line with the
–gnu-prefix
and
--sysroot
compiler options, as follows:
icc –gnu-prefix=i586-poky-linux- --sysroot=/opt/poky/2.1/sysroots/i586-poky-linux my_source_file.c
Following successful compilation, an executable named
a.out
is created in the current directory. Copy
a.out
onto the target machine running Yocto Project (v2.1 in this example), and verify that
a.out
runs on the target machine.
For information about the
gnu-prefix
and
sysroot
compiler options, see the Intel® C++ Compiler 19.1 Developer Guide and Reference.

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