Build-wrapper scanning 0 C files

  • ALM used: GitHub
  • CI system used: Circle CI
  • Scanner command used when applicable: sonar-scanner
  • Languages of the repository: C, C++, C#
  • Error observed:
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 44.685s
INFO: Final Memory: 43M/786M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: The "build-wrapper-dump.json" file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:
  * you are using the latest version of the build-wrapper and the SonarCFamily analyzer
  * you are correctly invoking the scanner with correct configuration  
  * your compiler is supported
  * you are wrapping your build correctly
  * you are wrapping a full/clean build
  * you are providing the path to the correct build-wrapper output directory
  • Steps to reproduce: run sonar-scanner through circleci
  • Potential workaround: unclear

I am attempting to integrate sonar scans into our CircleCI workflow, but am currently blocked by the above error. When I run the scanner on my local, it finishes without issue and posts results to localhost:9000 like in the documentation, however when trying to do the same via sonarcloud, the execution fails.

Addressing the points in the error:
* you are using the latest version of the build-wrapper and the SonarCFamily analyzer
Both are downloaded from the website as part of the docker build for the base image we’re scanning on, so they are definitely the latest.

* you are correctly invoking the scanner with correct configuration
Not 100% clear what this means, however it’s a pretty simple sonar-scanner -Dproject.settings=<path> -Dsonar.login=<token> that we’re doing, and again the command works on local.

* your compiler is supported
Using same compiler as on local, so yes.

* you are wrapping your build correctly
It would appear not since this isn’t working. The specific command we are using is build-wrapper-linux-x86-64 --out-dir ../../bw-output ../build.sh, where build.sh is just a script that runs all our build commands. Again, works on local.

* you are wrapping a full/clean build
Definitely full because we’re doing the same build process as local. Definitely clean because the build is done right after the Docker base image is spun up, which doesn’t have any files from a previous build on it.

* you are providing the path to the correct build-wrapper output directory
Definitely are because it is finding the build-wrapper-dump.json file.

Here’s a link to our repo if you’d like to take a look: https://github.com/usdot-fhwa-OPS/V2X-Hub. There are some odd configs and comments there since I’m currently trying to debug, so please let me know if you want any clarification on what we’re doing.

Hi @jtbaird,

could you possibly be affected by this bug (workaround in the ticket description)?
https://jira.sonarsource.com/browse/CPP-2027

Note that it has been fixed and soon to be released.

I don’t think so, we’re not getting the LD_PRELOAD error. The only error we’re getting is the one posted above.

Hi @jtbaird,

what compiler are you using? Would you be able to share the content of the build-wrapper output directory?

Compiler from CMakeCXXCompiler.cmake:

set(CMAKE_CXX_COMPILER_ID "GNU")
set(CMAKE_CXX_COMPILER_VERSION "7.4.0")

build-wrapper output:

"MYSQL_ROOT_PASSWORD=***",
"DOCKER_MACHINE_NAME=138427671",
"DOCKER_TLS_VERIFY=1",
"CIRCLE_INTERNAL_SCRATCH=/tmp/circleci-231999853",
"CIRCLE_WORKFLOW_ID=d77c3fc4-f371-4547-8bc5-d1d4f103dfac",
"_=/usr/bin/cmake",
"CIRCLE_WORKFLOW_JOB_ID=c83558b1-7bc5-475f-bc48-8394090757ac",
"CIRCLE_WORKFLOW_WORKSPACE_ID=d77c3fc4-f371-4547-8bc5-d1d4f103dfac",
"TERM=xterm",
"DOCKER_CERT_PATH=/tmp/docker-certs217768936",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/jq/:/opt/sonarqube/sonar-scanner/bin/:/opt/sonarqube/build-wrapper/",
"CIRCLE_INTERNAL_TASK_DATA=/.circleci-task-data",
"CIRCLE_PROJECT_REPONAME=V2X-Hub",
"CIRCLE_STAGE=build",
"LANG=",
"CIRCLE_USERNAME=jtbaird",
"CIRCLE_NODE_INDEX=0",
"SSH_AUTH_SOCK=/tmp/circleci-231999853/ssh_auth_sock",
"CIRCLE_JOB=build",
"LC_MESSAGES=",
"DOCKER_HOST=tcp://34.74.23.212:2376",
"CIRCLE_PROJECT_USERNAME=usdot-fhwa-OPS",
"BASH_ENV=/tmp/.bash_env-5e3c66b2a317d879d864f197-0-build",
"CIRCLE_PREVIOUS_BUILD_NUM=644",
"PWD=/home/V2X-Hub/src/tmx",
"LC_ALL=",
"CIRCLE_SHA1=1748d5bf153fe010b54d6d54c09dec6d7e4ae667",
"CIRCLE_NODE_TOTAL=1",
"LD_PRELOAD="]}]}

Hi @jtbaird,

could you please share the content of such folder? It is the folder where build-wrapper is saving information.

Yeah here are the contents:

+ ls ../../bw-output
build-wrapper-dump.json  build-wrapper.log

Hi @jtbaird,

could you please share those files? They may help in understanding the issue.

Had to save them as .txt in order to upload, but here are the files:
build-wrapper-dump.txt (34.6 KB)
build-wrapper.txt (117.6 KB)

@mpaladin any ideas?

Hi @jtbaird,

in the log file I don’t see any build, I see cmake . configuration invocation but not cmake --build ., what do you have in your build.sh?

Hey Massimo, here’s the build.sh:

#!/bin/bash

cmake .
make
make install  

I just put the build commands we’re using into one script so we could wrap it with the build-wrapper command.

Hi @jtbaird,

can you share the console output of the job? Is it a clean build or is workspace persisted between two runs?

We’re running it on CircleCI, which spins up a new container to run our job on every time, so has to be a clean build. Output from CircleCI is attached. Thanks Massimo! build-output.txt (283.2 KB)

Hi @jtbaird,

in your log, during make command:

[ 50%] Built target asn_j2735_r63
[ 91%] Built target asn_j2735_r41
[ 92%] Built target tmxapiStatic
[ 94%] Built target tmxapi
[ 97%] Built target tmxutils
[ 99%] Built target tmxcore
[100%] Built target tmxctlStatic
[100%] Built target tmxctl
[100%] Built target j2735dump
[ 50%] Built target asn_j2735_r63
[ 91%] Built target asn_j2735_r41
[ 92%] Built target tmxapiStatic
[ 94%] Built target tmxapi
[ 97%] Built target tmxutils
[ 99%] Built target tmxcore
[100%] Built target tmxctlStatic
[100%] Built target tmxctl
[100%] Built target j2735dump

I don’t see any compilation unit being compiled. Is your project header only? Please note that the analyzer entry points are the compilation units which get compiled, not the header file.

Hey Massimo,

Thanks for pointing that out! Turns out that the build wrapper wasn’t getting all the info it needed since we were checking out and building our project on a base image of the same project. Thanks again for the pointers in all this.

1 Like

Hi @jtbaird,

thank you for the update, I am glad you spotted the issue.