Main Content

Create Polyspace Projects from Build Systems That Use Unsupported Compilers

Issue

Your compiler is not supported for automatic project creation from build commands.

Cause

For automatic project creation from your build system, your compiler configuration must be available to Polyspace®. Polyspace provides a compiler configuration file only for certain compilers.

For information on which compilers are supported, see Requirements for Project Creation from Build Systems.

Solution

To enable automatic project creation for an unsupported compiler, you can write your own compiler configuration file.

  1. Copy one of the existing configuration files from polyspaceroot\polyspace\configure\compiler_configuration\. Select the configuration that most closely corresponds to your compiler using the mapping between the configuration files and compiler names.

  2. Save the file as my_compiler.xml. my_compiler can be a name that helps you identify the file.

    To edit the file, save it outside the installation folder. After you have finished editing, you must copy the file back to polyspaceroot\polyspace\configure\compiler_configuration\.

  3. Edit the contents of the file to represent your compiler. Replace the entries between the XML elements with appropriate content.

  4. After saving the edited XML file to polyspaceroot\polyspace\configure\compiler_configuration\, create a project automatically using your build command.

    If you see errors, for instance, compilation errors, contact MathWorks® Technical Support. After tracing your build command, the software compiles certain files using the compiler specifications detected from your configuration file and build command. Compilation errors might indicate issues in the configuration file.

    Tip

    To quickly see if your compiler configuration file works, run the automatic project setup on a sample build that does not take much time to complete. After you have set up a project with your compiler configuration file, you can use this file for larger builds.

Elements of Compiler Configuration File

The following table lists the XML elements in the compiler configuration file file with a description of what the content within the element represents.

XML ElementContent DescriptionContent Example for GNU® C Compiler
<compiler_names><name> ... </name><compiler_names>

Name of the compiler executable. This executable transforms your .c files into object files. You can add several binary names, each in a separate <name>...</name> element. The software checks for each of the provided names and uses the compiler name for which it finds a match.

You must not specify the linker binary inside the <name>...</name> elements.

If the name that you specify is present in an existing compiler configuration file, an error occurs. To avoid the error, use the additional option -compiler-config my_compiler.xml when tracing the build so that the software explicitly uses your compiler configuration file.

  • gcc

  • gpp

<include_options><opt> ... </opt></include_options>

The option that you use with your compiler to specify include folders.

To specify options where the argument immediately follows the option, use an isPrefix attribute for opt and set it to true.

-I
<system_include_options><opt> ... </opt></system_include_options>

The option that you use with your compiler to specify system headers.

To specify options where the argument immediately follows the option, use an isPrefix attribute for opt and set it to true.

-isystem
<preinclude_options><opt> ... </opt></preinclude_options>

The option that you use with your compiler to force inclusion of a file in the compiled object.

To specify options where the argument immediately follows the option, use an isPrefix attribute for opt and set it to true.

-include
<define_options><opt> ... </opt></define_options>

The option that you use with your compiler to predefine a macro.

To specify options where the argument immediately follows the option, use an isPrefix attribute for opt and set it to true.

-D
<undefine_options><opt> ... </opt></undefine_options>

The option that you use with your compiler to undo previous definitions of a macro.

To specify options where the argument immediately follows the option, use an isPrefix attribute for opt and set it to true.

-U
<semantic_options><opt> ... </opt></semantic_options>

The options that you use to modify the compiler behavior. These options specify the language settings to which the code must conform.

You can use the isPrefix attribute to specify multiple options that have the same prefix and the numArgs attribute to specify options with multiple arguments. For instance:

  • Instead of

    <opt>-m32</opt>
    <opt>-m64</opt>
    
    You can write <opt isPrefix="true">-m</opt>.

  • Instead of

    <opt>-std=c90</opt>
    <opt>-std=c99</opt>
    
    You can write <opt numArgs="1">-std</opt>. If your makefile uses -std c90 instead of -std=c90, this notation also supports that usage.

  • -ansi

  • -std=C90

  • -std=c++11

  • -funsigned-char

<compiler> ... </compiler>

The Polyspace compiler option that corresponds to or closely matches your compiler. The content of this element directly translates to the option Compiler in your Polyspace project or options file.

For the complete list of compilers available, see Compiler (-compiler).

gnu4.7
<compile_options_list><opt> ... </opt></compile_options_list>The options that you use to compile source files without linking.-c
<preprocess_options_list><opt> ... </opt></preprocess_options_list>

The options that specify how your compiler generates a preprocessed file.

You can use the macro $(OUTPUT_FILE) if your compiler does not allow sending the preprocessed file to the standard output. Instead it defines the preprocessed file internally.

-E

For an example of the $(OUTPUT_FILE) macro, see the existing compiler configuration file ti_c6000.xml.

<preprocessed_output_file> ... </preprocessed_output_file>

The name of file where the preprocessed output is stored.

You can use the following macros when the name of the preprocessed output file is adapted from the source file:

  • $(SOURCE_FILE): Source file name

  • $(SOURCE_FILE_EXT): Source file extension

  • $(SOURCE_FILE_NO_EXT): Source file name without extension

For instance, use $(SOURCE_FILE_NO_EXT).pre when the preprocessor file name has the same name as the source file, but with extension .pre.

For an example of this element, see the existing compiler configuration file cosmic.xml.

<src_extensions><ext> ... </ext></src_extensions>The file extensions for source files.
  • c

  • cpp

  • c++

<obj_extensions><ext> ... </ext></obj_extensions>The file extensions for object files.o
<precompiled_header_extensions> ... </precompiled_header_extensions>The file extensions for precompiled headers (if available).gch
<polyspace_extra_options_list>
   <opt> ... </opt>
   <opt> ... </opt>
</polyspace_extra_options_list>

Additional options that are used for the subsequent analysis.

For instance, to avoid compilation errors in the subsequent analysis due to non-ANSI® extension keywords, enter -D keyword=value, for example:

<polyspace_extra_options_list> 
    <opt>-D MACRO1</opt> 
    <opt>-D MACRO2=VALUE</opt> 
</polyspace_extra_options_list> 

For more information, see Preprocessor definitions (-D).

 

Mapping Between Existing Configuration Files and Compiler Names

Select the configuration file in polyspaceroot\polyspace\configure\compiler_configuration\ that most closely resembles the configuration of your compiler. Use the following table to map compilers to their configuration files.

Compiler NameVendorXML File
ARM® ARM Keilarmcc.xml
armclang.xml
Visual C++® Microsoft® cl.xml
ClangNot applicableclang.xml
CodeWarrior® NXPcw_ppc.xml
cw_s12z.xml
cx6808Cosmiccx6808.xml
cosmic.xml
Diab Wind River® diab.xml
gccNot applicablegcc.xml
Green Hills® Green Hills Softwareghs_arm.xml
ghs_arm64.xml
ghs_i386.xml
ghs_ppc.xml
ghs_rh850.xml
ghs_tricore.xml
IAR Embedded WorkbenchIARiar.xml
iar-arm.xml
iar-avr.xml
iar-msp430.xml
iar-rh850.xml
iar-riscv.xml
iar-rl78.xml
Renesas®Renesasrenesas-rh850.xml
renesas-rl78.xml
renesas-rx.xml
renesas-sh.xml
TASKING® Altium® tasking.xml
tasking-166.xml
tasking-850.xml
tasking-arm.xml
Tiny CNot applicabletcc.xml
TM320 and its derivatives Texas Instruments® ti_arm.xml
ti_c28x.xml
ti_c6000.xml
ti_msp430.xml
xc8 (PIC)Microchipmicrochip.xml