Closed KOLANICH closed 2 years ago
Yer not trying to compiler that library on a modern/post2016 AVR are you? That won't work, they haven't updated the library.
Yer not trying to compiler that library on a modern/post2016 AVR are you?
The mcu I compile for is atmega2560.
That won't work, they haven't updated the library.
What do you mean? Should not clang link well to any standard library gcc links well?
If I understand right, the issue mentioned here can happen if clang has stricter checks than gcc has (and it is often tye case).
No library that uses _SFR_TO_IO_ADDR on a special function register that doesn't reside in the I/O spacve will ever work.
And yeah apparently that's the case on the 2560. It's 0x60. But 0x3F is the highest number allowed for the I constraint, which specifies the address of a locatrion within the I/O space. On the 2560, the WDT control registrer is not located within the I/O space, and the assembly that is being used to access it cannot work. On claqssic AVRs it's almost universal that they are, but not 100%, and on modern AVRs they never are.
Thanks for the info.
I guess I have mistaken, arduino/toolchain-avr
is the wrong repo to fill an issue against. I probably should have created the issue in https://github.com/avrdudes/avr-libc
The func has 2 branches: https://github.com/avrdudes/avr-libc/blob/960a359d854001399b8fb445a9ad0ce3ea80f4d0/include/avr/wdt.h#L450-L532 , one uses out
and another one uses sts
, I guess on this board the one using sts
is expected to be taken, but the content of if
is not a constexpr, and if I rewrite it to if constexpr
it errors because #define _SFR_MEM_ADDR(sfr) ((uint16_t) &(sfr))
is not a constexpr.
The issue has already been filed by someoje else there: https://github.com/avrdudes/avr-libc/issues/678
https://github.com/arduino/toolchain-avr/issues
When tryint to setup a CMake toolchain file to compile to avr target using
clang-15
I got the following errors:(in
wdt_disable
)(in
wdt_disable
)I guess
& 0b111111
is needed for runtime dispatch to calm down the compiler.if constexpr
for the case of C++ to do dispatch in compile time.