[sdiy] Some Audio DSP prototypes

Mike Bryant mbryant at futurehorizons.com
Fri Apr 22 10:59:06 CEST 2022

> From: Synth-diy [mailto:synth-diy-bounces at synth-diy.org] On Behalf Of Gordonjcp

> So LLVM is only better than gcc if you take the risk of using a proprietary version that could be dropped at any time, leaving you in the same situation as all the PIC developers?

Not at all.  Firstly in professional environments counted by seats, LLVM is now the world's standard compiler nowadays so it's going nowhere.  Even Intel are switching to it after maintaining their internally developed Intel Compiler as the best x86 compiler for about 40 years.  Similarly TI, Qualcomm and others are making it the only supported toolset for their newest devices.

Even for hobbyists the growing number of Mac users makes sure it is well represented there as well, although I accept gcc is still the standard amongst hobbyists as it's so well entrenched, and amongst Linux OS builders as gcc is tested and optimised on that.

The open source version Clang compiler gives better code than gcc in almost all situations, but if you want code optimised to the n'th degree for a particular platform then you are better off paying for the specific version you need as it will have all the latest improvements.  And as ARM is the world's most widely used processor, I think there is zero chance of them dropping ARMcompiler.   When they switched from their homegrown effort to LLVM around 2014/15 they made sure old code still compiled.  This back-compatibility is one of the differences between ARMcompiler and Clang.  The other is the use of the ARM vector processors.  If you use these a lot then you probably need the paid for version otherwise you're likely going to be using similar long-winded kludges to those needed with gcc.

In fact I think the version more at risk of being dropped are the pre-built gcc builds on the ARM website (with the long -eabi type names) as they take effort to maintain for little gain to ARM so they may leave those who still want these to build these themselves in future.  ARM recently released the open source LLVM Embedded Toolchain for ARM and if you look at their website just the effort spent on the more attractive webpages would indicate this will be their standard free offering going forward.

> Out of interest, how hard is it to switch from gcc to LLVM, for fairly standard C code with odd sprinklings of assembler?  How much would I need to change?  If it's something fairly straightforward that a couple of #ifdefs can cope with it'd be nice to give folk the choice.

It really depends how deep you've gone into using all the special gcc optimisations.  If you just have -0x on the command line then it's usually under a day's work.  Clang will accept some of the gcc methods of including assembly code, but not all.  But if you've spent months tuning your code to get the best from gcc then unfortunately it will be a lot more effort.  And if you use the RP2040 toolset RPL supply it's f-word impossible as they've deliberately locked their SDK into unique gcc features.

As I said there are some situations where gcc can still give better results, although I think this is often because those developers have years of experience getting the best out of gcc and are still learning how to use Clang.  Some SMEs thus make sure their code compiles on either.  

I'd recommend to anyone to just load the open source version of Clang and give it a try.  Then if you like it, download the free month's trial version of ARMcompiler to see if the improvement is worth it to your company financially.

More information about the Synth-diy mailing list