Texas instruments compilers. ARMCL compiler support

Template for a good new topic, formatted with Markdown:

  • ALM used: Bitbucket Cloud

  • CI system used: Bitbucket pipelines and AWS Linux VM

  • Scanner command used when applicable: ~/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir /home/ubuntu/.sonar/bw-output ~/ti/ccs1200/ccs/eclipse/ccstudio -noSplash -data /home/ubuntu/workspace-ccs -application com.ti.ccstudio.apps.projectBuild -ccs.projects ccs-project-name -ccs.buildType full

  • Languages of the repository C

  • Error observed: “java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found empty.”

  • Steps to reproduce: run build-wraper and then sonnar-source

  • Potential workaround: Do not use ccstudio wrapper and try directly with the compiler

Hello,

I want to know if there is any way to support ti-cgt-arm compiler. I saw this ticket CPP-2094 which marks as closed the support for armcl compiler. But I do not know if it is supported by SonarCloud.

Also, I reviewed this community and I saw some topics regarding Texas Instruments compilers, someone use the eclipse.exe wrapper and works, others directly calls to gmake and there is also the possibility to dump to compilation database. However, I do not know if it is possible in my case and how.

Can you help me?

Best regards,

Welcome to the community @Javier!

Thank you for the report, and very thoughtful investigation.

As you mentioned, we are currently supporting armcl compiler, but please note that Texas Instruments recently released a clang-based version of this compiler that uses tiarmclang name for binary, which is not currently supported. Could you please check which version of the Texas Instrument compiler you are using?

For the error itself, it means that the build-wrapper file was properly generated, however, build-wrapper didn’t recognize any of the compiler invcations. This may be caused by multiple reasons, and for the purpose of the investigation, it would be best if you could share logs and JSON files produced by build-wrapper dir (there are /home/ubuntu/.sonar/bw-output in your case). If you think this file contains private information, let us know, and we’ll send you a private message that will allow you to send it privately.

Hello @Tomasz_Kaminski ,

We are currently using “TI ARM C/C++ Compiler v16.9.6.LTS”. By the moment we are not currently interested in tiarmclang compiler, thanks for the warning.

I prefer to share with you these files privately, how can I send them?

Regards

@Javier. I have noticed that you are using the armcl compiler on Linux. This operating system is currently not supported by the Texas Instruments compilers (SonarCloud docs).

This is effect of build-wrapper using a dynamic library loaded with LD_PRELOAD in order to observe compiler calls. That means that cannot observe statically linked binaries, as it is the case of armcl distribution. to work around this you can

  • have a small bash wrapper with the same name armcl which simply calls the real armcl, this should allow build-wrapper to observe the bash call and fetch the configuration
  • If above option is not feasible and you can generate a compilation database for your project, you can use it instead of build-wrapper: SonarCloud docs.

I have created CPP-3975 for the purpose of recording this request for supporting such use cases, and tracking any such request in the future.

Hello @Tomasz_Kaminski ,

I was trying the first approach that you mentioned, as it looks more straightforward. But I did not success, I had the same error as before, build-wrapper-dump.json is empty.

What I did is the following:

cp /home/ubuntu/ti/ti-cgt-arm_16.9.6.LTS/bin/armcl /home/ubuntu/ti/ti-cgt-arm_16.9.6.LTS/bin/armcl-or
vim /home/ubuntu/ti/ti-cgt-arm_16.9.6.LTS/bin/armcl

And I did the following script:

#/bin/bash
arguments="$*"
/home/ubuntu/ti/ti-cgt-arm_16.9.6.LTS/bin/armcl-or ${arguments}

The compilation time and the outputs looks fine but Sonar Scanner continues complaining… If I understood well I did the correct steps, but I am not sure if there are all of them…

Any ideas?

Best regards,

As an update, for a workaround, a bash script is not sufficient, and replacing an armcl with a binary wrapper is necessary. A one compiled from the following program may be used:

#include <unistd.h>

char* binary = "/home/ubuntu/ti/ti-cgt-arm_16.9.6.LTS/bin/armcl-or";

int main(int argc, char* argv[]) {
  argv[0] = binary;
  return execv(binary, argv);
}

In this particular case, doing so exposed crashes in analysis.