Support for Microchip xc8

Hi all,

after reading the release notes of version 10.0, I understand that the Microchip xc8 compiler is now supported. Ticket CPP-4022 mentions this is included in 6.42, and SonarQube 10.0 seems to come with 6.43.

Now I’m trying to get build-wrapper to catch the compilation, which uses GNU make and the compiler binary xc8-cc, as I did successfully with SonarQube 9.6 and xc32 (which is gcc based, so already worked before).

But so far I can’t get build-wrapper to catch the compile commands, build-wrapper-dump.json always comes out empty and the log seems to not really see the invocation of xc8-cc. The log always looks like this:

Tue Apr 11 09:02:07 2023: process created with pid: 2012
Tue Apr 11 09:02:07 2023: parent pid: 1918
Tue Apr 11 09:02:07 2023: working directory: </home/koop/projects/C-Board/Application.X>
Tue Apr 11 09:02:07 2023: executable: </bin/dash>
Tue Apr 11 09:02:07 2023: argv[0]: </bin/sh>
Tue Apr 11 09:02:07 2023: argv[1]: <-c>
Tue Apr 11 09:02:07 2023: argv[2]: <"/opt/microchip/xc8/v2.41/bin/xc8-cc"  -mcpu=18F46K80 ... >
Tue Apr 11 09:02:07 2023: skipping process with pid: 2012

It looks like only the start of the shell dash is seen, where xc8-cc is passed via the -c argument, but not the start of xc8-cc. I also saw calls to xclm, the licence manager, and noticed that that binary has the suid bit set, so maybe the build-wrapper cannot inject into that process. But removing the suid bit made no difference.

Am I maybe mistaken that xc8-cc is fully supported in SonarQube 10.0?

I’ll try to attach the full log.build-wrapper.log (264.9 KB)

Hi @kkoop, and thanks for your question.

You are right, xc8-cc support on Linux and macOS is a bit tricky. The reason is that xc8-cc invokes statically linked executables that can’t be captured by build-wrapper. You have two options:

  1. Either run the analysis on a Windows machine. This works because build-wrapper on Windows is not limited to dynamically linked binaries.

  2. Or, if relevant to your project, you can analyze on Linux or macOS using a build configuration with an AVR -mcpu. This works because the aforementioned statically linked executables are used by the current version of xc8-cc only when compiling for PIC devices.

Please note that the second approach may break with future versions of xc8-cc, so the first approach is preferred.

Hope this helps…

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