Incorrect abi detected during sonnar-scanner probe (for -mabi=ilp32)

Language C

Cross-compiling to riscv64-unknown-elf-gcc -march=rv32i -mabi=ilp32

Hi,

I’m using sonarqube to analyze a riscv elf build with -march=rv32i, -mabi=ilp32

Build-wrapper-win is working and in the compile_commands I see:

"arguments":[
"riscv64-unknown-elf-gcc",
"-march=rv32i",
"-mabi=ilp32",
"-msmall-data-limit=8",
"-mstrict-align",
"-mno-save-restore",
"-O2",
"-fmessage-length=0",
"-fsigned-char",
"-ffunction-sections",
"-fdata-sections",
"-Wall",
"-Werror",
"-g3",
...

Which is fine.

However, when I use sonar-scanner -X seems the march is correctly detected but not the mabi during probing the compiler.

11:24:47  08:24:47.239 DEBUG Java memory after lexical analysis (used, peak): 77, 169
11:24:47  08:24:47.263 INFO  Compilation database was generated by build-wrapper 6.70.1
11:24:47  08:24:47.284 DEBUG Probing compiler: [riscv-unknown-elf-gcc\bin\riscv64-unknown-elf-gcc.exe, -x, c, --std, gnu11, -march=rv32i, -v, -dM, -E, -]
11:24:47  08:24:47.478 DEBUG stdout:
11:24:47  
11:24:47  08:24:47.478 DEBUG stderr:
11:24:47  Using built-in specs.
11:24:47  COLLECT_GCC=riscv-unknown-elf-gcc\bin\riscv64-unknown-elf-gcc.exe
11:24:47  Target: riscv64-unknown-elf
11:24:47  Configured with: riscv64-unknown-elf-gcc-8.3.0-1.1/sources/riscv-gcc-8.3.0-1.1/configure --prefix=riscv64-unknown-elf-gcc-8.3.0-1.1/win32-x64/install/riscv64-unknown-elf-gcc --infodir=riscv64-unknown-elf-gcc-8.3.0-1.1/win32-x64/install/riscv64-unknown-elf-gcc/share/doc/info --mandir=riscv64-unknown-elf-gcc-8.3.0-1.1/win32-x64/install/riscv64-unknown-elf-gcc/share/doc/man --htmldir=riscv64-unknown-elf-gcc-8.3.0-1.1/win32-x64/install/riscv64-unknown-elf-gcc/share/doc/html --pdfdir=riscv64-unknown-elf-gcc-8.3.0-1.1/win32-x64/install/riscv64-unknown-elf-gcc/share/doc/pdf --build=x86_64-unknown-linux-gnu --host=x86_64-w64-mingw32 --target=riscv64-unknown-elf --with-pkgversion='xPack GNU RISC-V Embedded GCC (Microsemi SoftConsole build)\x2C 64-bit' --with-bugurl=https://github.com/sifive/freedom-tools/issues --enable-languages=c,c++ --enable-mingw-wildcard --enable-plugins --enable-lto --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-threads --disable-tls --enable-checking=yes --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-riscv64-unknown-elf --with-sysroot=riscv64-unknown-elf-gcc-8.3.0-1.1/win32-x64/install/riscv64-unknown-elf-gcc/riscv64-unknown-elf --with-native-system-header-dir=/include --with-abi=lp64d --with-arch=rv64imafdc --disable-rpath --disable-build-format-warnings --with-system-zlib
11:24:47  Thread model: single
11:24:47  gcc version 8.3.0 (xPack GNU RISC-V Embedded GCC (Microsemi SoftConsole build), 64-bit) 
11:24:47  COLLECT_GCC_OPTIONS='-std=gnu11' '-march=rv32i' '-v' '-dM' '-E' '-mabi=lp64d'

Is there any solution to pass the correct -mabi or fix probing?

Note, it seems to be a regression with 6.70, but before this, it was “working” because probing was not correctly detecting -march:

`‘-march=rv64imafdc’ ‘-mabi=lp64d’` instead of correct abi/arch

Hi,

Welcome to the community!

What version of SonarQube are you using? And can you add -Dsonar.verbose=true to your analysis command line and post the log, redacted as necessary?

 
Thx,
Ann

it’s sonar server v2025.4.4 (119049) with SonarCLI 7.3.0.5189

(Note: 5.0.1.3006 was ““““working””” as it was not detecting -march or -mabi (`‘-march=rv64imafdc’ ‘-mabi=lp64d’`) )

I can give verbose output, but what log should I seek for? Because basically, every steps seems fine except the sonar-scanner compiler probing that pass an incorrect – with-abi/–with-arch resulting in an incorrect COLLECT_GCC_OPTIONS (march=rv32i, mabi=lp64d).

Hi,

Presumably this happens as part of the sonar-scanner command right? That’s the log I’m looking for.

 
Ann

Ok I got an answer from a parallel channel nad it’s indeed a bug.

-mabi is not supported yet by sonar and there is a new ticket opened to address this gap. -march only is supported.

There is however a workaround. Do notuse compile-commands, but auto config (Analysis modes | SonarQube Server | Sonar Documentation)

In this case it works

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.