Closed MichalOp closed 6 months ago
Hm, I know that in the past, a lot of the floating point methods didn't exist in libcore so you couldn't call them in the first place. The solution back then was to use the libm
crate instead which has replacement implementations. libm::fminf()
in your case...
But as your program is failing at the linker stage instead of simply erroring on a missing f32::min()
method, it seems something has changed here. Maybe another compiler-builtins
topic? @Patryk27, do you have any idea?
I've just checked and the code compiles correctly on my machine - could you run avr-gcc --version
and post the result? Maybe you're using an older avr-gcc which didn't yet have float intrinsics for AVR.
(for comparison, I'm on avr-gcc (Homebrew AVR GCC 9.4.0) 9.4.0
)
It looks like this was the issue, thank you. I was using avr-gcc 5.4.0
- which is the default one installed via apt for Ubuntu, and I guess it is too old.
After I compiled gcc 13.2.0 from source for avr (I also compiled avr-libc 2.1.0 for good measure), the program compiled and ran without issues.
It seems that I can't use a lot of the floating point functions (when compiling for atmega328p), for example
min
:This fails to link with the following error:
My understanding is that this function and other float functions should be available in the avr-libc. I tried adding -lm to the linker args in avr-specs, but it didn't help. I also tried the new nightly toolchain and both the newest and mentioned in the readme commits of this repo.
I am on Ubuntu 22.04, and I installed the prerequisites according to the readme, so I have avr-gcc 5.4.0 and avr-libc 2.0.0. If I don't use the floating point functions, the code compiles normally - am I missing something?