Contenu principal

Configure Sources and Build Options in Project for Polyspace Analysis and Testing

R2026b

Before running static analysis or tests with Polyspace Platform projects, you must configure the build options to accurately represent your build environment — compiler, target processor, preprocessor macros, and include paths. You can set sources and build options in one of the following ways:

  • Configure sources and build options using your build system — This is a fully automated approach, and can be used directly in continuous integration systems. You do not need to know the inner workings of your build system. All you need is a working build command (or a compilation database if your build system generates one).

  • Configure sources and build options manually — Specify your sources, includes, and build options manually in a project or options file. You can find Polyspace® options that are equivalent to your compiler options using a semi-automated approach.

Create Project or Options File from Compilation Database or Build Command

The recommended approach is to use polyspace-configure to automatically extract source files, build options, and target configuration from your build system into a Polyspace Platform project or options file. You can provide your build information to polyspace-configure in two ways:

  • Using a compilation database (if your build system supports creation of a JSON compilation database).

  • Using a build command.

When possible, providing a compilation database is the recommended approach. Unlike the build command approach, which requires polyspace-configure to track processes and find the compiler invocations, the compilation database approach is faster and has fewer limitations because polyspace-configure simply reads compiler invocation commands from a file.

For information on how to invoke polyspace-configure in the Polyspace Platform user interface, see Create Polyspace Platform Project from Build Command in User Interface.

Create Project from Compilation Database

If your build system supports generation of a JSON compilation database (for instance, CMake with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON), you can pass it directly to polyspace-configure:

polyspace-configure -output-platform-project myProject -compilation-database compile_commands.json

The compilation database contains the exact compiler invocations used to build each source file. The polyspace-configure command reads these invocations and extracts the corresponding Polyspace options. The main limitation of this approach is that not all build systems support compilation database generation.

For an example, see Create Polyspace Platform Projects from CMake Builds.

Create Project from Build Command

If your build system does not support compilation database generation, you can run polyspace-configure on your build command directly. The command traces all processes spawned by the build, identifies compiler invocations among them, and extracts the corresponding Polyspace options.

polyspace-configure -output-platform-project myProject make -B <targetName>

Because this approach relies on tracking processes on the build machine, it has some limitations. For instance, antivirus software and firewalls can block process tracking, the build must run locally to completion, and distributed builds and compiler caches are not supported. For details, see Requirements for Polyspace Project Creation from Build Systems.

For examples, see:

Configure Build Options Manually

If you cannot use polyspace-configure with your full build command or compilation database, you must configure the build options manually. Unlike the automated approach where polyspace-configure uses your actual build to determine the correct options, manual configuration requires you to identify and map your compiler settings to Polyspace options yourself. Ensure that you verify your mapping carefully, as incorrect settings can lead to inaccurate analysis results.

You can still use polyspace-configure to assist with parts of this process, rather than doing the entire mapping manually. If you can determine the compile commands used in your build and deduce a common set of compile options used in the commands, you can invoke polyspace-configure on the compile command launched with those compile options, and find the equivalent Polyspace options.

Determine Polyspace Options from Single Compiler Invocation

Even if you cannot run polyspace-configure on your full build, you can still use it as a starting point to determine Polyspace options equivalent to a single compiler invocation.

To do this:

  1. Determine which compiler executable your build calls and the common set of compiler options used across your source files. You can typically find this information by examining the log output of your build system (some build systems require you to specify an option to print this log).

    See Compiler Executable Names for Common Compilers and Architectures for a list of common compiler executables and typical options.

  2. Run polyspace-configure on that compiler invocation with a single source file and the -no-sources option (so that no source files are included in the generated options file):

    polyspace-configure -no-sources -output-options-file psoptions.txt <compiler> <flags> <source-file>
    For example, if your build uses arm-none-eabi-gcc with hardware floating-point options, you can enter the following command:
    polyspace-configure -no-sources -output-options-file psoptions.txt arm-none-eabi-gcc -mfloat-abi=hard -mfpu=neon-fp-armv8 -c main.c

  3. From the resulting options file, use the -compiler, -custom-target, and the compiler implicit defines and includes (the -D and -I options) in your project configuration.

    For more information on the options, see:

If different source files in your project are compiled with different compiler options that materially affect target characteristics (for instance, different GCC -march flags that change type sizes), this approach might produce incorrect settings for some files. This is typically not the case — most projects use a common set of target-affecting flags across all files. However, for the most accurate results, running polyspace-configure on the full build remains the best approach; single-invocation is a fallback when the full build is not available.

Determine Polyspace Options from Documentation

If polyspace-configure does not support your compiler at all, you must determine the correct Polyspace options entirely from documentation. This is the most manual process. You must read both your compiler documentation and the Polyspace reference documentation to map your compiler settings to the corresponding options:

For more information on all build options, see Polyspace Bug Finder Options in Polyspace Platform User Interface.

Compiler Executable Names for Common Compilers and Architectures

The following table lists common cross-compiler executables and typical compiler options that affect target characteristics. If you are setting your build options manually, use this information to identify the compiler invocation for use with polyspace-configure, or as a starting point for manual configuration.

CompilerArchitectureCompiler executableCommon compiler options
GNU Arm Embedded Toolchain (GCC)ARM (32-bit)arm-none-eabi-gcc-mfloat-abi=hard -mfpu=neon-fp-armv8 -c
Arm Compiler (armclang)ARM (32-bit)armclang--target=arm-arm-none-eabi -march=armv8-a -c
Arm Compiler (armclang)ARM (64-bit / AArch64)armclang--target=aarch64-arm-none-eabi -march=armv8-a -c
TI ARM CGT ClangARM (32-bit)tiarmclang 
IAR Embedded WorkbenchARMiccarm-e
IAR Embedded WorkbenchRISC-Viccriscv--core=RV32MADXandesdsp -e
IAR Embedded WorkbenchRH850iccrh850-e
IAR Embedded WorkbenchRL78iccrl78-e
IAR Embedded WorkbenchAVRiccavr-e -v4
Hightec GCCTriCore (Infineon)tricore-gcc 
Hightec GCCMSP430gcc-msp430-none 
Wind River® DiabPowerPC 64-bitdcc-tPPCLP64FH:windiss
Renesas® CC-SHSuperHshc-cpu=sh4aldsp -dspc -lang=c
Renesas CC-RXRXccrx-isa=rxv2 -lang=c99
Renesas CC-RHRH850ccrh 
Renesas CC-RLRL78ccrl-cpu=S3
Texas Instruments® CGTARMarmcl--float_support=VFPv2 -mv6
Texas Instruments CGTC6000 (DSP)cl6x--silicon_version=6600
Texas Instruments CGTMSP430cl430--silicon_version=mspx
Texas Instruments CGTC2000 (C28x)cl2000-I <ti-cgt-c2000>/include/
CosmicS12Zcxs12z 
Microchip XC32PIC32 (MIPS)xc32-gcc-mprocessor=32MX795F512L
Microchip XC16PIC24 / dsPICxc16-gcc-mcpu=33FJ256GP710
Microchip XC8PIC10/12/16/18xc8--chip=16F1947 --std=c99
Cadence Tensilica XT-CLangXtensaxt-clang--xtensa-system=<config_path>
Microsoft® Visual C++®x86-64cl(run from VS Developer Command Prompt)
LLVM Clangx86-64 / ARM / AArch64clang / clang++--target=<triple>
Intel® C++ Compilerx86-64icc 

See Also

|