Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52 development using clang

Hello, 

We are running a pretty massive nRF52832, SDK14.2, softdevice5.0.0, freertos based project built using Keil's "default compiler version 5"

For various reasons we are considering moving to llvm clang compiler either in SES environment or using Keil V6 compiler (which I understand is clang)

My questions are:

  1. I've seen some pretty old posts (e.g. RK's comment here, and here) that the app breaks/softdevice calls not supported when using clang compiler. Is this still the case?
  2. Is there a (reasonably) easy way to make the project clang/Keil V6 compatible?
  3. Are there any Code/RAM/Performance deltas when comparing Keil V5 and clang? (I've found this old post , but it compares gcc only and its outdated)

Thanks for any insight

  • Hi eyalasko,

    The clang expert on our team is on holiday and will be back on Monday. He will answer to this post.  I know the posts you linked in but I am worried that this information might be outdated. 

  • Hello,

    I can confirm that the problem exists in SDK 15.3.0 (SVCALL is implemented in the same way). We're also considering to use 6.x compiler, so looking forward..

    Concerning code/RAM results, maybe statistics from our project will be interesting for you.

    v5.06 (-O2): Full build time 0:43, Program Size: Code=27962 RO-data=13030 RW-data=308 ZI-data=10024
    v6.9 (-Os balanced): Full build time 2:06, Program Size: Code=32600 RO-data=8392 RW-data=92 ZI-data=10236

    A noticeable difference in RO-data is because LLVM removes unused constant sections (for example, we have sha256/512 common source where sha512 functions are not called, v5.06 leaves sha512 transform tables in resulting image).

  • Hi,

     

    I just want to initially point out that armclang / llvm is not supported in nRF5 SDK, so please be aware that there might be unwanted side effects by using this toolchain.

    I've seen some pretty old posts (e.g. RK's comment here, and here) that the app breaks/softdevice calls not supported when using clang compiler. Is this still the case?

     Yes, that would still be the case. llvm/clang is close to gcc compatible, but not 100 % on the asm parts, and other ARM specific attributes (SVC for instance).

    Is there a (reasonably) easy way to make the project clang/Keil V6 compatible?

     I haven't tried since SDK 13/14, but other forum users have. From the first thread you linked to, you can find a link to this github repo:

    https://github.com/eblot/nrf5-llvm

    You can try it out and see if that works for you.

    Are there any Code/RAM/Performance deltas when comparing Keil V5 and clang? (I've found this old post , but it compares gcc only and its outdated)

    I am not sure if moving to llvm/armclang would be the best option if you're looking to tune your code, but for research purposes, it makes sense to look at it.

    From the link you posted, you can see that most compilers perform equally when optimizing for size. Without having done any testing with llvm/armclang in a while, I do suspect that the performance would be similar to other ARM compilers out there (IAR, gcc, armcc).

     

    Kind regards,

    Håkon

  • Thanks.

    We are aware of the git repo you've mentioned. We have tried to follow the instructions with SDK14.2 with limited success.

    Is there any clang support on Nordic's roadmap on the foreseeable future?

    Thanks

  • you can see that most compilers perform equally when optimizing for size

    actually when it comes to RAM consumption, I come the opposite conclusion...

Related