You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
linker is not using rustflags defined in the config.toml file in LINUX only (it is working fine in windows with same code and rustc version).
I ran the same project in linux and windows and displayed the linker arguments using cargo rustc -- --print=link-args my config.toml inside project's .cargo folder contains the following.
In windows I got the following linker args at the end of the linker command ... target\\thumbv7em-none-eabihf\\debug\\deps\\i2c-4754388f49bb4437" "--gc-sections" "-Tlink.x"
In linux this is what I get at the end of my linker args
WORKAROUND:
Manually assigning RUSTFLAGS before running the build command works correctly RUSTFLAGS="-C link-arg=-Tlink.x" cargo rustc -- --print=link-args
This displayed the correct linker arguments in linux and probe-rs worked great. ......target/thumbv7em-none-eabihf/debug/deps/i2c-9061183c020b57e6" "--gc-sections" "-Tlink.x"
On your Linux system did you have RUSTFLAGS set? If so that overrides the rustflags in .cargo/config.toml. And were you inside the directory containing .cargo/config.toml when you ran the build command.
On your Linux system did you have RUSTFLAGS set? If so that overrides the rustflags in .cargo/config.toml. And were you inside the directory containing .cargo/config.toml when you ran the build command.
Ohhhhh it seems to be set but empty in my env variables sorry about that. I tried echoing it before but nothing showed up. That explains it.
Just in case you still want the information
I ran the command from multiple folders (I initially used older version of these projects where config.toml did have the correct linker arg -Tlink.x) however the latest version referenced below was also tried and though it might be easier for you to try out:
1- From discovery-mb2 main folder using cargo build -p led-roulette then checking the elf file readelf -l ./target/thumbv7em-none-eabihf/debug/led-roulette
2- I also tried running it in the project folder containing .cargo folder and ` folder . /discovery-mb2/mdbook/src/08-led-roulette
jieyouxu
added
C-discussion
Category: Discussion or questions that doesn't represent real issues.
and removed
C-bug
Category: This is a bug.
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
labels
May 28, 2025
linker is not using rustflags defined in the config.toml file in LINUX only (it is working fine in windows with same code and rustc version).
I ran the same project in linux and windows and displayed the linker arguments using
cargo rustc -- --print=link-args
myconfig.toml
inside project's.cargo
folder contains the following.In windows I got the following linker args at the end of the linker command
... target\\thumbv7em-none-eabihf\\debug\\deps\\i2c-4754388f49bb4437" "--gc-sections" "-Tlink.x"
In linux this is what I get at the end of my linker args
... target/thumbv7em-none-eabihf/debug/deps/i2c-ce1445d509cca9ef" "--gc-sections"
WORKAROUND:
Manually assigning RUSTFLAGS before running the build command works correctly
RUSTFLAGS="-C link-arg=-Tlink.x" cargo rustc -- --print=link-args
This displayed the correct linker arguments in linux and probe-rs worked great.
......target/thumbv7em-none-eabihf/debug/deps/i2c-9061183c020b57e6" "--gc-sections" "-Tlink.x"
rustc --version --verbose
:I also tried the nightly version same issue.
The text was updated successfully, but these errors were encountered: