Scanner "probe" fails after switching from build-wrapper to compile_commands.json

SonarScanner 4.6.2.2472
SonarQube: Developer Edition Version 9.3 (build 51899)

C compiler: arm-none-eabi-gcc and arm-linux-gnueabihf-gcc

After few successful analyses using build-wrapper + scanner I decided to switch to compile_commands.json (so the incremental builds would also be nicely analyzed).

I have a correct compilation database - I’ve checked the commands and they do work - but scanner fails and log is full of following messages

2022-03-04 17:36:08.543  WARN: Invalid probe found, skip analysis of files: [/home/jenkins/XXXXX.c]
2022-03-04 17:36:08.543  The compiler probe 'stdout' is expected to contain at least one '#define' directive:
2022-03-04 17:36:08.543  
2022-03-04 17:36:08.543  WARN: Invalid probe found, skip analysis of files: [/home/jenkins/YYYYY.c]
2022-03-04 17:36:08.543  The compiler probe 'stdout' is expected to contain at least one '#define' directive:
2022-03-04 17:36:08.543  
2022-03-04 17:36:08.543  WARN: Invalid probe found, skip analysis of files: [/home/jenkins/AAAAA.c]
2022-03-04 17:36:08.543  The compiler probe 'stdout' is expected to contain at least one '#define' directive:

and so on.

I’ve only added -Dsonar.cfamily.compile-commands=compile_commands.json in place of -Dsonar.cfamily.build-wrapper-output=sonar-output and kept all other options unchanged.

Scanner seemed to work fine with build-wrapper - issues were detected, files scanned etc.
I can revert back to build-wrapper, but switching to compilation database would greatly increase team productivity.

Thanks for help!

Hi @hcorg ,

could you share the entire sonar-scanner output in debug mode? I can send you a private message if you prefer to share it privately.

Debug mode indeed provided some additional information:

[2022-03-08T12:02:34.000Z] 12:02:33.970 DEBUG: Probing compiler: [arm-none-eabi-gcc, -x, c, --std, c11, -mcpu=cortex-m7, -mfloat-abi=hard, -mfpu=fpv5-d16, -mthumb, -v, -dM, -E, -]
[2022-03-08T12:02:34.000Z] 12:02:33.975 DEBUG: stdout:
[2022-03-08T12:02:34.000Z] 
[2022-03-08T12:02:34.000Z] 12:02:33.975 DEBUG: stderr:
[2022-03-08T12:02:34.000Z] execv: No such file or directory

Which is still a little confusing, since arm-none-eabi-gcc should be in PATH… (double checked it by adding explicit call just beforre calling sonnar-scanner in the script)

seems that manually editing compile_commands.json to replace compiler name with complete path to the compiler helps… why sonar-scanner is not using PATH?

Hi @hcorg ,

indeed it is expected to have full path to compiler in compile_commands.json.

Tools like CMake usually put an absolute path to the compile_commands.json as you may have several toolchains.

Shall we consider the issue as solved?

Yes, ensuring absolute path for the compiler in compile_commands.json solves the problem.

I had compile commands captured and not generated, so they might be a little different than coming from CMake.

Thanks for the help!

1 Like

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