-
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
core: rmutex compilation issue on ARM with llvm #12048
Comments
I cannot reproduce the issue with LLVM 9.0.0 - I guess it has been fixed upstream. Can you confirm that the issue has been resolved? |
OK, works for |
I can also reproduce this with the |
I opened a bug report at the LLVM bug tracker: https://bugs.llvm.org/show_bug.cgi?id=43603 |
Some Background
To us, the behavior of GCC is clearly better, as the assumption of disabling interrupts during the implementation of the library functions is totally sane for embedded1 targets, applies to RIOT, and yields better performance. I hope that I can convince the LLVM guys to just also assume that on embedded bare metal targets. 1 Embedded target here shall mean: Single-threaded, single-core bare metal targets without MMU and any meaningful distinction between user and kernel mode The Actual IssueThe warning of Taking the following example: extern atomic_int_least32_t bar;
void foo1(void)
{
unsigned state = irq_disable();
bar += 42;
irq_restore(state);
}
void foo2(void)
{
atomic_fetch_add(&bar, 42);
} In the context of RIOT: On systems supporting lock free implementations of So to us the warning really has no value - we are totally fine with the library calls. We should therefor just disable the warning. |
Description
Cannot build anything with TOOLCHAIN=llvm for ARM.
It fails with a warning when compiling rmutex.c.
Googling the error points to where the warning was introduced in llvm.
Quote: "If an atomic variable is misaligned Clang will emit accesses to it as a libcall. These calls are likely to be slow and involve locks; they are almost certainly not what the developer intended. So this patch adds a warning (promotable or ignorable) for tat situation."
It seems like clang warns that it cannot use single-instruction magic (cmpxcg?), but has to resort to a compiler-rt library function call that uses locks etc.
I don't quite understand the issue. First I thought the owner variable sharing memory with the refcount variable was causing this, but changing "owner" to (word-sized) atomic_int doesn't solve the issue.
Steps to reproduce the issue
Try "BOARD=samr21-xpro make -C examples/hello-world".
Expected results
Actual results
Versions
Using arch clang 8.0.1 and gcc 9.1.0 headers (full toolchain versions gist)
The text was updated successfully, but these errors were encountered: