SonarQube Analysis fails for QNX, works for Linux

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube Server / Community Build, Scanner, Plugin, and any relevant extension):
    • SonarQube Enterprise Edition v10.7 (96327)
  • how is SonarQube deployed: zip, Docker, Helm
    • Don’t know, not relevant
  • what are you trying to achieve
    • I am trying to setup C/C++ scanning for QNX 7.1 files using CMAKE. GCC linux profile works, but QNX 7.1 profile has the error shown below.
  • what have you tried so far to achieve this
    • I have another project where I use the exact same setup with the exact same compiler (conan managed) and it works.
    • It uses the build-wrapper to create the .sq folder in a build job, then uses the data to run the analysis job.
    • Linux Release works perfectly fine, but changing to the QNX profile gives the error shown below.
13:29:37.618 WARN: Provided compiler is not compatible.
Invalid probe found, skip analysis of files: [/root/.conan2/p/sdk-xa5d4fb35bf0f8/p/x86_64-pc-nto-qnx7.1.0-g++, /builds/path/to/file.cpp]
The compiler probe 'stdout' is expected to contain at least one'#define' directive:

The warning above is thrown for all the cpp files it tries to analyze.

Then at the end we get this error:

13:29:39.048 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: The Compilation Database JSON file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:
  * you are correctly invoking the scanner with correct configuration
  * your compiler is supported
  * you are providing the path to the correct Compilation Database JSON
  * you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps
	at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:306)
	at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:183)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:64)
	at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:204)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:200)
	at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:173)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
	at org.sonar.scanner.bootstrap.SpringScannerContainer.doAfterStart(SpringScannerContainer.java:351)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
	at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:144)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at jdk.proxy1/jdk.proxy1.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
	at org.sonarsource.scanner.cli.Main.main(Main.java:62)
13:29:39.051 DEBUG: Cleanup org.eclipse.jgit.util.FS$FileStoreAttributes$$Lambda$399/0x0000000801301160@72725ee1 during JVM shutdown

After inspecting the stdout/stderr of the compiler probing we get this:

13:29:37.589 DEBUG: Probing compiler: [/opt/ccache-4.10.2-linux-x86_64/ccache, /root/.conan2/p/sdk-xa5d4fb35bf0f8/p/x86_64-pc-nto-qnx7.1.0-g++, -x, c++, --std, c++17, --stdlib, libc++, --sysroot=/root/.conan2/p/sdk-xa5d4fb35bf0f8/p/sdk/target/qnx7/x86_64, -v, -dM, -E, -]
13:29:37.617 DEBUG: stdout:
13:29:37.617 DEBUG: stderr:
x86_64-pc-nto-qnx7.1.0-g++: error: libc++: No such file or directory
Using built-in specs.
COLLECT_GCC=/root/.conan2/p/sdk-xa5d4fb35bf0f8/p/sdk/host/linux/x86_64/usr/bin/x86_64-pc-nto-qnx7.1.0-g++
x86_64-pc-nto-qnx7.1.0-g++: error: unrecognized command line option '--stdlib'; did you mean '-nostdlib'?
Target: x86_64-pc-nto-qnx7.1.0
Configured with: ../configure --srcdir=.. --enable-gnu-indirect-function=yes --enable-cxx-flags=-stdlib=libstdc++ --enable-cheaders=c_global --enable-initfini-array --enable-default-pie --with-as=x86_64-pc-nto-qnx7.1.0-as --with-ld=x86_64-pc-nto-qnx7.1.0-ld --with-tune=generic --prefix=/opt/qnx710/host/linux/x86_64/usr --libexecdir=/opt/qnx710/host/linux/x86_64/usr/lib --with-gxx-include-dir=/opt/qnx710/target/qnx7/usr/include/c++/8.3.0 --enable-threads=posix --enable-__cxa_atexit --enable-languages=c++ --with-sysroot=/opt/qnx710/target/qnx7 --target=x86_64-pc-nto-qnx7.1.0 --disable-nls --disable-tls --disable-libssp --disable-libstdcxx-pch --enable-libgomp --enable-shared --enable-multilib --with-bugurl=http://www.qnx.com --enable-default-ssp CC=x86_64-unknown-linux-gnu-gcc CFLAGS=-m64 LDFLAGS='-Wl,-s ' CXX=x86_64-unknown-linux-gnu-g++ CXXFLAGS=-m64 AUTOMAKE=: AUTOCONF=: AUTOHEADER=: AUTORECONF=: ACLOCAL=:
Thread model: posix
gcc version 8.3.0 20190222 (lookup) [qnx710 1535#57] (GCC) 
13:29:37.618 WARN: Provided compiler is not compatible.
Invalid probe found, skip analysis of files: [/root/.conan2/p/sdk-x.....

Hello

Environment:
SonarScanner 5.0.1.3006
Java 17.0.7 Eclipse Adoptium (64-bit)
Linux 5.15.167.4-microsoft-standard-WSL2 amd64

When running sonar-scanner with our qnx 7.1 compiler it wants to probe the compiler with:

Probing compiler: [x86_64-pc-nto-qnx7.1.0-g++, -x, c++, --std, c++17, --stdlib, libc++, --sysroot=[path]/target/qnx7/x86_64, -v, -dM, -E, -]

But errors out with:

x86_64-pc-nto-qnx7.1.0-g++: error: unrecognized command line option ‘–stdlib’; did you mean ‘-nostdlib’?

We do use “-stdlib=libc++” in our compiler arguments, and the compile_commands.json used by the sanner reflect this:


“-stdlib=libc++”,

But somehow the scanner translates “-stdlib=libc++” to “–stdlib libc++” (double dash and no equals sign) which the compiler clearly does not like.

Is this an error on our side or an error in the scanner?

Regards
Klaus