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.

Hello @pastrana,

Sorry for the late reply.

Unfortunately, we do not support the compiler version you are using, as it is a fairly old version (5 years old).

We have a ticket (CPP-3940 Report a clearer error when compiler probes doesn’t contain the required macros) to improve the error message in such cases.

And we have another one (CPP-2906 Add support for old versions of Texas compilers) to add support for old versions of Texas compilers. I have added your version.

One way to resolve your issue is to upgrade your compiler to a more recent version. Is that possible for you?

Have a nice day,
Amélie

Hello @Amelie ,

Sorry for the late replay, I was doing some tests.

It is not a problem update the compiler, we can use the last available.

Now it looks that is working, but I have to test it extensively.

I will post my analysis next week.

Thanks for the effort.

And have a nice day,

Javi

1 Like

Hello @Tomasz_Kaminski and @Amelie ,

I was doing some test during the last days and below you can find my conclusions:

  • I updated the TI compiler to 20.2.6 LTS version.
  • I compiled the following code as a suggestion of @Tomasz_Kaminski
#include <unistd.h>

char* binary = "/home/ubuntu/ti/ccs1200/ccs/tools/compiler/ti-cgt-arm_20.2.6.LTS/bin/armcl-or";

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

Then I renamed the orginal armcl to armcl-or and finally I placed the new binary in the following path:
~/ti/ccs1200/ccs/tools/compiler/ti-cgt-arm_20.2.6.LTS/bin/armcl

By this way I can see the results in Sonar Cloud, as I can dive into the code and see the results of my project. However, I have a new issue and I do not know if it is related to the previous or not.

I always see the results in the same branch “release”

If I scan develop branch, even if I open a pull request it does not appear. I checked in the host the current branch and it is fine. Any suggestions?

Best regards and thank you for the huge effort,

Hello,

As I can see the problem is related to the following variables:

  • sonar.branch.name: The name of the branch that was analyzed.
  • sonar.branch.target: The name of the target branch of the branch that was analyzed.

It should be a different topic as the original of this post. We can close it then.

Regards.

1 Like

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