Must-share information (formatted with Markdown):
- SonarScanner 4.7
- scan my code on debian11 32bit
- (see below)
I have some C\C++ codes for 32bit x86 machine and I compile it on 32bit debian VM. When I try to run scanner it show below error:
will@debian:~/C2/sonarqube/FrameApplication$ build-wrapper-linux-x86-64 --out-dir bw-output make
-bash: /home/will/C2/sonarqube/build-wrapper-linux-x86/build-wrapper-linux-x86-64: cannot execute binary file: Exec format error
I know that I could compile code on 64bit machine even it will fail to generate binary file but still could do the scan for “.o” file.
However if my codes need to link 64bit library or need some kernel related file it will fail.
Is there any workaround for this situation?
Welcome to the community @nonikka!
We do not support running the analysis on x32 bits systems (per docs). As an alternative, you may try to prepare cross-compilation to build your project on x64 system for x32 target (
-m32 flag for GCC), and perform analysis on such build.
Cross-compilation is an option, but for some situation like we need to modify and replace the kernel before compile, it will be some kind of complicate to do the cross compile for scan.
Unfortunately, we do not have plans to reintroduce support for running scans on the 32bits OS, so running an actual scan in a 64bit OS environment is unavoidable.
As I already mentioned, one option is cross-compilation. Note that for the scanner to work correctly it is not necessary to link the final executable. Building an object file from each cpp source should be sufficient.
As an alternative, that can be seen more as the hack. If you will be able to produce a compilation database file on VM, then it may be possible to perform analysis on 64bit environment, but with key limitations:
- code, compiler, and the included search directories (including system libraries) need to be placed under exactly the same paths in both build VM and scan machine
- the size of the types may be detected incorrectly, and some rules may produce FP of FN due to that fact (that may need to be disabled).
In other words, this option may be a way to get some of the analysis results, but they will have worse quality than proper cross-compilation.
Thanks very much, Tomasz.
I think I should try to make the cross-compilation work, at least let the wrapper get the object file list.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.