Compilation toolchain (Testing)
Specify the compiler that you use to build your source code and tests for dynamic testing
Description
This option applies to C/C++ testing with Polyspace®
Test™. To specify a compilation toolchain for static analysis, use the option Compilation toolchain (Static Analysis) (Polyspace Bug Finder).
Specify the compiler that you use to build your source code and tests for dynamic testing. Polyspace invokes your specified compiler on your source code and tests to create a test executable.
Set Option
Set the option using one of these methods:
Polyspace Platform user interface (desktop products only): In your project configuration, on the Build tab, select the Target & Compiler node and then select a value for this option.
Command line : Use the option
-toolchain. See Command-Line Information.
Why Use This Option
When you build a Polyspace Platform project, the build happens in two steps. Each step uses a separate compiler specification.
The source code and tests are compiled into a test executable. You can compile the code and tests for on-host or on-target execution. The compiler being used for this step will be henceforth referred to as the user compiler. You specify the user compiler through this option.
A master executable is created from internally generated code to dispatch instructions to the test executable. This compilation step always happens on the host. The compiler being used for this step will be henceforth referred to as the host compiler. You specify the host compiler in your settings.
You can specify the same compiler as user compiler and host compiler. For more information, see the Settings section below or see Specify C/C++ Compilers for Testing in Polyspace Platform User Interface.
Settings
Default: Detect automatically
Detect automaticallyPolyspace uses the host compiler that you specify in your settings as the user compiler.
If you have a supported host compiler installed, the compiler is automatically detected when you open the Polyspace Platform user interface and set in your settings. When you create a new project in the user interface, this compiler is also selected as the user compiler for parsing source code and building the project. To change the host compiler:
On the Polyspace Platform toolstrip, select Settings.
On the Testing and Profiling tab, select a compiler for the option C/C++ Host Compiler.
If you do not see a compiler in this dropdown, it indicates that a supported compiler was not detected. See Supported Host Compilers for installing and configuring a supported host compiler.
Microsoft Visual C++ 2019 v16.0 – CMake/Ninja (64-bit Windows),MinGW64 – CMake/Ninja (64-bit Windows),GNU gcc/g++ – CMake/gmake (64-bit Linux), ...Instead of using the same compiler as the host and user compiler using
Detect automatically, you can explicitly select a user compiler from the list of installed compilers.By default, this list shows installed compilers that are supported for use as host compilers. You can add more compilers to this list using one of these methods:
Create and register a target using a custom target registration file. The target registration file defines the toolchain that you want to use. For more information on:
How to register a target using a custom target registration file, see Run C/C++ Tests on Target in Polyspace Platform User Interface.
How to define a toolchain in a custom target registration file, see:
Create Target Registration Packages for C/C++ Test Execution on Targets for a brief overview of a custom target registration file.
Set Up PIL Connectivity by Using Target Framework (Embedded Coder) for the full description of a custom target registration file.
target.create(Embedded Coder) to get started with creating a target.target.Toolchain(Embedded Coder) to add a toolchain description to the custom target registration file. A compiler can be specified as part of the toolchain description.
Create a toolchain in the Polyspace Platform user interface by specifying build tool paths, directives, and other information in an app. For more information, see Toolchain.
Note that you cannot create a full execution target in the toolchain app. Using this app, you can only create a toolchain to associate with host execution (that is, with
Host Computeras board and processor), or link it to a board that you have registered separately using a target registration file.
Dependencies
The list of available toolchains for this option depends on your selection for the option Target board name (Testing):
If you select
Host Computeras your target board, you only see toolchains associated with the host compilers that you have installed. For instance, if your host compiler is GCC on Linux®, you see these toolchains:GNU gcc/g++ | CMake/gmake (64-bit Linux)GNU gcc/g++ | CMake/Ninja (64-bit Linux)GNU gcc/g++ | gmake (64-bit Linux)
If you register a custom target where you have associated a host processor with a toolchain, this toolchain also appears in the list. A host processor includes the processor
Host Computerand someIntelandAMDprocessors. For more information, seeProcessor.If you set your target board to
Noneyou see all toolchains: ones associated with the installed host compilers and ones that you have specified in your target registration files.If you select a specific target board, you see all toolchains. However, the toolchains that are explicitly associated with the target board in the target registration file appear first and are shown separated from the remaining toolchains.
Tips
Sometimes, you might want to append compiler flags, build flags, and other such flags instead of the default ones, or ones defined in your target registration file. This allows you to emulate your command-line build by adding flags that you normally use at the command line. Instead of creating a new target with the additional flags and registering the new target, you can add these flags in your project configuration.
To add custom toolchain flags:
Open your project configuration.
On the Build tab, select your toolchain in the dropdown for Compilation toolchain (Testing). Click
next to the option.Select Enable toolchain customization. You can see the default command-line flags being used. Modify the flags as necessary to emulate your command-line build.

Debugging of tests on host requires that your host compiler and user compiler are the same. For more information, see Compilers and Debugging.
Command-Line Information
Parameter: -toolchain |
| Default: N/A |
Example:
polyspace-test -build -project |
The option -toolchain overrides the existing compilation toolchain defined in the project myProject.psprjx. If you do not specify this option, Polyspace
Test uses the compilation toolchain specified in the project.