Build-wrapper is not producing output with specific gcc version

  • Versions used
    build-wrapper - 6.4
    gcc - x86_64-centos6-linux-gnu-g++ (crosstool-NG 1.24.0) 8.3.0

  • Error observed
    When using a specific GCC version/toolchain, build-wrapper doesn’t produce any output in build-wrapper-dump.json.

The logs below are from building the sonar-scanning-examples/sonarqube-scanner-build-wrapper-linux example project with GCC 8.3.0. There are no build errors (and the compiled programs work).

When building with the system default GCC (7.4.0) or with Clang, build-wrapper work correctly and produces output in build-wrapper-dump.json.

build-wrapper-dump.json

# (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":[
]}

build-wrapper.log

Mon Nov 04 18:09:09 2019: build-wrapper, version 6.4 (linux-x86)
Mon Nov 04 18:09:09 2019: System name: Linux Nodename: 6f085fdb0caa Release: 4.9.184-linuxkit Version: #1 SMP Tue Jul 2 22:58:16 UTC 2019 Machine: x86_64
Mon Nov 04 18:09:09 2019: socket path: /tmp/build-wrapper-socket.IcEoog
Mon Nov 04 18:09:09 2019: dynamic library found: /opt/sonar_scanner/bin/libinterceptor-i686.so
Mon Nov 04 18:09:09 2019: dynamic library found: /opt/sonar_scanner/bin/libinterceptor-x86_64.so
Mon Nov 04 18:09:09 2019: command executed as: <build-wrapper-linux-x86-64>
Mon Nov 04 18:09:09 2019: command line received: <./build.sh>
Mon Nov 04 18:09:09 2019: env 0: <LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:>
Mon Nov 04 18:09:09 2019: env 1: <LESSCLOSE=/usr/bin/lesspipe %s %s>
Mon Nov 04 18:09:09 2019: env 2: <HOSTNAME=6f085fdb0caa>
Mon Nov 04 18:09:09 2019: env 3: <PWD=/code>
Mon Nov 04 18:09:09 2019: env 4: <HOME=/root>
Mon Nov 04 18:09:09 2019: env 5: <TERM=xterm>
Mon Nov 04 18:09:09 2019: env 6: <SHLVL=1>
Mon Nov 04 18:09:09 2019: env 7: <PATH=/opt/sonar_scanner/bin:/xtools/x86_64-centos6-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin>
Mon Nov 04 18:09:09 2019: env 8: <LESSOPEN=| /usr/bin/lesspipe %s>
Mon Nov 04 18:09:09 2019: env 9: <_=/opt/sonar_scanner/bin/build-wrapper-linux-x86-64>
Mon Nov 04 18:09:09 2019: env 10: <OLDPWD=/xtools/x86_64-centos6-linux-gnu/bin>
Mon Nov 04 18:09:09 2019: executing: <./build.sh>
Mon Nov 04 18:09:09 2019: initializing json file
Mon Nov 04 18:09:09 2019: process created with pid: 528
Mon Nov 04 18:09:09 2019: parent pid: 527
Mon Nov 04 18:09:09 2019: working directory: </code>
Mon Nov 04 18:09:09 2019: executable: </opt/sonar_scanner/bin/build-wrapper-linux-x86-64>
Mon Nov 04 18:09:09 2019: argv[0]: <build-wrapper-linux-x86-64>
Mon Nov 04 18:09:09 2019: argv[1]: <-c>
Mon Nov 04 18:09:09 2019: argv[2]: <>
Mon Nov 04 18:09:09 2019: argv[3]: <./build.sh>
Mon Nov 04 18:09:09 2019: skipping process with pid: 528
Mon Nov 04 18:09:09 2019: process created with pid: 529
Mon Nov 04 18:09:09 2019: parent pid: 528
Mon Nov 04 18:09:09 2019: working directory: </code>
Mon Nov 04 18:09:09 2019: executable: </bin/bash>
Mon Nov 04 18:09:09 2019: argv[0]: </bin/bash>
Mon Nov 04 18:09:09 2019: argv[1]: <./build.sh>
Mon Nov 04 18:09:09 2019: skipping process with pid: 529
Mon Nov 04 18:09:09 2019: process created with pid: 530
Mon Nov 04 18:09:09 2019: parent pid: 529
Mon Nov 04 18:09:09 2019: working directory: </code>
Mon Nov 04 18:09:09 2019: executable: </bin/rm>
Mon Nov 04 18:09:09 2019: argv[0]: <rm>
Mon Nov 04 18:09:09 2019: argv[1]: <-rf>
Mon Nov 04 18:09:09 2019: argv[2]: <build>
Mon Nov 04 18:09:09 2019: skipping process with pid: 530
Mon Nov 04 18:09:09 2019: process created with pid: 531
Mon Nov 04 18:09:09 2019: parent pid: 529
Mon Nov 04 18:09:09 2019: working directory: </code>
Mon Nov 04 18:09:09 2019: executable: </bin/mkdir>
Mon Nov 04 18:09:09 2019: argv[0]: <mkdir>
Mon Nov 04 18:09:09 2019: argv[1]: <build>
Mon Nov 04 18:09:09 2019: skipping process with pid: 531
Mon Nov 04 18:09:10 2019: finalizing json file
Mon Nov 04 18:09:10 2019: returned with code: 0

Hi @mwcmd,

Is this the name of the compiler which is not captured by build-wrapper? Is it statically linked?

Hi, yes, the compiler being used is x86_64-centos6-linux-gnu-g++, and it is statically linked.
I’m also building the toolchain, so if there’s some requirements on how the compiler is built, I can change it.

Hi @mwcmd,

build-wrapper is using a dynamic library loaded with LD_PRELOAD in order to observe compilers calls. That means that cannot observe statically linked binaries. Two options could be:

  • have a small bash wrapper with the same name x86_64-centos6-linux-gnu-g++ which simply calls the real x86_64-centos6-linux-gnu-g++, this should allow build-wrapper to observe the bash call and fetch the configuration
  • the other option is to not statically link x86_64-centos6-linux-gnu-g++

Hi, Thanks, building the compiler with dynamic linking did fix the problem for me.

1 Like

Hi @mwcmd,

great to hear that, thank you for the update.