Closed brainstorm closed 7 months ago
As mentioned in https://github.com/esp-rs/esp-hal/issues/1336#issuecomment-2014543276, looks like you are missing some .cargo/config.toml
configurations.
Feel free to reopen the issue if you consider it is not completed.
@SergioGasquez Not the same issue, here's my .cargo/config.toml
:
[target.riscv32imac-unknown-none-elf]
runner = "espflash flash --monitor"
[build]
rustflags = [
"-C", "link-arg=-Tlinkall.x",
# Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.)
# NOTE: May negatively impact performance of produced code
"-C", "force-frame-pointers",
]
target = "riscv32imac-unknown-none-elf"
[unstable]
build-std = ["core"]
could you please point out what I'm missing? Also I don't seem to be able to reopen the issue, perhaps that option is disabled in this repo?
There is something strange going on.
-nostartfiles
should only get added to .cargo/config.toml
for Xtensa: https://github.com/esp-rs/esp-template/blob/21b13bc6089ef67d65e869b7fd03545de3289eff/.cargo/config.toml#L16-L18
And in the posted file above it's not present - so the big question would be what adds that option?
Since I cannot tell if the last question is aimed at me, I re-did the steps above just in case (with no advanced template options this time)... and got another rust-lld
missing file, the rom_functions.x
one too this time:
$ cargo generate esp-rs/esp-template
⚠️ Favorite `esp-rs/esp-template` not found in config, using it as a git repository: https://github.com/esp-rs/esp-template.git
🤷 Project Name: rust
🔧 Destination: /home/rvalls/dev/personal/pancake-legend-lights/src/rust ...
🔧 project-name: rust ...
🔧 Generating template ...
✔ 🤷 Which MCU to target? · esp32c6
✔ 🤷 Configure advanced template options? · false
🔧 Moving generated files into: `/home/rvalls/dev/personal/pancake-legend-lights/src/rust`...
🔧 Initializing a fresh Git repository
✨ Done! New project created /home/rvalls/dev/personal/pancake-legend-lights/src/rust
Here's the generated .cargo/config.toml
$ cat .cargo/config.toml
[target.riscv32imac-unknown-none-elf]
runner = "espflash flash --monitor"
[build]
rustflags = [
"-C", "link-arg=-Tlinkall.x",
# Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.)
# NOTE: May negatively impact performance of produced code
"-C", "force-frame-pointers",
]
target = "riscv32imac-unknown-none-elf"
[unstable]
build-std = ["core"]
Here's the end of cargo build
(also fails the same way with --release
):
(...)
= note: rust-lld: error: unknown argument '-nostartfiles'
rust-lld: error: cannot find linker script rom_functions.x
Are any of you two @bjoernQ and/or @SergioGasquez able to reproduce this issue or it's just me?
I'm not able to reproduce it given the steps above. But since it seems cargo is picking up something which is not in your generated .cargo/config.toml
maybe it's picking up something from another file: https://doc.rust-lang.org/cargo/reference/config.html - e.g. having a config.toml
in $CARGO_HOME
or in any of the other options provided
Maybe the output of cargo -Z unstable-options config get
might help
cargo -Z unstable-options config get
Thanks @bjoernQ, here it is:
$ cargo -Z unstable-options config get
build.rustflags = ["-C", "link-arg=-Tlinkall.x", "-C", "link-arg=-Trom_functions.x", "-C", "link-arg=-nostartfiles", "-C", "link-arg=-Tlinkall.x", "-C", "force-frame-pointers"]
build.target = "riscv32imac-unknown-none-elf"
env.ESP_LOGLEVEL = "INFO"
target.riscv32imac-unknown-none-elf.runner = "espflash flash --monitor"
target.xtensa-esp32s3-none-elf.runner = "espflash flash --monitor"
unstable.build-std = ["core", "core"]
# The following environment variables may affect the loaded values.
# CARGO_HOME=/home/rvalls/.cargo
On a quick look, I don't see any config overrides/definitions in /home/rvalls/.cargo
:
$ cat ~/.cargo/
bin/ .crates.toml git/ .package-cache registry/
.crates2.json env .global-cache .package-cache-mutate
rvalls@framework:~/dev/personal/pancake-legend-lights/src/rust$ cat ~/.cargo/.crates.toml
[v1]
"binocle 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = ["binocle"]
"cargo-generate 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = ["cargo-generate"]
"du-dust 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = ["dust"]
"espflash 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = ["espflash"]
"espup 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = ["espup"]
"just 1.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = ["just"]
"qrrs 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = ["qrrs"]
"ravedude 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = ["ravedude"]
rvalls@framework:~/dev/personal/pancake-legend-lights/src/rust$ cat ~/.cargo/env
#!/bin/sh
# rustup shell setup
# affix colons on either side of $PATH to simplify matching
case ":${PATH}:" in
*:"$HOME/.cargo/bin":*)
;;
*)
# Prepending path in case a system-installed rustc needs to be overridden
export PATH="$HOME/.cargo/bin:$PATH"
;;
esac
rvalls@framework:~/dev/personal/pancake-legend-lights/src/rust$ env | grep -i cargo
PATH=/home/rvalls/.rustup/toolchains/esp/riscv32-esp-elf/esp-12.2.0_20230208/riscv32-esp-elf/bin:/home/rvalls/.rustup/toolchains/esp/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin:/home/rvalls/.rustup/toolchains/esp/xtensa-esp32s2-elf/esp-12.2.0_20230208/xtensa-esp32s2-elf/bin:/home/rvalls/.rustup/toolchains/esp/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin:/home/rvalls/.cargo/bin:/home/rvalls/.local/bin:/home/rvalls/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/rvalls/bin:/home/rvalls/.cargo/bin:/home/rvalls/.local/bin
Thanks for the assistance either way!
Just for reference this is what the effective config looks for me
❯ cargo -Z unstable-options config get
build.rustflags = ["-C", "link-arg=-Tlinkall.x", "-C", "link-arg=-Trom_functions.x", "-C", "force-frame-pointers"]
build.target = "riscv32imac-unknown-none-elf"
target.riscv32imac-unknown-none-elf.runner = "espflash flash --monitor"
unstable.build-std = ["core"]
# The following environment variables may affect the loaded values.
# CARGO_HOME=C:\Users\Bjoern\.cargo
e.g. target.xtensa-esp32s3-none-elf.runner = "espflash flash --monitor"
looks suspicious and also the problematic "-C", "link-arg=-nostartfiles",
is there
cargo -Z unstable-options config get --show-origin
might help .... it should show where each setting is from
Aha! Thanks so much, there was this remaining .cargo
leftover from a previous template generation on the top level of the project (I was generating sub-rust projects and posting the sub-.cargo dirs), I didn't know that top level .cargo
(not $HOME/.cargo, but repo top level) took precedence, interesting behavior!:
$ cat .cargo/config.toml
[target.xtensa-esp32s3-none-elf]
runner = "espflash flash --monitor"
[env]
ESP_LOGLEVEL="INFO"
[build]
rustflags = [
"-C", "link-arg=-Tlinkall.x",
"-C", "link-arg=-Trom_functions.x",
"-C", "link-arg=-nostartfiles",
]
target = "xtensa-esp32s3-none-elf"
[unstable]
build-std = ["core"]
Thanks so much for the help, apologies for the confusion!
Hello!
I was trying to have one of the great embassy
esp-hal
examples fromesp-hal
as a standalone project that I wish to develop further but I ran into the followingrust-lld
issue (similar to https://github.com/esp-rs/esp-hal/issues/1336 ?):Then I just went and copied the example file over to
main.rs
on the template (knowing that some error related to embassy not being supported in this template was about to come (see issue #110))... which I could justcargo add
a posteriori (I guessed/thought):$ cp ~/dev/personal/esp-hal/examples/src/bin/embassy_i2s_read.rs src/main.rs
But to my surprise I saw a
rust-lld
error instead:My local setup seems to be ok since the
esp-hal
example works out of the box, btw:For context I'm just trying to pipe I2S mems microphone data, see https://github.com/esp-rs/esp-println/issues/29#issuecomment-2016655068.
What I am doing wrong here w.r.t the
rust-lld -nostartfiles
error?