top | item 36859018

Practical comparison of ARM compilers

108 points| manchoz | 2 years ago |m0agx.eu

16 comments

order

tiniuclx|2 years ago

I've been using GCC & friends for a few years now, building mostly for the Cortex-M23. GDB has been a godsend, with a J-Link you basically have as much runtime debugging support as you would on a hosted system. This is especially helpful in cases where logging would slow down the operation of the system too much.

We're also very successfully using CMake as our build system, as opposed to Make itself. It lets you organise your build system & support different configurations & dependencies in a much easier way than e.g. Makefiles & Git submodules, which we've tried in the past. When combined with the Ninja generator we're also seeing ~20% faster compilation times.

cozzyd|2 years ago

gdb + J-Link is indeed a superpower. I sometimes leave in a static size buffer to provide some scratch space for abusing gdb as a repl for testing...

sigsev_251|2 years ago

You're lucky. I wish my vendor's proprietary toolchain was supported by CMake

nagisa|2 years ago

I have not seen a compiler that incidentally ICEs (crashes) more than IAR does (experience from c. 5 yrs ago.) Early-days rustc may come close, but experience is likely skewed by my perspective as a rustc contributor too.

And then we were always using IAR in a way that disabled all and every optimization; if enabling them did not lead to a compiler imploding, the compiler would produce invalid machine code even for trivial examples. This defeated any possible code size benefits that IAR may have had over GCC/Clang.

To top if off, I had an impression that reports of that nature weren’t really considered critical.

sigsev_251|2 years ago

Really? I would expect more than that from an EDG based professional compiler. A friend of mine uses the STM8 version in his workplace and he swears by it (though he still prefers SDCC due to C2x support)

nona42|2 years ago

For Armv8.M and MVE, I expect that Clang and Arm Compiler for Embedded, which is Clang/LLVM based, generates much better code than GCC or IAR.

Regarding code size: the common pitfall is -Os for GCC and -Oz for Clang based compilers to optimise for minimum code size.

cozzyd|2 years ago

Does the Arm Compiler for Embedded have significant changes to upstream clang? I'm somewhat concerned that clang not being GPL may eventually become unfortunate for embedded...

furtiman|2 years ago

In my experience arm clang compiler often times produced code that is ~10-20 percent faster (hence less energy consuming) than gcc with the same optimisation levels

(Building bare metal code with a lot of DSP and MATMUL)

powturbo|2 years ago

Yes, especially SIMD Neon where gcc producing horrible Neon code for all versions < gcc-12 even by using simd intrinsics. From version 12 gcc is at same level as clang.

You can try it : https://github.com/powturbo/Turbo-Base64

kevin_thibedeau|2 years ago

You don't need attributes for alignment anymore in a post-C11 world. It's much more advisable to use alignas and avoid vendor specific ifdef soup.

bottom999mottob|2 years ago

Gcov is great until higher-ups start demanding 100% line coverage, and you end up with hundreds of thousands of lines of unit tests. Then you gotta hire someone to check why the Jenkins builds are failing because some of your code isn't thread safe, and running the unit tests takes longer than compiling and taking a smoke break...

jeffreygoesto|2 years ago

I remember an ARM person stating: "We thought we're building those chips, who else could optimize for them better than us? Then we learned how little we know about C++ and the next version will be clang based.". That was back when we filed a number of RealView 4 compiler bugs...