15

I'm about to develop some firmwares for Cortex-M cores on STM32 processors using C for my projects, and searching on the web I've found a lot of different compilers: Keil, IAR, Linaro, Yagarto and GNU Tools for ARM Embedded Processors.

I was wondering, what functional differences are there between these compilers that might influence my choice? For example as an enthusiast I don't need support or assistance from the vendor, and a limitation on the code size is OK for the moment. Also the ease of use is not a main concern since I like to learn (and for the moment I have both Keil Lite and Eclipse with GNU ARM configured and working).

Is the generated code so different in terms of size/speed between these compilers? Are there any comparison table? (I've found only stale infos on the web)

4
  • Is your main concern learning? Then why do you care about performance of the compiler? Linaro and Yagarto are two version of gcc (different libraries). I would choose the last one you linked to. Speed/Size numbers are always based on the synthetic benchmark. Take/make your code and compile with different compilers. Generally they way you code will reflect results more than the compiler. Ie, the same algorithm with different 'C' implementation. Jan 12, 2015 at 22:20
  • My main concern is obviously learning, but performance is not a bad thing to achieve (and a lot of fun working into). However I'll follow your suggestion taking the same code to different compilers and I'll check on which one I get more familiar. Thanks for the comment Jan 13, 2015 at 16:38
  • 1
    The question is equally valid outside of a learning context, so please don't dismiss it with "it doesn't matter which one you pick if you are learning". I am not learning, but my question is very similar and I would like to know for example whether the commercial options provide significant performance or code size differences over the GNU ARM toolchain. Oct 12, 2016 at 10:29
  • Raisonance AN0052 has a comparison. This question will have stale information (why it would be dismissed) as the compilers are constantly evolving. GCC is near (or better) performing than commercial compilers in many respects. There are many different ways to 'benchmark'. Oct 29, 2016 at 14:30

3 Answers 3

6

benchmarking is an artform in and of itself, usually easy to manipulate the results to show whatever you want. I would not expect the compilers to generate the same results except for very small test cases, and sometimes in those small test cases their results are either identical or sometimes vastly different as your test has exposed an optimization that one compiler knows/uses and one the other doesnt.

I used to keep track of such things (compiler performance numbers) with dhrystone for example, but in the case of known benchmarks (not that dhrystone means much anymore, but others) you may find that some compilers are tuning themselves to look good under benchmarks perhaps at the expense of something else.

There is no right answer, there is no universal "best", it is all in the eye of the beholder, you. Which tool is easier for you to use, which do you like better be it for the gui or pretty colors or sound card sounds or whatever. And go from there.

The gnu compiler generally for applications I have tested does not produce code as "fast" which is my benchmark, compared to the others, but there are way more people using the free gnu tools so the support for it is considerably wider due to the number of web pages and forums and examples. gnu wont have a size restriction either, but it may require more learning or whatever to get up and running...

The cortex-ms are split into the armv6m and armv7m families, the v6m (cortex-m0) only have a small number of thumb2 extensions, the armv7m have about 150 thumbv2 extensions to thumb, so you need to know what your tools support and not use the wrong stuff on the wrong chip. Then the compilers if they know all of this may and will produce different instruction mixes from the same source code. Further within the same compiler or family using different command line options you can/will get vastly different code. And then beyond that with a cortex-m4 with cache on if you have one with such a thing, depending on how the code lies in the cache lines you may get vastly different performance, so benchmarking is a research project in itself for each blob of C code you want to benchmark. The performance range within a single compiler may shadow another compiler or the overlap may be enough to not matter.

If you have access to the tools you add value to yourself professionally by learning to use the competing tools and being able to walk into a job and or within your job choose what you see as the right tool for the job or walk into a Kiel house and be able to work right away or a gnu house and work right away. Where you might lose a job if you are gnu only and the job is for a Kiel house.

1
  • Thanks for the extremely detailed comment! I'll check compatibility on thumb2 extensions and support for compilers, I'll let you know where I'll land Jan 13, 2015 at 16:40
5

We have done some comparisons; IAR and Keil typically outperform GCC with default settings. But with some compiler flags you can make GCC come pretty close to the result of IAR and Keil.

Some of the compilers you mention are integrated development environments. Others are just plain compilers. Some people prefer a integrated environment with compiler, editor and debugger nicely packaged for you. Others prefer to set up their own environment. It is a matter of taste.

In addition to Yagarto, there is also the "Code Sourcery" distribution of GCC for ARM.

3

Performance should not be your first concern unless when it becomes so in a production environment. The reason is that first, most ARM compilers are plenty good enough, and really you are down to GCC based, Keil, and IAR. Second, most ARM MCU are "blazingly fast" and have "so much memory" (these are comparing to 8-bit MCU like AVR/PIC but also to older PC). A decent Cortex-M4 MCU runs up to 100MHz and has 256K of flash. Again, to put it in perspective, that's more memory and 10x faster clock rate than the original Macintosh etc. We went to the Moon with much less ;-)

Now the performance of the tools itself, in particular, the IDE and the debuggers, differ greatly. For example, the popular Eclipse is written in Java, might be a bit sluggish to slower or memory-starved PCs. The best thing to do is to install GCC+Eclipse, and the vendors' demos and see for yourself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.