114341462 © Siriporn Kaenseeya | Dreamstime.com
Code Dreamstime L 114341462

Compiler Qualification is Critical for Smart-Device Code

Oct. 5, 2023
Qualifying a compiler is essential in today’s connected world. If a compiler isn't tailored for a specific use case, especially those that are safety-critical, the outcome will be less than optimal.

This article is part of the TechXchange: Developing High-Quality Software.

What you’ll learn:

  • Why is compiler qualification so important?
  • How use cases impact compiler development.
  • An example of improved development efficiency.

Due to the explosion in intelligent and connected devices, demand has ramped up for the code that drives them. There are many ways to generate code—you can write it, copy it, and have it made for you by advanced software tools. However, that code must be compiled to make it useful to the electronics that will be driven by it. Compilers involve quite a few layers of analysis and transformation, and changes in one stage are frequently amplified by subsequent stages.

This cascading effect makes compilers highly sensitive to configuration. Almost like a bad time-travel movie, apparently tiny changes to a compiler’s configuration can have a massive impact on the executable code generated. This issue isn’t a small one, because there’s no wiggle room in compiler qualification for safety-critical applications. A compiler that’s not specifically tailored for the exact use case or configuration at hand will not create an optimal solution.

Defining a Use Case

An application’s use case must address every factor that influences the translation of the compiler’s input, the application’s source code, into the executable code. The compiler version is also vital because virtually every compiler update is going to introduce subtle changes in the generated executable code.

Moreover, the use case is important to the compiler’s option settings, as each can potentially alter the compiler pipeline’s downstream behavior, which can create a cascading effect. This means a pre-qualified compiler is only appropriate if it’s qualified for that specifically defined use case.

Understanding the targeted version of the programming language is crucial, too. For example, a compiler configured to compile C99 code should be qualified following the C99 specification, not the latest C18 specification. While every option combination is different, there are permissible changes.

For example, GCC- and Clang-based compilers offer around a thousand options, but not every option changes the pipeline’s behavior. Diagnostic options related to compiler error messages typically don’t, say, change the output, but it could result in compile-time errors. Qualifying a compiler for a specific use case demands that you identify that use case properly, which is no trivial act.

Recently, BUGSENG analyzed the configurations utilized to compile the open-source Xen project hypervisor for x86-64 in the default configuration. It identified 40 different use cases, which involve three different versions of code. Luckily, not many safety-critical applications are this complex, but it’s important to remember that if you want to qualify your compiler, you must make sure you have your use case optimized ahead of time.

A BUGSENG Efficiency Boost

One example of boosting development efficiency with BUGSENG uses a CerTran extension to ECLAIR that integrates with Solid Sands’ SuperTest compiler test and validation suite. A versatile platform for the verification of C and C++ programs, ECLAIR applications include coding rule validation as well as computation of software metrics, checking interference among software components, and automatically checking for the absence of run-time errors.

C++ compiler qualification with SuperTest enables users to acquire a test suite with thousands of validated tests, which can be configured for their particular use cases.

The CerTran extension leverages ECLAIR’s functionalities, automating the configuration of SuperTest for compiler qualification by scanning the application build process and creating the exact test configuration files needed to cover all use cases. Such a solution can be incorporated into a continuous system, which can save a considerable amount of time as well as address configuration errors that easily occur when scanning the build process manually.

Read more articles in the TechXchange: Developing High-Quality Software.

Sponsored Recommendations

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!