Sonarscan with qmake project

Hi,

I want to use Sonarcloud with a Qt project for an embedded system based on the imx6dl CPU (ARMv7 architecture). I created a custom docker image with the build environment all setup up and building works just flawlessly. Problem start occuring when using the bitbucket pipe for sonar-scan.

Details of the project:

  • ALM used: Bitbucket Cloud
  • CI system used: Bitbucket Cloud
  • Pipeline script:
    • qmake main.pro && build-wrapper-linux-x86-64 --out-dir bw_output make -j8
    • pipe: sonarsource/sonarcloud-scan:1.1.0
      variables:
      DEBUG: ‘true’
      EXTRA_ARGS: ‘-Dsonar.cfamily.build-wrapper-output=“bw_output” -Dsonar.cfamily.threads=8 -Dsonar.cfamily.cache.enabled=false’
  • Languages of the repository: C++ with Qt
  • Error observed:
    The build-wrapper.json contains valid output captured by the make command, as far as I can tell:
    {
    “compiler”: “clang”,
    “cwd”: “/opt/atlassian/pipelines/agent/build//src/vplayer",
    “executable”: "/opt/sdk/latest/sysroots/x86_64-sdk-linux/usr/bin/arm--linux-gnueabi/arm-
    -linux-gnueabi-g++”,
    “cmd”: [
    “arm--linux-gnueabi-g++",
    “-marm”,
    “-mfpu=neon”,
    “-mfloat-abi=hard”,
    “-mcpu=cortex-a9”,
    "–sysroot=/opt/sdk/latest/sysroots/cortexa9hf-neon-
    -linux-gnueabi”,
    “-c”,
    “-pipe”,
    “-O2”,
    “-pipe”,
    “-g”,
    “-feliminate-unused-debug-types”,
    “–sysroot=/opt/sdk/latest/sysroots/cortexa9hf-neon--linux-gnueabi",
    “-Wformat-security”,
    “-Werror=format-security”,
    “-Wall”,
    “-Wextra”,
    “-O2”,
    “-std=gnu++11”,
    “-pthread”,
    “-pthread”,
    “-pthread”,
    “-Wall”,
    “-W”,
    “-D_REENTRANT”,
    “-fPIC”,
    “-DQT_NO_DEBUG_OUTPUT”,
    “-DQT_DEPRECATED_WARNINGS”,
    “-DGSTNETPORT=51153”,
    “-DAVIPCPORT=51152”,
    “-DDEV_LOG”,
    “-DQT_NO_DEBUG”,
    “-DQT_NETWORK_LIB”,
    “-DQT_BLUETOOTH_LIB”,
    “-DQT_DBUS_LIB”,
    “-DQT_CORE_LIB”,
    “-I.”,
    “-I.”,
    "-I…/lib_
    ”,
    “-I…/lib_/player",
    "-I/opt/sdk/latest/sysroots/cortexa9hf-neon-
    -linux-gnueabi/usr/include/gstreamer-1.0”,
    “-I/opt/sdk/latest/sysroots/cortexa9hf-neon--linux-gnueabi/usr/include/glib-2.0",
    "-I/opt/sdk/latest/sysroots/cortexa9hf-neon-
    -linux-gnueabi/usr/lib/glib-2.0/include”,
    “-I/opt/sdk/latest/sysroots/cortexa9hf-neon--linux-gnueabi/usr/include/QtNetwork",
    "-I/opt/sdk/latest/sysroots/cortexa9hf-neon-
    -linux-gnueabi/usr/include/QtBluetooth”,
    “-I/opt/sdk/latest/sysroots/cortexa9hf-neon--linux-gnueabi/usr/include/QtDBus",
    "-I/opt/sdk/latest/sysroots/cortexa9hf-neon-
    -linux-gnueabi/usr/include/QtCore”,
    “-I.”,
    “-I/opt/sdk/latest/sysroots/cortexa9hf-neon--linux-gnueabi/usr/lib/mkspecs/linux-oe-g++",
    “-o”,
    "
    _avsync_server.o”,
    “******_avsync_server.cpp”
    ]
    }

However in the build.log for the pipe I get those kinds of errors (Only copied one, repeats for all files of the project):
12:07:47.536 INFO: Cache is explicitly disabled: Optional[false]
12:07:47.566 DEBUG: Probing compiler: [/opt/sdk/latest/sysroots/x86_64-sdk-linux/usr/bin/arm--linux-gnueabi/arm--linux-gnueabi-g++, -x, c++, --std, gnu++11, -mcpu=cortex-a9, --sysroot=/opt/sdk/latest/sysroots/cortexa9hf-neon--linux-gnueabi, -marm, -v, -dM, -E, -]
12:07:47.590 DEBUG: stdout:

12:07:47.599 WARN: Invalid probe found, skip analysis of files: [/opt/atlassian/pipelines/agent/build/*******/src/vplayer/*******_avsync_server.cpp]
The compiler probe 'stdout' is expected to contain at least one '#define' directive:

12:07:47.700 INFO: Subprocess(es) done in 164ms
12:07:47.700 INFO: 0 compilation units analyzed
12:07:47.727 INFO: ------------------------------------------------------------------------
12:07:47.728 INFO: EXECUTION FAILURE
12:07:47.728 INFO: ------------------------------------------------------------------------
12:07:47.729 INFO: Total time: 49.615s
12:07:47.806 INFO: Final Memory: 30M/128M
12:07:47.807 INFO: ------------------------------------------------------------------------
12:07:47.807 ERROR: Error during SonarQube Scanner execution
12:07:47.807 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 CFamily 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
  * you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps
  • Steps to reproduce:
    Try to cross compile a qmake project with an arm-gnueabi toolchain.

Hi @Faxe,

Sonarcloud pipe runs in a docker container, this is not compatible with C/C++ analyzer, the analysis should be ran at the same OS layer.

Yep they do in the same script

Hi @Faxe,

sonarcloud-scan pipe runs in a docker container, ie see https://bitbucket.org/sonarsource/sample-nodejs-project/addon/pipelines/home#!/results/152, you can see it in the logs of pipe: sonarsource/sonarcloud-scan:0.1.5. For C/C++ analysis the sonar-scanner should be ran at the same OS/container layer of the build, you should set it up manually without the use of pipe: sonarsource/sonarcloud-scan.

1 Like

I just tried it using the manual scanner in the pipeline, it works :smiley: . Thanks a lot, I have been trying to fix this the last two days.

1 Like

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