"build-wrapper-dump.json" found empty

SonarCloud used within Bitbucket. Problem reproduced on local linux system. build-wrapper-linux-x86-64 doesn’t output valid build-wrapper-dump.json but build-wrapper.log appears to be populated correctly.

sonar-scanner debug (-X) output:

  • you are using the latest version of the build-wrapper and the CFamily analyzer

    • build-wrapper-linux-x86-64 version 6.29
  • your compiler is supported

    • GCC/G++: arm-none-eabi-gcc and arm-none-eabi-g++
  • you are wrapping your build correctly

    • build-wrapper.log is 19M, data appears valid, ends with “returned with code: 0”
  • you are wrapping a full/clean build

    • Confirmed, clean build. Freshly cloned git repository, then python script runs cmake and “ninja -v”. Tried single thread “-j1” and multithread, both result in same, mostly empty “build-wrapper-dump.json” file.
  • if you are building your project inside a Docker container, build-wrapper is wrapping the build process inside the container and not wrapping the external Docker process

    • using Bitbucket pipelines script provided by SonarCloud.io signup, with updated build-wrapper-linux-x86-64 line:
        - export SONAR_SCANNER_VERSION=4.4.0.2170
        - export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
        - export BW_OUTPUT=$HOME/.sonar/bw-output
        - mkdir -p $BW_OUTPUT
        - curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
        - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
        - export PATH=$SONAR_SCANNER_HOME/bin:$PATH
        - curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
        - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
        - export PATH=$HOME/.sonar/build-wrapper-linux-x86:$PATH
        - build-wrapper-linux-x86-64 --out-dir $BW_OUTPUT python3 build.py -v
        - sonar-scanner -Dsonar.cfamily.build-wrapper-output=$BW_OUTPUT
  • I can reproduce the problem on my local system with:
    ./build-wrapper-linux-x86-64 --out-dir . python3 build.py -v

No snaps present. Build-wrapper just couldn’t follow the build.

The solution was to use compilation database: C/C++/Objective-C | SonarCloud Docs

2 Likes

More details on this topic and request for documentation update.

There is a bug in Sonar’s linux build-wrapper executable. I got to the point of running strace and realized any tool being paid for shouldn’t be this hard to integrate. I had to work around build-wrapper by using a cmake compilation database flag “-DCMAKE_EXPORT_COMPILE_COMMANDS=ON”.

For CMake based builds, using Sonar’s build-wrapper is completely unnecessary and just adds more complexity and time to the analysis. It has to be downloaded, decompressed, run and troubleshot. When using cmake, you just add a single command line option and point to the output file.

I strongly suggest the documentation for C/C++ analysis be changed at: C/C++/Objective-C | SonarCloud Docs “The general recommendation is to use Build Wrapper unless you have a good reason not to.” I trusted this statement and wasted 2 days getting the build to work. I only made progress when not using the build-wrapper. Adding something about cmake builds using the flag listed above will save people time.

1 Like

Hi @KaseyErickson,

Welcome to the community!

Sorry I missed your post due to the missing CFamily tag.

I’m sorry you had a bad experience with build-wrapper. Our recommendation is based on the safer choice based on the experience of most of our users.

Build-wrapper has limitations. Same for the compilation database. and you probably hit one of the limitations. you have a look at this blog post for more insight.

I will have to investigate further if you are interested to see why it is not working for you. For example, build-wrapper cannot track your build command if you are executing it in sudo mode. were you doing that?

there is already a direct link to the CMake page that tells you how to generate a Compilation database when using CMake:

It can be generated by tools like [CMake] It can be generated by tools like CMake

Thanks,

Build-wrapper has limitations. Same for the compilation database. and you probably hit one of the limitations. you have a look at this blog post for more insight.

Listing the build-wrapper limitations in the “Important Notes” section of C/C++/Objective-C | SonarCloud Docs would be helpful. Specifically, running in sudo, python3 or other build invocations, then pointing the user to the compilation database option. A link the blog post would also be relevant and helpful.

For example, build-wrapper cannot track your build command if you are executing it in sudo mode. were you doing that?

No, but it is wrapped in python3.

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