-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
When using the native build, the linking phase fails with the following errors:
Error: Linker /Users/imarkov/projects/esp32/rust-esp32-std-hello/.sdk/tools/riscv32-esp-elf/1.24.0.123_64eb9ff-8.4.0/riscv32-esp-elf/bin/riscv32-esp-elf-gcc failed: exit status: 1
STDERR OUTPUT:
/Users/imarkov/projects/esp32/rust-esp32-std-hello/.sdk/tools/riscv32-esp-elf/1.24.0.123_64eb9ff-8.4.0/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: /Users/imarkov/projects/esp32/rust-esp32-std-hello/.sdk/tools/riscv32-esp-elf/1.24.0.123_64eb9ff-8.4.0/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/lib/rv32im/ilp32/libc.a(lib_a-svfprintf.o): in function `_svfprintf_r':
/builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/riscv32-esp-elf/src/newlib/newlib/libc/stdio/vfprintf.c:1217: undefined reference to `__trunctfdf2'
/Users/imarkov/projects/esp32/rust-esp32-std-hello/.sdk/tools/riscv32-esp-elf/1.24.0.123_64eb9ff-8.4.0/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: /Users/imarkov/projects/esp32/rust-esp32-std-hello/.sdk/tools/riscv32-esp-elf/1.24.0.123_64eb9ff-8.4.0/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/lib/rv32im/ilp32/libc.a(lib_a-vfprintf.o): in function `_vfprintf_r':
/builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/riscv32-esp-elf/src/newlib/newlib/libc/stdio/vfprintf.c:1192: undefined reference to `__trunctfdf2'
collect2: error: ld returned 1 exit status
Preliminary analysis:
I am half there in figuring out the linkage problems with the native build and the C3 chip:
- Rust is spitting out a
-nodefaultlibsoption on the command line, which seems to be kind of like "the default behavior" (but it seems you can control this on a Rust target level, when you define the target) - This is somehow preventing the linker from finding the missing intrinsic (
__trunctfdf2); if I remove the-nodefaultlibs, it works OK - Short term solution: we have a simple workaround in adding a
rustflags = ["-C", "default-linker-libraries"]to the[target.riscv32imc-esp-espidf]section in.cargo/config.tomlin the relevant binary crate (rust-esp32-std-helloetcetera) - Long term solution: we should probably allow the "default libs" behavior on the Rust target level (as in
riscv32imc-esp-espidfas well as in all xtensa targets, if it is not allowed there). Reason why I believe this is a correct behavior: I don't see the-nodefaultlibsargument amongst the "native" (cmake) args, which means the native ESP-IDF build is assuming it is NOT set
Unresolved questions/issues:
- Why is this argument defined in the first place? The Rust/cargo committers are fuzzy on the topic:
- Why does the build work for the Xtensa targets? Either they opt out from the
-nodefaultlibsoption, or that particular intrinsic is simply not needed on Xtensa. Not sure - Why does the ESP32C3 build work via PlatformIO? Superstrange.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels