esp-rs / esp-idf-template

A "Hello, world!" template of a Rust binary crate for the ESP-IDF framework.
373 stars 43 forks source link

build error while linking in v4 #149

Closed kons-9 closed 10 months ago

kons-9 commented 10 months ago

Bug description

error occurs in link process. here is a part of output of the error. this error doesn't occur in stable v5.

= note: [ldproxy] Running ldproxy
   6   │           Error: Linker /home/wslmtl/Documents/rust/std-template/.embuild/espressif/tools/riscv32-esp-elf/esp-2021r2-patch5-8.4.0/riscv32-esp-elf/bin/riscv32-esp-e
       │ lf-gcc failed: exit status: 1
   7   │           STDERR OUTPUT:
   8   │           /home/wslmtl/Documents/rust/std-template/.embuild/espressif/tools/riscv32-esp-elf/esp-2021r2-patch5-8.4.0/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/
       │ 8.4.0/../../../../riscv32-esp-elf/bin/ld: error: esp-idf/esp_ringbuf/libesp_ringbuf.a(ringbuf.c.obj): Mis-matched ISA version for 'i' extension. 2.0 vs 2.1
   9   │           /home/wslmtl/Documents/rust/std-template/.embuild/espressif/tools/riscv32-esp-elf/esp-2021r2-patch5-8.4.0/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/
       │ 8.4.0/../../../../riscv32-esp-elf/bin/ld: failed to merge target specific data of file esp-idf/esp_ringbuf/libesp_ringbuf.a(ringbuf.c.obj)
  10   │           /home/wslmtl/Documents/rust/std-template/.embuild/espressif/tools/riscv32-esp-elf/esp-2021r2-patch5-8.4.0/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/
       │ 8.4.0/../../../../riscv32-esp-elf/bin/ld: -march=: ISA string must begin with rv32 or rv64

To Reproduce

just build by default value like

cargo generate esp-rs/esp-idf-template cargo
cd project_name
cargo build

target is esp32c3. (I didn't try other targets)

Expected behavior

work correctly

Screenshots

Environment

I tried macOS and WSL2 using cargo-generate.

Additional context

Vollbrecht commented 10 months ago

you are using the latest nightly compiler? can you try using one that is not newer than 8th of August. You can install a specific version using rustup install nightly-2023-08-07 . Than change the rust-toolchain.toml to that version or use the +nightly-2023-08-07 syntax added to your cargo b command.

kons-9 commented 10 months ago

Yes, my version was latest nightly(2023-8-12) And using nightly-2023-08-07, it works.

LarryMerino commented 10 months ago

I try updating rust version and now I'm using 1.73.0-nightly (7c3904d6c 2023-08-14) but the same problem

   Compiling embedded-svc v0.25.3
error: linking with `ldproxy` failed: exit status: 1

If I use custom configuration and select ESP-IDF version v5.1 it works but v4.4 have this error

ivmarkov commented 10 months ago

I try updating rust version and now I'm using 1.73.0-nightly (7c3904d6c 2023-08-14) but the same problem

   Compiling embedded-svc v0.25.3
error: linking with `ldproxy` failed: exit status: 1

If I use custom configuration and select ESP-IDF version v5.1 it works but v4.4 have this error

Unfortunately, the problem will not be fixed in any newer nightly rust release. It is a combination of the fact that recent rust nightlies migrated to LLVM 17, which now supports the newer 2.1 riscv spec, and the older gcc 8 compiler, which is used in esp idf 4.x for compiling the esp idf C code and then for linking everything together, which only supports the 2.0 riscv spec and refuses to link the newer speced rust object files generated by the newer rustc.

Other than using a newer gcc version for linking specifically, I have not found any other workaround. So that would most likely be the final fix too.

ivmarkov commented 10 months ago

Should be fixed now.