主要内容

Selecting Common Toolchain for Static Analysis and Testing

R2026b

In the Polyspace® Platform user interface, you specify two compilation toolchains in your project build configuration:

  • Compilation toolchain (Testing) (Polyspace Test) — The toolchain used for dynamic testing with Polyspace Test™.

  • Compilation toolchain for static analysis — The compiler used for static analysis with Polyspace Bug Finder™ or Polyspace Code Prover™. This option translates to the command-line option -compiler. For specialized cross-compilers where the compiler name is coupled with a processor name (for example, diab - arm), the selection translates to both -compiler and -target.

By default, the static analysis compiler is set to Same as testing toolchain. With this setting, the -compiler and -target values for static analysis are automatically determined from the testing toolchain that you select, so you configure your toolchain only once.

The following sections describe how these values are determined for each type of testing toolchain.

Host Toolchains

How the static analysis compiler is determined depends on the host toolchain family you specify:

  • If you select a host toolchain such as MinGW64 – CMake/Ninja (64-bit Windows) or GNU gcc/g++ – CMake/gmake (64-bit Linux), Polyspace runs a compiler detection step to determine the appropriate -compiler values based on the compiler characteristics defined in your toolchain.. No -target is needed. The target characteristics for static analysis are determined by the Processor option, which translates to the command-line option -custom-target.

    For example, if you select a MinGW-based host toolchain on Windows®, the static analysis runs the compiler detection step to determine the appropriate version of the gnu compiler.

  • If you select a Microsoft® Visual C++® host toolchain, the appropriate version of the visual compiler is selected without the need for a compiler detection step.

If you select Detect automatically for the testing toolchain, the toolchain used for testing is the same as the host toolchain specified in preferences. For more information, see Specify C/C++ Compilers for Testing in Polyspace Platform User Interface (Polyspace Test).

Template Toolchains

Template toolchains are predefined toolchains that correspond to compilers already known to Polyspace. For more information on template toolchains, see Configure Template Toolchains for Testing (Polyspace Test).

For standard template toolchains such as gnu, clang, and visual, the static analysis compiler (-compiler) is set directly from the toolchain name as long as the toolchain version is also specified. No -target is needed. As with host toolchains, the target characteristics are determined by the Processor option, which translates to the command-line option -custom-target. For example, if you select the gnu template toolchain for testing, the static analysis uses the corresponding gnu compiler.

For specialized cross-compiler template toolchains such as diab - arm or iar-ew - arm, both the static analysis compiler (-compiler) and target (-target) are derived from the toolchain name. For instance, if you select the diab - arm template toolchain, the static analysis uses -compiler diab with -target arm. The Processor option also generates a -custom-target value that determines type sizes, alignment, and endianness. The -target option selects compiler-specific predefined macros and language dialect only.

Custom Toolchains

If you select a custom toolchain that you registered using a target registration file, the static analysis compiler (-compiler) and target (-target) cannot be directly inferred from the toolchain name. In this case, Polyspace runs a compiler options detection process to determine the appropriate -compiler and -target values based on the compiler characteristics defined in your toolchain. For this detection to produce accurate results, your target registration file must fully describe the compiler, including any relevant compiler flags.

For instance, if your custom toolchain uses gcc -m32 versus gcc -m64, the compiler flag is present in your toolchain definition and is used during detection to deduce the correct target characteristics.

If the compiler detection step fails, the static analysis compiler (-compiler) value is set to generic.

See Also

(Polyspace Test) |

Topics