Toolchain-wrapper: No such file or directory

Hi All

I’ve managed to get most of the way in setting up scanning of a project running in a Docker instance but I’ve hit a blocker with an issue with sonar scanner accessing the cross compiler. I’ll start with sime of the required info:

Versions:

  • Sonarqube server 7.7.0.23042
  • sonarscanner 3.3.031492

Trying to set up a scan of a C++ code base that is cross-compiling for an ARM in an Ubuntu 18.04 Docker container. I’m getting the errors below. I haven’t tried much to get past this as I don’t really know what’s going on here. I did some reading yesterday and I think the scanner needs to probe the compiler?

I can give more of the error log if it’s required.

10:35:29.812 DEBUG: Probing compiler: [/home/jenkins/workspace/lee-etp-dev/output/host/bin/toolchain-wrapper, -x, c++, --std, gnu++11, --sysroot=/home/jenkins/workspace/lee-etp-dev/output/host/arm-buildroot-linux-gnueabihf/sysroot, -v, -dM, -E, -]
10:35:29.839 DEBUG: stdout:

10:35:29.839 DEBUG: stderr:
/home/jenkins/workspace/lee-etp-dev/output/host/opt/ext-toolchain/bin/toolchain-wrapper: No such file or directory

10:35:29.856 INFO: ------------------------------------------------------------------------
10:35:29.856 INFO: EXECUTION FAILURE
10:35:29.856 INFO: ------------------------------------------------------------------------
10:35:29.856 INFO: Total time: 9.223s
10:35:29.906 INFO: Final Memory: 21M/114M
10:35:29.906 INFO: ------------------------------------------------------------------------
10:35:29.906 ERROR: Error during SonarQube Scanner execution
java.lang.NullPointerException
at com.sonar.cpp.analyzer.StdFlags.fromCppMacros(StdFlags.java:23)
at com.sonar.cpp.analyzer.ClangDriver.onCapture(ClangDriver.java:332)
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:266)
at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:198)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:62)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:359)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:354)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:317)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:128)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
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 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:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
10:35:29.907 ERROR:
10:35:29.907 ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
Build step ‘Execute shell’ marked build as failure
Archiving artifacts
Finished: FAILURE

Hi @leeerussell,

what version of the analyzer do you have installed? Could you please make sure you have version 6.4 of the analyzer? (That requires to use SonarQube server 7.9)

OK - I’ll upgrade the server.

Hi @leeerussell,

any news on that?

Hi @mpaladin

That seems to have fixed the issue I was having. Was there a fix somewhere that would have caused the issue I was seeing.

Hi @leeerussell,

not really, did you change the way you build your project?

No - the only thing I changed was updating to version 8 of SonarQube and checking the analysers were updated.

What may have been a problem I suppose - Sonar Scanner was the latest version running against version 7.7 of SQ?

Hi @leeerussell,

it is not the version of the scanner which makes the change but it is the version of the C/C++ analyzer which changes. We fixed several bugs in the past releases and from the first log you put at the beginning of the thread I was still expecting the error to appear with latest version.

Are you getting a proper and successful analysis of your code now?

Hi @mpaladin

I think I’m getting a complete analysis - the number of lines of code examined is certainly about right, but I would have expected more errors!

I’m still investigating. I’ll reply again if I find anything else.

Lee

Hi @leeerussell,

could you share the log of the analysis? You should have a line like saying XXX compilation units analyzed. How many? Does it correspond to reality?

@mpaladin - it says 82 compilation units analysed, which looks about right. The results in SonarQube say 37k C++ lines and 17k C lines, which both seem reasonable numbers.

Would you still like more of the log - or does the above answer the question?

Hi @leeerussell,

if this seems correct to you I don’t need more logs.

You can check the quality profile which is enabled for the project and eventually enable more rules.

Hi @mpaladin

I may need to start a new topic for this one - but I don’t see how to enable rules in C++? When I look at the sonar-way built-in rules for C I have 150ish rules enabled, but for C++ I have zero enabled? Is there a built-in set of C++ rules that should be enabled? Or do I need to create a new profile and add rules?

Thanks

And, when I click on “Activate New Rules” in my copy of the C++ rules I have zero options to add?

Hi @leeerussell,

for both C and C++ you have two SonarWay quality profiles. To add new ones you need to create one which extends from SonarWay, it will inherit all rules from SonarWay and you can enable/disable some of them.

@mpaladin I have no C++ rules to select. When I’ve done the above - I then select activate more rules, but there are none for me to select. If I search for C++ rules there are none.

Do I need to import them?

image