This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Compile SDK11 with ARM Compiler Version 6

I would like to use the latest ARM Compiler Version 6 (armclang) because I need some features of the C++11 language.

Is it possible to use the latest ARM Compiler Version 6 to compile the SDK 11 ? Which flags should we use to be compatible with all macros currently available for GCC and armcc ?

In future SDK releases, will this compiler be officially supported ?

Parents Reply Children
  • I have tested both armclang and clang-3.8, and can confirm what you state, RK. It will optimize away something (arguments in registers R0-R3 I assume?) in the SVC-calls. You can get around this with "optnone" attribute to the SVCALL macro, but that's not a proper workaround in my mind. Cheers, Håkon.

  • unfortunately even optnone doesn't work in many cases, the clang optimiser is very aggressive and because there's nothing saying the arguments are used at all, even if it leaves them alone in the function itself, it often just doesn't even set them up for the call.

    I've been through every single option clang has for trying to control this and not one works at high optimisation levels properly.

    What's needed, unfortunately, is for the SVCALL macro to expand to have some more information, eg the count of parameters, in that way it's possible to have different stubs for different argument counts and reference that the arguments are used (and that r0 contains the return).

    Arguably clang is actually right here and gcc is sort of wrong, but that doesn't really help!

  • I noticed the same thing when trying -O2 or -O3. -O1 worked fine, anything over this failed (including Os/Oz). I really like clang as a compiler and the features that it provides, and I'll try to push for a deeper investigation of the llvm toolchain internally. Since Keil v5.20/DS-5/SES all have the option to use llvm, it will become more widespread in the near future.

  • that would be very welcome. I have actually done this work some time ago, it was just too manual to keep up but I'm happy to share anything I still have if you want it. It's going to be a one-time pain thing to come up with a version of SVCALL which works, all my other testing with clang showed up no other issues than that although any use of __asm() probably needs auditing because inline assembler is treated quite differently from gcc, any other assembler in .s files, will be fine.

    Segger Embedded Studio also has a clang option, so that's another product people are going to see a clang option and try it out.

    clang is a nice compiler, it can do some very clever optimisations although it's better at making fast code than small code in my limited experience. These days with the wonderful amount of flash we get to play with it's less of an issue.

  • @Nordic Any plan to officially support the ARM Compiler Version 6 for the next SDK releases ?

Related