Sonar Scanner is failing using Meson

I use sonar scanner cli v4.7.0 which is failing with the following message
“The Compilation Database JSON file was found but 0 C/C++/Objective-C files were analyzed.”

I am using Meson build system to compile my project, which produces the Compilation Database JSON
I give that to the scanner and yet it does not able to analyze any of the project C source files.

I would be glad if anyone could help me solve this problem, if more information is needed please let me know.

Hello @itaymov,

Could you please share with us the compilation database that you are producing, as well as the command-line you are using to run the scanner?

If you think it contains private data, let us know, and we’ll send you a message to upload it privately.

Hi @JolyLoic ,

Thanks for your reply, I would like to upload the data privately.

Thank you for this data. I would also need the log of the scanner, preferably with debug logs enabled. You can send them through the same channel.

Thanks!

Thanks for your help, I attached the log file here.
sonarscan.log (1.4 MB)

Hi @itaymov,

Your log file contained interesting information:

08:56:32.457 DEBUG: Probing compiler: [ccache, /opt/toolchains/Intel-Puma-Toolchain_03/usr/bin/armeb-buildroot-linux-uclibcgnueabi-gcc, -x, c, -mthumb, -v, -dM, -E, -]
08:56:32.480 DEBUG: stdout:

08:56:32.480 DEBUG: stderr:
execv: No such file or directory

08:56:32.481 WARN: Invalid probe found, skip analysis of files: [/home/itay/dev/SamDaemon/ninja-puma6-86nOSp/../compat.c]
The compiler probe 'stdout' is expected to contain at least one '#define' directive:

Once we read data from the compilation database, we try to probe the compiler you use to get additional configuration from it, and this is the step that is failing for you.

There could be different reasons for that, but I think the most probable is that you have the same issue that is described in this other post: Even if you have the full path to the compiler, you only have a relative path to ccache.

Since ccache is just an extra layer which is not useful here, could you please try to preprocess you compilation database so that lines like:

"command": "ccache /opt/toolchains/Intel-Puma-Toolchain_03/usr/bin/armeb-buildroot-linux-uclibcgnueabi-gcc -Idc@exe -I. -I.. -I../include.....

Are replace by:

"command": "/opt/toolchains/Intel-Puma-Toolchain_03/usr/bin/armeb-buildroot-linux-uclibcgnueabi-gcc -Idc@exe -I. -I.. -I../include

(an alternative would be to put the full path to ccache on every line)

Let me know if this works for you!

Since this situation is not really user friendly, I created a ticket to try and improve it.

Thanks very much for your help,

it worked for me.