SonarScanner 5.0.1.3006 running native in Ubuntu / SonarQube server 9.9.5.90363
We are doing C compilation for STM32, Xilinx 7000, and Xilinix Ultrascale, all GCC based toolchains. Sonar scanner works great for the STM32 and 7000 project, but not for the Ultrascale. It’s seems like the toolchain can’t be found (at least it’s not in the logs). The build process for all three is very similar, similar paths, etc. Attached logs, thanks for any clues! build-wrapper-dump.json (252.0 KB) sonar-scanner.log (471.9 KB)
There should be a file named build-wrapper.log next to the json. Could you share it as well? There we should be able to see the compilations that were not written into the json.
Thanks Alejandro - here’s the reply I got from out IT team: We don’t have a server running that version of Sonarqube, we’re running the latest LTS version which is 9.9.5.
Is there another possible solution?
It seems we have trouble capturing the compiler invocation. I can reproduce locally using the same toolchain. From what I see, the compiler is invoked indirectly using ld-linux-x86-64.so.2, which we capture fine. But we wrongly capture the first argument of the executable, which should be ld-linux-x86-64.so.2 . However, we have the compiler as argv[0], which breaks the compiler probe on a later stage. In fact, we are also missing ld’s parameter --library-path.
I am trying to figure out why we miss the flags passed to the linker
Basically, the compiler is called via the dynamic linker, which, in addition to loading the shared libraries and the like, will also set up argc and argv so the loaded binary “sees” itself and not the loader.
Hence, we get the dynamic loader as executable but with the compiler arguments, which is why the probing fails.
As a workaround, if your build system supports generating compilation databases, you could use that option instead.