The "build-wrapper-dump.json" file was found empty using cmake --build option

Hi SonarSource Community !

I stumbled recently on an issue related to the build-wrapper usage, but first, here are few technical information as context :

  • CI system : Azure DevOps
  • OS : Ubuntu Server 18.04 LTS (custom builder host for Azure DevOps)
  • build-wrapper-linux-x86_64 (version 6.23, installed locally and set in the Azure Agent’s PATH variable)
  • sonar-scanner (version, downloaded automatically by Azure DevOps’ SonarCloudAnalyse task)
  • CMake build system (version 3.20.5)
  • Project’s Language : C++17

In my pipeline, I was using the following command to build my project and satisfy Sonar’s needs :

build-wrapper-linux-x86-64 --out-dir . cmake --build .

I was hoping to be able to infer the underlying CMake Generator (as seen on this answer ), but instead I was blocked by the following error : java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found empty. Please make sure that: […]

So, I tried not infering the Generator with the following command

build-wrapper-linux-x86-64 --out-dir . ninja

and I have been surprised : It works and my pipeline finishes without any issues.

BUT I will still need to infer the CMake Generator at one point, so my question : does some one already encounter a similar case and found what was the problem with the cmake --build . statement ?

Thanks in advance for any help or tips !

Hi @mscherer ,

this is supposed to work. Can we try to understand what’s going wrong in your test?

build-wrapper-linux-x86-64 --out-dir . cmake --build .


build-wrapper-linux-x86-64 --out-dir . ninja

should lead to the same result. Could you share the build-wrapper.log and build-wrapper-dump.json files of both runs? I can send you a pm if you prefer to share privately.

Hi @mpaladin
Thanks for taking interest in this small problem (probably).

Here are the files you requested.
I looked into them, but I am clearly not used to, so maybe you will be able to find something strange. (16.0 KB)

Once again : thank you for the help !

Hi @mscherer ,

the reason is because of snap, you are invoking a cmake which has been installed through build-wrapper is using dynamic library concept to observe created processes, in this case it is not able to follow snap children because snap statically link exec* family calls.

If you run which cmake you are going to see /snap/bin/cmake which is a link to /usr/bin/snap.

You have several options here:

  • avoid snap wrapper during invocation:
    cmake -G Ninja -B build-dir -S .
    build-wrapper-linux-x86-64 --out-dir cfamily-compilation-database ./snap/cmake/current/bin/cmake --build build-dir
    sonar-scanner ... ...
  • use cmake installed by apt or by downloading it from
  • use Clang JSON Compilation Database (documentation), with CMake
    cmake -G Ninja -B build-dir -S .
    cmake --build build-dir
    sonar-scanner ... -Dsonar.cfamily.compile-commands=build-dir/compile_commands.json ...

Hi @mpaladin ,

Thanks for your answer, it is very clear and helpful.
It’s a shame to see such a flaw in snap’s design, even if it’s still an interesting tool…

Again, thank you for your help and time !

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