Main Content

Resolve Error: No Compilation Unit Detected in Your Build

Issue

You can automatically create a Polyspace® project or options file by running polyspace-configure on your build command at the command line or in the Polyspace user interface. polyspace-configure executes your build command, tracks the processes executed, extracts the compiler command invocations from the tracked processes, and determines source files to add to a Polyspace project. If your compiler command does not execute during the build or cannot be found, you might see this error:

No compilation unit detected in your build.
The error indicates that polyspace-configure could not find source files to add to a Polyspace project or options file.

Possible Solutions

Check for Incremental Build

Most build systems perform an incremental build by default. The build commands rebuild only the sources that changed since the last rebuild. For instance, if you build your sources by using make or its equivalent, the command rebuilds only those targets in the makefile that are out-of-date. If you run polyspace-configure on a build command and none of your sources have changed since the last rebuild, your compiler is not invoked and you see the preceding error. Even if some of the sources have changed, your compiler might rebuild only those sources, leaving your Polyspace project incomplete.

To avoid the error, when running polyspace-configure, perform a full or clean build of your sources. For instance, when building by using make, you can use the flag -B or --always-make to rebuild all targets in the makefile.

Check for Compiler Caching

Using a compiler cache is equivalent to performing an incremental build. Compiler caches speed up compilation by caching results of previous compilations. If the same compilation is repeated, the cached results are used instead of a fresh compilation. In this case, polyspace-configure cannot detect a compilation because the actual compiler commands are not invoked.

To work around the error, disable any compiler cache that you might be using just before running polyspace-configure on your build command. You can reenable the caching immediately after running polyspace-configure. For instance, if you use Ccache, you can disable the caching on the current shell by entering:

export CCACHE_DISABLE=1

Check for Antivirus Software

The polyspace-configure command works by tracking the processes executed by your build command. Certain antivirus software can block this tracking. polyspace-configure keeps a known list of antivirus software that block tracking and shows a warning if any of the software is detected. You might be using an antivirus software outside this known list and not see the warning but see a later error instead.

To avoid the issue, temporarily disable your antivirus software when running polyspace-configure. Some antivirus software allow you to specify a list of processes that must not be blocked. You might be able to work around the issue by specifying Polyspace processes in your allowlist. For details, see Fix Errors or Slow Polyspace Runs from Disk Defragmentation and Anti-virus Software.

Check for Unsupported Compilers

The polyspace-configure command supports the same compilers as Polyspace. Check if your compiler is supported in Compiler (-compiler). For each supported compiler, polyspace-configure can recognize a known set of compiler invocation commands. If your compiler is not supported or is supported but uses an invocation command outside this known set, polyspace-configure fails to recognize the compiler invocation and produces the preceding error.

If your compiler is supported but uses a nonstandard invocation command, or is closely related to a supported compiler, you might be able to extend support to your compiler command. See Create Polyspace Projects from Build Systems That Use Unsupported Compilers. In all other cases, contact MathWorks Technical Support. See Contact Technical Support About Issues with Running Polyspace.

Check for Source Exclusions

You can use the option -include-sources or -exclude-sources with the polyspace-configure command to include or exclude certain sources from the generated Polyspace project or options file. If you use these options, make sure to check their arguments and ensure that you have not accidentally excluded more source files than you intend.

See also Select Files for Polyspace Analysis Using Pattern Matching.

See Also

Related Topics