Embedded Development | Methods to Improve MCU Code Compilation Speed

Follow+Star Public Account, don’t miss wonderful content

Embedded Development | Methods to Improve MCU Code Compilation Speed

Author | strongerHuang

WeChat Public Account | strongerHuang

Programmers doing software development hate one thing, which is the slow code compilation speed.
Code for one minute, compile for ten minutes, who can stand that?
Embedded Development | Methods to Improve MCU Code Compilation Speed
Today, let’s talk about some common operations or methods to improve compilation speed in embedded software development.

Upgrade to a Higher Configuration Computer

What most people think of first is: upgrading to a higher configuration computer.

This is one of the methods, but how many companies are willing to provide you with a new computer?
So, this method is not practical.
Embedded Development | Methods to Improve MCU Code Compilation Speed

Reduce Compilation Output Files

Some unnecessary debugging and browsing information files can be excluded from the output during compilation, such as:

1.Keil MDK

Project -> Options for Target -> Output/Listing:

Embedded Development | Methods to Improve MCU Code Compilation Speed

The configurations here will affect the compilation speed, especially the Browse Information. If you use the Go to Definition Of feature, you will need these types of files.

If checked, it will output some “intermediate compilation files”, and you will have many intermediate files in your set output path (default “Listings” and “Objects”) that will occupy compilation time during the compilation process.

The content and function of these files can be referenced in the article:Keil Series Tutorial_File Types and Related Descriptions

2.IAR EWARM

Similar to Keil MDK, IAR also has related output file configurations, such as:

Project -> Options -> C/C++ Compiler -> output:

Embedded Development | Methods to Improve MCU Code Compilation Speed

There are many configurations related to compilation in the configuration information that will affect the compilation speed.
For various file types in IAR, you can refer to the article:IAR Series Tutorial_File Type Descriptions
3.Command Line
If you use the command line to compile code, this problem can be avoided. You can input the corresponding commands for compilation, linking, and debugging according to your needs.
For example:
gcc test.c -o test
Of course, using the command line requires memorizing the usage of various commands.

Change the Compiler Toolchain

This is different from changing the computer: changing the compiler is just a software tool, no need to see the boss’s face.

For example:

Upgrading Keil MDK from AC5 to AC6 will greatly increase speed.

You can also change the MDK compiler to gcc compiler:A Step-by-Step Guide to Using GCC Compiler Toolchain in Keil MDK

Related articles can be referenced:

Understanding the AC6 Compiler

Differences in Browse Information Generated by Compilers AC5 and AC6

Important Content and Differences in Optimization Options Between AC5 and AC6

Optimize Code

For embedded code, most are written in C/C++, and all have #include xxx.h header files.

If header files are repeatedly and multilayered included, modifying one header file will require recompilation of all related header and source files, which will also affect compilation speed.

Similar to the image below, if you modify the bottom file, all upper files need to be compiled again:

Embedded Development | Methods to Improve MCU Code Compilation Speed

Recommended reading: Several Methods and Key Points for Referencing Header Files in Software Projects

Finally, everyone is welcome to add more effective methods to improve compilation speed.
———— END ————
Follow the public account and reply Embedded DevelopmentMicrocontrollerEmbedded C Language to read more related articles.
Reply “Join Group” to join the technical exchange group according to the rules, reply “1024” to see more content.

Embedded Development | Methods to Improve MCU Code Compilation Speed

Embedded Development | Methods to Improve MCU Code Compilation Speed

Click “Read Original” to see more shares.

Leave a Comment