-
Notifications
You must be signed in to change notification settings - Fork 13.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
Linking fails for AVR: undefined reference to '__gtdf2' / '__gedf2' #139144
Comments
__gtdf2' /
__gedf2'
@rustbot label: +O-AVR +A-floating-point +A-linkage +T-compiler |
According to the libgcc-docs, those are used to compare two Which version of |
I'm using My project doesn't use
Now the project should use Here's the long output of
|
I've reproduced your issue locally with an avr-gcc version 14.2.0, so I can confirm the issue on the nightly you use even with different avr-gcc-versions. I've tried it with a more recent nightly ( $ cd /tmp/
$ curl -L https://github.com/user-attachments/files/19526406/avr-f64-fail.zip -o avr-f64-fail.zip
$ unzip -q avr-f64-fail.zip
$ cd avr-f64-fail/
$ sed -i 's/"nightly-.*"/"nightly-2025-03-11"/' rust-toolchain.toml
$ RUSTFLAGS='-Ctarget-cpu=atmega2560' cargo build -q
$ avr-size target/avr-atmega2560/debug/avr-f64-fail.elf
text data bss dec hex filename
4170 0 1 4171 104b target/avr-atmega2560/debug/avr-f64-fail.elf I've run a little bisection (just compilation without running of the code, as I don't have access to an ATmega2560 at the moment) and came to the conclusion, that a compiler after 2024-07-30 should work (which contains #125016, which updates compiler-builtins). (manual) bisection logs
Is there a reason for using this old compiler? |
There's no reason for using 2024-03-21. It was part of the template, so I ended up using it. I tried your commands on two different Ubuntus, but I'm still getting the same linking error. Here's what
The other Ubuntu is running on x86_64 so it prints out the host line as I also tried Maybe I am missing some system libraries? I have run |
Actually, the linking error isn't exactly the same. It is also complaining
|
Thanks for pointing out that I was using old compilers! I was able to get the code linking by using avr-gcc version 14.2.0. The older avr-gcc 7.3.0 wasn't good enough. I had assumed that Ubuntu 24.04 would include a fairly recent avr-gcc, but it still ships with avr-gcc 7.3.0. I installed Ubuntu 25.04, which includes avr-gcc 14.2.0 and then everything started linking. So, if anyone is having similar AVR linking issues, try with avr-gcc 14.2.0 or later and Rust 1.87.0 or later. I'll close this issue, because it is now resolved for me. |
I'm trying to build a Rust project for Arduino Mega 2560. The project was generated with avr-hal and is based on mega2560-usart.
Here's a zip package with a complete Rust project: avr-f64-fail.zip
I tried this code with f64 floating point numbers. Linking fails when
cargo build
is run:I expected to see this happen: the program is linked successfully.
Instead, this happened: a linking error is given:
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: