The "build-wrapper-dump.json" file was found but 0 C/C++/Objective-C files were analyzed

Hello!
I’m trying to run code analysis for a new project using sonar-scanner. The building using a build wrapper is successful.
And before code analysis, I get this error:

18:08:13.919 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: 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
	at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:494)
	at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:215)
	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:188)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:403)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:399)
	at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:368)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
	at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:137)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
	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 com.sun.proxy.$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)

Before this error, I also got several WARNs like:

18:08:13.805 WARN: Invalid probe found, skip analysis of files: [/home/jeremy/Product/Mulan 2/framework/base/shell/src/cmd.c]
The compiler probe 'stdout' is expected to contain at least one '#define' directive:

I double confirmed ‘#define’ do exist in these files.

Steps:
1> git clone the project to local disk of Ubuntu 22.04 desktop;
2> The sonnarqube version is 9.9, the latest LTA version.
And build wrapper v6.41

$ /home/jeremy/sonarqube-9.9/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --version
build-wrapper, version 6.41 (linux-x86)
Copyright (C) 2014-2022 SonarSource SA, info@sonarsource.com

Usage: /home/jeremy/sonarqube-9.9/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir <output directory> <build command>

sonar scanner v4.8.0.2856

$ /home/jeremy/sonarqube-9.9/sonar-scanner-4.8/bin/sonar-scanner --version
INFO: Scanner configuration file: /home/jeremy/sonarqube-9.9/sonar-scanner-4.8/conf/sonar-scanner.properties
INFO: Project root configuration file: /home/jeremy/Product/Mulan 2/sonar-project.properties
INFO: SonarScanner 4.8.0.2856
INFO: Java 11.0.17 Eclipse Adoptium (64-bit)
INFO: Linux 5.19.0-40-generic amd64

3> Ran build wrapper via command:

$ /home/jeremy/sonarqube-9.9/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir ../../bw-output scons -j64

This building step was completed successfully, and the directory bw-output with files build-wrapper.log and build-wrapper-dump.json appeared.
Then I ran the sonar scanner step with -X via command:

$ /home/jeremy/sonarqube-9.9/sonar-scanner-4.8/bin/sonar-scanner -X -Dsonar.projectKey=Mulan-2   -Dsonar.sources=.   -Dsonar.cfamily.build-wrapper-output=bw-output   -Dsonar.host.url=http://localhost:9000   -Dsonar.login=sqp_a175784aa687d7411d96937f4ef182445ee56814

And after that, I got the error that I described above.

About the questions:

  • you are using the latest version of the build-wrapper and the CFamily analyzer
    • Yes, I am using the latest LTA version.
  • you are correctly invoking the scanner with correct configuration
    • Yes, I think so, as I used the same configurations and steps for the previous project, never met this issue before.
  • your compiler is supported
    • The current gcc compiler I am using is:
$ ./tools/gcc/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Arm Embedded Toolchain 10.3-2021.10) 10.3.1 20210824 (release)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  • you are wrapping your build correctly
  • you are wrapping a full/clean build
    • Yes, I use the same commands for my previous project on the same machine, and everything works properly there, and I tried running cleaning before git clone & build & code analysis
  • you are providing the path to the correct build-wrapper output directory
    • Yes, the path is correct.
  • you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps
    • Yes, I’m building and analyzing absolutely the same source checkout in the same directory. I also tried the identical absolute path in build and analysis, but the results are same as the above error.

I saw a few similar issues on the community forum, but I couldn’t find a solution. I am sure the building and analyzing absolutely the same source on the same computer, no docker, no cloud. The recent projects are almost the same structure but never met this issue before.

I attached the below files here, hope they will be helpful:
1> build-wrapper-dump.json
2> build-wrapper.log
3> sonar-project.properties
4> analysis.log
5> scan logs
sonarlog_buildwrapper_20240508.zip (5.6 MB)

Thank you very much in advance!

Hello @Jeremy1 ,

I am afraid you have hit a bug in our probing of the compiler. See [CPP-5313] - Jira

In summary, we forward -mfloat-abi=hard to GCC, but we do not forward -march=armv8.1-m.main+mve.fp+fp.dp. The compiler defaults to the cpu arm7tdmi, which has no FPU support, and errors out.

As a workaround, explicitly adding -mcpu when compiling may fix the issue, as that one we do forward. For instance, when probing with -mcpu=cortex-m55 we get the macros, and the compiler figures the arch by itself (-march=armv8.1-m.main+fp.dp+mve.fp), so we will get meaningful predefines.

Please, let me know if this helps.

Thanks so much!
I tried the solution you provided, it really works!
This issue blocked our progress for several days. You really gave us so big support. Thank you again!

1 Like