esp-rs / esp-idf-template

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

`-C default-linker-libraries` breaks the build at link time (pthread multiple symbols) with recent ESP IDF toolchains #178

Open ivmarkov opened 9 months ago

ivmarkov commented 9 months ago

Also see this.

Need to get to the bottom of this but the most likely hypothesis is as per the comment above. It does happen at least with riscv targets, and with ESP IDF 5.X. Unsure yet if xtensa targets are affected, or any targets with ESP IDF 4.4.

WORKAROUND: Remove -C default-linker-libraries from .cargo/config.toml.

ivmarkov commented 9 months ago

Seems to me that linking to libnosys.a is the culprit.

ivmarkov commented 9 months ago

Digging a bit further: seems that the problem is with ESP IDF's own fork of newlib. Specifically, this thing: https://github.com/espressif/newlib-esp32/commit/ff0b7d937917fd4847d9eb1a12d709a1cb651938

Still need to understand (a) why this code was necessary in the first place - perhaps - to fill in the gaps in ESP IDF's own pthread implementation? (b) why it does not link with weak syms (c) why it does break only when default-linker-libraries is used

mrchantey commented 7 months ago

fyi in my case after removing -C default-linker-libraries I got all kinds of errors when trying to use esp_idf_svc 0.47.3 features like wifi. All good after doing a full clean including removing .embuild, then updating dependencies.

My current dependencies are working and look like this:

#[dependencies]
embedded-svc = "0.27"
embedded-hal = "1.0.0"
esp-idf-hal = "0.43"
esp-idf-svc = { version = "0.48", default-features = false,features = ["std"] }