-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP, POC: Add LLVM support for AVR #16924
base: master
Are you sure you want to change the base?
Conversation
@chrysn: Since you seemed to be interested in using LLVM with AVR: I dumped my current state of work here. It does at least compile and link finally, but it cannot be flashed for now... |
Thanks, and I appreciate any WIP PRs as they make sure that it's findable -- but to clarify: I have no interest in AVR itself (last project had on it was >10a ago, not looking back), it was just that #16919 means that I can avoid the mess the C2Rust transpiler makes of C11 atomics by telling it to go through the atomic utils instead. (Staying subscribed as in general I like having LLVM usable more widely -- it opens up cross-language-LTO opportunities.) |
This one needs a rebase |
Indeed :) But more importantly, it also depends on some infrastructure work. First, llvm/llvm-project#51557 needs to be resolved. Afterwards, the avrlibc headers need to be fixed to be compatible with Since the avrlibc was recently resurrected, this seems to be quite feasible actually :) |
LLVM14 will contain support for the register aliases and the AVR backend has received quite some attention. Also avr-libc became active maintenance again, so I guess I can just aim for fixing things upstream first. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
@maribu Still working on this? |
I think some work on LLVMs AVR support has been merged since the last time I looked. Maybe now is a good time to pick this up again. There are some bugs in avrlibc that GCC doesn't trigger, that can cause a headache. Upstream is pretty much dead for avrlibc. |
Reminder: Soft-freeze is on the 25th. |
f2f2e74
to
470564e
Compare
This does actually compile now on both LLVM and GCC. There are still some rough corners, but this may be on track to get in prior to the soft feature freeze. |
Can we do reviewing now? |
Mixing address spaces is something LLVM doesn't like (for good reason). This re-organized the code a bit so that this does not happen anymore, even on AVR. Split out of RIOT-OS#16924
Looks like there are still compilation issues with GCC (at least the old version) that need fixing and static tests. I'm also not happy with the quality yet. But I split out the commit that I think is ready, though: #20483 |
Mixing address spaces is something LLVM doesn't like (for good reason). This re-organized the code a bit so that this does not happen anymore, even on AVR. Split out of RIOT-OS#16924
Mixing address spaces is something LLVM doesn't like (for good reason). This re-organized the code a bit so that this does not happen anymore, even on AVR. Split out of RIOT-OS#16924
Contribution description
This PR is working towards adding LLVM support for the AVR platform.
WARNING: This is work in progress and not in a shape in which it makes sense to start a code review.
I needed to add some workarounds for features of the avrlibc that do not compile with clang. One big pain point is that clang verifies constraints of inline assembly before eliminating dead branches, while GCC does it the other way round. E.g. something like
will fail to compile for
FOO >= 64
with LLVM, despite the inline assembly never being executed in that case. The header in<avr/wdt.h>
uses this a lot, so I provided versions ofwdt_enable()
etc. inline - I'm not sure if those will work on al AT(X)mega MCUs supported by RIOT, though.Another issue with LLVM is that commonly used helpers like
__tmp_reg__
,__SREG__
,__SP_L__
,__SP_H__
are not available. For now, I replaced them with magic numbers / register names.Testing procedure
$ make BOARD=atmega328p TOOLCHAIN=llvm -C examples/hello-world
compiles and links, but cannot be flashed.Issues/PRs references
Depends on: