"build-wrapper-dump.json" file was found but 0 C/C++/Objective-C files were analyzed by scanner

Hi Team,

we have an open source project, Few of our builds are failing at sonar scanner step due to java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found but 0 C/C++/Objective-C files were analyzed. we are able to generate the reports and publish to sonar cloud for some of the repos with the same configuration.

Here is the Ci build :
https://app.circleci.com/pipelines/github/usdot-fhwa-stol/carma-velodyne-lidar-driver/434/workflows/431dc135-d799-4a97-a43e-4f0e2d504cfa/jobs/419

Github Repo : GitHub - usdot-fhwa-stol/carma-velodyne-lidar-driver at fix/Circleci_build

Please let me know if you need any other information, Thanks in advance!

Hi @SaikrishnaBairamoni,
Do you run build-wrapper from the same directory as sonar-scanner?
Can you, please, share the “build-wrapper-dump.json” file, as well as the “build-wrapper.log” that should be in the same directory as “build-wrapper-dump.json”?

Hi @necto,

I’m not able to see the build-wrapper-dump.json file, where can I find it?

Here is the build output file with build wrapper command we use :
build step.txt (361.6 KB)

Here is the sonar output :
sonar output.txt (48.0 KB)

Also if I use sonar.sources=. I’m getting this error
ERROR: File velodyne_lidar_driver_wrapper/CMakeLists.txt can’t be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files

The build-wrapper-dump.json should be produced by build-wrapper after the build command in the folder specified as --bw-output. According to your sonar-project.properties configuration:

sonar.cfamily.build-wrapper-output=/opt/carma/bw-output

It is in “/opt/carma/bw-output”. “build-wrapper.log” is stored in the same directory.
It is also mentioned in the analysis log:

INFO: Using build-wrapper output: /opt/carma/bw-output/build-wrapper-dump.json

Also if I use sonar.sources=. I’m getting this error
ERROR: File velodyne_lidar_driver_wrapper/CMakeLists.txt can’t be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files

this is a problem, and might be the cause of your analysis issue. In what context do you see this error message?

Hi @necto

Here are the build-wrapper-dump.json and log files, seems like they are empty.

build-wrapper.log.txt (30.8 KB)
build-wrapper-dump.json.txt (516 Bytes)

Hi @necto

Did you get a chance to see my logs files? Could you please help me with this issue. Thank you!

Regards,
Sai

Hi,

I know this is hard to hear (read) but please be patient. You’re interacting with one of the developers of these features and all our devs have a lot going on. And as a side note, tomorrow is a holiday in Geneva, so it may be a couple days more before he’s able to get back to you.

 
Ann

Sure, Thanks for letting me know. :+1:

Good Morning Team,

I would like to reach out to you for assistance as I not able to find out the root cause of the issue, Most of the our other repos are getting the reports which uses same base image scripts for sonar (carma-base/code_coverage at develop · usdot-fhwa-stol/carma-base · GitHub). I tried modifying the sonar properties but got the same errors. Could you please help me with this issue and let me know if you need any other information. Thank you!

Regards,
Sai.

Hi @SaikrishnaBairamoni
I apologize for the long delay. We are currently very busy making sure the upcoming LTS release of SQ is solid.

From the Build Wrapper JSON file you’ve attached I discovered that it did not manage to intercept any compilation commands. This means that the issue lies in the way you build the project under the build-wrapper invocation:

build-wrapper-linux-x86-64 --out-dir /opt/carma/bw-output bash make_with_coverage.bash -m -e /opt/carma/ -o ./coverage_reports/gcov

The usual reason for this is either

  • building the project in a container (for example in a Docker container), or
  • building it on a remote host.

Neither mode is supported by Build Wrapper (they escape our process interception mechanism).

From your build logs I infer that you are using a build-automation tool colcon, which I am not familiar with, but which is likely doing one of the above.

Can you check if you are using Docker containers or remote hosts for the build?

@necto

Sorry for the late response! We are using the docker containers, We are able to see the sonar scan results for few of other projects with same compilation commands from our carma-base repo. Just want to verify why it is passing for few repos like carma-platform and carma-messenger, etc. with same build commands and failing repos like (GitHub - usdot-fhwa-stol/carma-velodyne-lidar-driver: Velodyne LiDAR Driver wrapper for usage with the CARMA Platform), (GitHub - usdot-fhwa-stol/carma-lightbar-driver: CARMALightbarDriver is the driver for use with a ADAM6256 IO Module custom configured Lightbar and the CARMA Platform.). Could you please help me with any inputs for this. Thank you!

Unfortunately, I do not have the bandwidth to compare build configurations of multiple projects.
I can only give you a hint on how to go about investigating the issue.

As I said, Build Wrapper does not support “remote execution”, be it a cluster with the compilation done by several worker machines, or a cluster of several virtual machines, or a constellation of multiple independent processes such as multiple Docker containers.
The reason is all the above prevents Build Wrapper from intercepting compilation commands since Build Wrapper is only run at the coordinator node and does not see the workers.

You can try to run a sequential build (see --executor sequential). I have no experience with colcon, but chances are it will run compilation as a subprocess of the original process which is supported by Build Wrapper.

If this does not help, you can give up on the Build Wrapper, and generate a compilation database instead. SonarCloud supports it as a way of configuring C and C++ analysis, see the " Analysis Steps Using Compilation Database" here.

@necto,

Thank you so much for the inputs! I’ll go and try with this new configurations and update you.

Regards,
Saikrishna