Error while using wrapper: The "build-wrapper-dump.json" file was found empty

Hi !
I’m trying to use SonarQube on my (mainly) C++ project.
I’m trying to use correctly build-wrapper-linux-x86-64, but even if my compilation is working fine, my file build-wrapper-dump.json doesn’t contain any information.

The versions I use:
SonarQube 8.0
build-wrapper, version 6.4 (linux-x86)
SonarQube Scanner 4.2.0.1873

My file sonar-project.properties:

sonar-project.properties
# must be unique in a given SonarQube instance
sonar.projectKey=rtc

# --- optional properties ---

# defaults to project key
#sonar.projectName=My project
# defaults to 'not provided'
sonar.language=cpp
#sonar.projectVersion=1.0
 
# Path is relative to the sonar-project.properties file. Defaults to .
sonar.sources=. 

sonar.cfamily.build-wrapper-output=build_wrapper_output_directory

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
sonar.java.binaries=build.x86_64/

The (empty) output I got from the wrapper:

# All SONARSOURCE programs and content are copyright protected.
# SONARSOURCE and SONARQUBE are trademarks of SonarSource SA. All rights are expressly reserved.
#
# This file is designed exclusively for use with the SONARSOURCE C / C++ / Objective-C Plugin.
# It may not be used in connection with any other software.
# Any other use is prohibited by law and may be grounds for immediate termination of your License.
{
"version":0,
"captures":[
]}

The logs I got in build-wrapper.log:

Thu Nov 07 16:09:06 2019: build-wrapper, version 6.4 (linux-x86)
Thu Nov 07 16:09:06 2019: System name: Linux Nodename: toex2096 Release: 4.15.0-65-generic Version: #74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019 Machine: x86_64
Thu Nov 07 16:09:06 2019: socket path: /tmp/build-wrapper-socket.FsZYsk
Thu Nov 07 16:09:06 2019: dynamic library found: /PATH/build-wrapper-linux-x86/libinterceptor-i686.so
Thu Nov 07 16:09:06 2019: dynamic library found: /PATH/build-wrapper-linux-x86/libinterceptor-x86_64.so
Thu Nov 07 16:09:06 2019: command executed as: </PATH/build-wrapper-linux-x86/build-wrapper-linux-x86-64>
Thu Nov 07 16:09:06 2019: command line received: <sudo python scripts/build.py -t x86_64>
Thu Nov 07 16:09:06 2019: env 0: <HOSTNAME=toex2096>
Thu Nov 07 16:09:06 2019: env 1: <TERM=xterm-256color>
Thu Nov 07 16:09:06 2019: env 2: <EPICS_CAS_AUTO_BEACON_ADDR_LIST=NO>
Thu Nov 07 16:09:06 2019: env 3: <LS_COLORS=rs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.Z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*.svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5;13:*.webm=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38;5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv=38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.axv=38;5;13:*.anx=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.mid=38;5;45:*.midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:>
Thu Nov 07 16:09:06 2019: env 4: <SSH_AUTH_SOCK=/run/user/1000029/keyring/ssh>
Thu Nov 07 16:09:06 2019: env 5: <PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin>
Thu Nov 07 16:09:06 2019: env 6: <PWD=/PATH/shared_repo/RTC1/src>
Thu Nov 07 16:09:06 2019: env 7: <JENKINS_PUBLIC_KEY=define>
Thu Nov 07 16:09:06 2019: env 8: <LANG=en_US.UTF-8>
Thu Nov 07 16:09:06 2019: env 9: <MODULEPATH=/usr/share/Modules/modulefiles:/etc/modulefiles>
Thu Nov 07 16:09:06 2019: env 10: <LOADEDMODULES=>
Thu Nov 07 16:09:06 2019: env 11: <HOME=/home/my_name>
Thu Nov 07 16:09:06 2019: env 12: <SHLVL=2>
Thu Nov 07 16:09:06 2019: env 13: <GITLAB_SSH_PRIVATE_KEY=define>
Thu Nov 07 16:09:06 2019: env 14: <MODULESHOME=/usr/share/Modules>
Thu Nov 07 16:09:06 2019: env 15: <LESSOPEN=||/usr/bin/lesspipe.sh %s>
Thu Nov 07 16:09:06 2019: env 16: <DISPLAY=:0>
Thu Nov 07 16:09:06 2019: env 17: <BASH_FUNC_module()=() {  eval `/usr/bin/modulecmd bash $*`
}>
Thu Nov 07 16:09:06 2019: env 18: <OLDPWD=/PATH/shared_repo/RTC1>
Thu Nov 07 16:09:06 2019: env 19: <_=/PATH/build-wrapper-linux-x86/build-wrapper-linux-x86-64>
Thu Nov 07 16:09:06 2019: executing: <sudo python scripts/build.py -t x86_64>
Thu Nov 07 16:09:06 2019: initializing json file
Thu Nov 07 16:09:06 2019: process created with pid: 15612
Thu Nov 07 16:09:06 2019: parent pid: 15611
Thu Nov 07 16:09:06 2019: working directory: </PATH/shared_repo/RTC1/src>
Thu Nov 07 16:09:06 2019: executable: </PATH/build-wrapper-linux-x86/build-wrapper-linux-x86-64>
Thu Nov 07 16:09:06 2019: argv[0]: </PATH/build-wrapper-linux-x86/build-wrapper-linux-x86-64>
Thu Nov 07 16:09:06 2019: argv[1]: <-c>
Thu Nov 07 16:09:06 2019: argv[2]: <>
Thu Nov 07 16:09:06 2019: argv[3]: <sudo>
Thu Nov 07 16:09:06 2019: argv[4]: <python>
Thu Nov 07 16:09:06 2019: argv[5]: <scripts/build.py>
Thu Nov 07 16:09:06 2019: argv[6]: <-t>
Thu Nov 07 16:09:06 2019: argv[7]: <x86_64>
Thu Nov 07 16:09:06 2019: skipping process with pid: 15612
Thu Nov 07 16:31:18 2019: finalizing json file
Thu Nov 07 16:31:18 2019: returned with code: 0

I’m running it on a docker CentOS7, using cmake to compile with a python to launch the compilation, using c++ (default centos 7 g++) as a compiler.

I’m under the impression that it skips the process entirely, but I don’t understand what I’m doing wrong.
I didn’t find a working solution in the other threads with the same issue.
Could you help me?

Hi @a.d,

I believe that sudo is the issue here, build-wrapper cannot follow the launched process. Why running build as root?

Our CMake compiles but also install our product in the system in which it is launch, and need some accesses to do so.
I retried without using sudo (without install), but I had the same results:

# (C) SonarSource SA, 2014-2019, info@sonarsource.com
# All SONARSOURCE programs and content are copyright protected.
# SONARSOURCE and SONARQUBE are trademarks of SonarSource SA. All rights are expressly reserved.
#
# This file is designed exclusively for use with the SONARSOURCE C / C++ / Objective-C Plugin.
# It may not be used in connection with any other software.
# Any other use is prohibited by law and may be grounds for immediate termination of your License.
{
"version":0,
"captures":[
]}

And similar logs

Fri Nov 08 17:15:13 2019: build-wrapper, version 6.4 (linux-x86)
Fri Nov 08 17:15:13 2019: System name: Linux Nodename: toex2096 Release: 4.15.0-65-generic Version: #74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019 Machine: x86_64
Fri Nov 08 17:15:13 2019: socket path: /tmp/build-wrapper-socket.zW3wNS
Fri Nov 08 17:15:13 2019: dynamic library found: /home/path/build-wrapper-linux-x86/libinterceptor-i686.so
Fri Nov 08 17:15:13 2019: dynamic library found: /home/path/build-wrapper-linux-x86/libinterceptor-x86_64.so
Fri Nov 08 17:15:13 2019: command executed as: </home/path/build-wrapper-linux-x86/build-wrapper-linux-x86-64>
Fri Nov 08 17:15:13 2019: command line received: <python scripts/build.py -t x86_64 -m U_Test_Common>
Fri Nov 08 17:15:13 2019: env 0: <HOSTNAME=toex2096>
Fri Nov 08 17:15:13 2019: env 1: <TERM=xterm-256color>
Fri Nov 08 17:15:13 2019: env 2: <EPICS_CAS_AUTO_BEACON_ADDR_LIST=NO>
Fri Nov 08 17:15:13 2019: env 3: <OLDPWD=/home/pathshared_repo/RTC1>
Fri Nov 08 17:15:13 2019: env 4: <LS_COLORS=rs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.Z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*.svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5;13:*.webm=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38;5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv=38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.axv=38;5;13:*.anx=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.mid=38;5;45:*.midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:>
Fri Nov 08 17:15:13 2019: env 5: <SSH_AUTH_SOCK=/run/user/1000029/keyring/ssh>
Fri Nov 08 17:15:13 2019: env 6: <PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin>
Fri Nov 08 17:15:13 2019: env 7: <PWD=/home/pathshared_repo/RTC1/src>
Fri Nov 08 17:15:13 2019: env 8: <JENKINS_PUBLIC_KEY=define>
Fri Nov 08 17:15:13 2019: env 9: <LANG=en_US.UTF-8>
Fri Nov 08 17:15:13 2019: env 10: <MODULEPATH=/usr/share/Modules/modulefiles:/etc/modulefiles>
Fri Nov 08 17:15:13 2019: env 11: <LOADEDMODULES=>
Fri Nov 08 17:15:13 2019: env 12: <HOME=/home/path>
Fri Nov 08 17:15:13 2019: env 13: <SHLVL=2>
Fri Nov 08 17:15:13 2019: env 14: <GITLAB_SSH_PRIVATE_KEY=define>
Fri Nov 08 17:15:13 2019: env 15: <MODULESHOME=/usr/share/Modules>
Fri Nov 08 17:15:13 2019: env 16: <LESSOPEN=||/usr/bin/lesspipe.sh %s>
Fri Nov 08 17:15:13 2019: env 17: <DISPLAY=:0>
Fri Nov 08 17:15:13 2019: env 18: <BASH_FUNC_module()=() {  eval `/usr/bin/modulecmd bash $*`
}>
Fri Nov 08 17:15:13 2019: env 19: <_=/home/path/build-wrapper-linux-x86/build-wrapper-linux-x86-64>
Fri Nov 08 17:15:13 2019: executing: <python scripts/build.py -t x86_64 -m U_Test_Common>
Fri Nov 08 17:15:13 2019: initializing json file
Fri Nov 08 17:15:13 2019: process created with pid: 15767
Fri Nov 08 17:15:13 2019: parent pid: 15766
Fri Nov 08 17:15:13 2019: working directory: </home/pathshared_repo/RTC1/src>
Fri Nov 08 17:15:13 2019: executable: </home/path/build-wrapper-linux-x86/build-wrapper-linux-x86-64>
Fri Nov 08 17:15:13 2019: argv[0]: </home/path/build-wrapper-linux-x86/build-wrapper-linux-x86-64>
Fri Nov 08 17:15:13 2019: argv[1]: <-c>
Fri Nov 08 17:15:13 2019: argv[2]: <>
Fri Nov 08 17:15:13 2019: argv[3]: <python>
Fri Nov 08 17:15:13 2019: argv[4]: <scripts/build.py>
Fri Nov 08 17:15:13 2019: argv[5]: <-t>
Fri Nov 08 17:15:13 2019: argv[6]: <x86_64>
Fri Nov 08 17:15:13 2019: argv[7]: <-m>
Fri Nov 08 17:15:13 2019: argv[8]: <U_Test_Common>
Fri Nov 08 17:15:13 2019: skipping process with pid: 15767
Fri Nov 08 17:15:13 2019: process created with pid: 15768
Fri Nov 08 17:15:13 2019: parent pid: 15767
Fri Nov 08 17:15:13 2019: working directory: </home/pathshared_repo/RTC1/src>
Fri Nov 08 17:15:13 2019: executable: </usr/bin/python2.7>
Fri Nov 08 17:15:13 2019: argv[0]: <python>
Fri Nov 08 17:15:13 2019: argv[1]: <scripts/build.py>
Fri Nov 08 17:15:13 2019: argv[2]: <-t>
Fri Nov 08 17:15:13 2019: argv[3]: <x86_64>
Fri Nov 08 17:15:13 2019: argv[4]: <-m>
Fri Nov 08 17:15:13 2019: argv[5]: <U_Test_Common>
Fri Nov 08 17:15:13 2019: skipping process with pid: 15768
Fri Nov 08 17:15:33 2019: finalizing json file
Fri Nov 08 17:15:33 2019: returned with code: 0

The compilation itself has been successful.

Hi @a.d,

is scripts/build.py spawning cmake process as a child?

build-wrapper uses LD_PRELOAD to load a dynamic library on children processes in order to be able to follow them.

Hi, sorry for the delay,
scripts/build.py is spawning cmake process by making a system call.
I modified this call to call the wrapper inside this system call instead of above the script.
It generates data in my build-wrapper.log.

However, it makes multiple call to the wrapper in multiple folders, so I may have an issue in the future to launch the scanner on my entire project.

For the moment, I stumbled on another issue with the Scanner, so I will open another issue.

Thank you for your time,

Arthur Dumas