Issues setting up sonarlint on custom build solution

  • Operating system: Windows 10 (unable to build on linux)
  • SonarLint plugin version: v3.12.0
  • Programming language you’re coding in: C
  • Is connected mode used: Not yet, as sonarlint is not working currently, but will be in the future.


We are trying to setup sonarlint on our project which uses custom provided build process (based on armcc, tcc, armlink, fromelf and armar). Current solution does not generate a compilation database file and it appears, that armcc compiler is unable to create this database natively.

I have tried using 3rd party scripts, like compiledb and makefile tools extension in VScode but all of them generate only empty compile_commands.json file.

Is there any other way, how to setup sonarlint without using the compilation database or is there any other independent way to generate such database?

Sidenote - due to our project specifics we are unable to compile our solution on any other plaftorm, other than windows, thus we are unable to use all linux tools…

Thanks in advance,

Eimantas M

Hello @EimantasM,

Unfortunately, a compilation database is the only way.

Fortunately, generating a compilation database is easy.

If you exhausted the first and the second option in our doc, you are stuck with the third option: Generating Compilation Database Using a Custom Script.

Compilation databases are really simple, you only have to provide the command to build your file, the directory from which this command is executed, and the path to the file you are compiling.

You can take 3 approaches to do this.

Incremental and lightweight local approach

If your project mostly compiles the same way, you can start with a compilation database with one entry that you add manually and start from there. We have an algorithm behind the scene to deduce the compile command for files that don’t have entries in the compilation database based on available entries.
You just have to make sure that the provided entry is valid by executing the command from directory and making sure that the output is a successful compilation to file

After that, you can enable S2260 to detect the quality of the analysis as indicated by the doc and add more entries to your compilation database incrementally.

I would recommend this approach if you are looking for a local and quick solution.

build system based script

It is easy to generate a compilation database for one build system, but it is hard to generate it consistently across build systems. You can simply modify your build system to add an entry to the compilation database every time it calls the compiler.

This is recommended if your build system is customizable and extendable.

build-wrapper based script

if you already have build-wrapper.json for your project, you can write a quick script to transform it into a compilation database. build-wrapper.json is a superset of compile_commands.json. It should be easy to write a script by looking at your specific `build-wrapper.json and mapping it.

directory = cwd from build-wrapper.json
command = concatenated cmd from build-wrapper.json
file can be extracted from command with one entry for each compiled file.

Let me know if you have further questions,

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.