GO+C: Empty build-wrapper-dump.json

Hi!
I have a GO package like this

    package main
    
    //#include "hello.c"
    import "C"
    
    func main(){
      C.hello()
    }

which call C code from hello.c

    #include <stdio.h>
   
    void hello(){
      printf("Hello, world!\n");
    }

And when i run command to build

    build-wrapper-linux-x86-64 --out-dir . go build main.go

I get binary file “main” ( it works great! ) and empty file “build-wrapper-dump.json”

    # (C) SonarSource SA, 2014-2021, info@sonarsource.com
    # All SONARSOURCE programs and content are copyright protected.
    # SONARSOURCE and SONARQUBE are trademarks of SonarSource SA. All rights are expressly reserved.
    #
    # This file is designed exclusively for use with the SONARSOURCE C / C++ / Objective-C Plugin.
    # It may not be used in connection with any other software.
    # Any other use is prohibited by law and may be grounds for immediate termination of your License.
    {
    "version":"6.28",
    "captures":[
    ]}

How can I analyze my C code in such projects? Thanks.

Hello @Maxim,

I’m afraid that you are affected by the same issue that is reported in this ticket. As far as I understand, the way the Go tool launches the C compiler cannot be seen by the build wrapper.

One workaround for you might be to generate a compilation database, but I don’t think there is anything in the Go ecosystem to do that, so you would be on your own.
Another option might be to also compile those files independently from the Go files (for instance with cmake), and run the build wrapper on this extra build.

Hi @JolyLoic, thanks for your reply.