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
{{ message }}
Repository navigation
rust stable 1.78 using 'x86_64-pc-windows-gnu' host tool to build 'thumbv7em-none-eabihf' arm bare metal target got rust-lld failed #125809
Failed reason is can't find 'libgcc_s_seh-1.dll' and 'libwinpthread-1.dll'
when fallback to 1.77.2 or using 'x86_64-pc-windows-msvc' host tool then every thing is ok
$ file ~/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu/bin/rust-lld.exe
/c/Users/mateusz/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu/bin/rust-lld.exe: PE32+ executable (console) x86-64, for MS Windows, 17 sections
I rust-lld should be called with PATH set to ~/.rustup/toolchains/stable-x86_64-pc-windows-gnu/bin/, or at least used to be. Do you have an example that reproduces the problem? Hopefully, we can bisect it to easily find the problem.
I have tested using clean rust host toolchain installed by rustinit, and just build cortex-m-quickstart, then it reproduce the problem.
note: Cargo.toml in cortex-m-quickstart need change 'package.name' and 'bin.name' before build, because they have '{{' and '}}'
If I understand correctly, when ~/.rustup/toolchains/stable-x86_64-pc-windows-gnu/bin/ is in PATH on Windows, it makes no difference. What the removed code path did was adding that to PATH. In rustup 1.27.1, RUSTUP_WINDOWS_PATH_ADD_BIN was changed to false by default (rust-lang/rustup#3703), so probably the rustup change is related.
@mati865 is it possible for you to add RUSTUP_WINDOWS_PATH_ADD_BIN=true and check it again?
I don't have a Windows machine available at hand :(
Also, could you check if rustc appends host tool bin to PATH? It looks like it but I am not particularly sure.
Thought it might be important to add; all my tests were made with only ~/.cargo/bin present in PATH:
$ echo $PATH
/c/Users/mateusz/.cargo/bin
If I understand correctly, when ~/.rustup/toolchains/stable-x86_64-pc-windows-gnu/bin/ is in PATH on Windows, it makes no difference.
Yes, but apparently it's not in PATH when tools from ~/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu/bin are called. $ PATH=$PATH:~/.rustup/toolchains/stable-x86_64-pc-windows-gnu/bin cargo +stable b works fine so that sort of confirms it.
In rustup 1.27.1, RUSTUP_WINDOWS_PATH_ADD_BIN was changed to false by default (rust-lang/rustup#3703), so probably the rustup change is related.
@mati865 is it possible for you to add RUSTUP_WINDOWS_PATH_ADD_BIN=true and check it again? I don't have a Windows machine available at hand :(
Adding that env makes no difference:
$ rustup -V
rustup 1.27.1 (54dd3d00f 2024-04-24)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.80.0-nightly (a330e4959 2024-06-04)`
$ RUSTUP_WINDOWS_PATH_ADD_BIN=true cargo +stable b
...
error: linking with `rust-lld` failed: exit code: 0xc0000135
Also, could you check if rustc appends host tool bin to PATH? It looks like it but I am not particularly sure.
I can do some builds during the weekend.
Also, could you check if rustc appends host tool bin to PATH? It looks like it but I am not particularly sure.
Judging from that code, it only adds ~/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu/bin.
@ChrisDenton are you talking about a fix in cargo or rustc?
What happens if we invoke rustc directly to cross-compile? If it doesn't work either, I feel like this should be addressed on rustc or linker invocation side.
Runtime libraries are located alongside rustc, so invoking it directly would work fine.
The same cannot be said about bins inside ~/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu/bin, but is it even supported to invoke them manually?
if we invoke rustc directly to cross-compile? If it doesn't work either, I feel like this should be addressed on rustc or linker invocation side.
This would be my inclination that rustc ensures that it has the PATH set up correctly. We just need to make sure that things like rust-lang/cargo#8531 and rust-lang/rustup#3036 don't regress again.
I suspect adding the bin directory to PATH will make proc-macros fail recursive calls to rustc or cargo via rustup. I'm not sure how much we should care about that. The only solution I can think there is to separate the DLLs into a separate directory.
I'm solving this now in my PR #128876 by shipping the required runtime DLLs along with rust-lld.exe too.
It must be possible to run rust-lld.exe without relying on any PATH variable being set. We already ship these runtime DLLs alongside rustc.exe, so doing the same for rust-lld.exe feels like a reasonable thing to do. This solution won't require RUSTUP_WINDOWS_PATH_ADD_BIN or any other modification to the PATH environment variable.
Activity
mati865 commentedon Jun 4, 2024
Those libraries are provided alongside other Rust binaries:
Note
rust-lldis located inside rustlib:I rust-lld should be called with PATH set to
~/.rustup/toolchains/stable-x86_64-pc-windows-gnu/bin/, or at least used to be. Do you have an example that reproduces the problem? Hopefully, we can bisect it to easily find the problem.pbl-pw commentedon Jun 5, 2024
I have tested using clean rust host toolchain installed by rustinit, and just build cortex-m-quickstart, then it reproduce the problem.
note: Cargo.toml in cortex-m-quickstart need change 'package.name' and 'bin.name' before build, because they have '{{' and '}}'
mati865 commentedon Jun 5, 2024
searched nightlies: from nightly-2024-02-01 to nightly-2024-03-16
regressed nightly: nightly-2024-02-22
searched commit range: bb59453...3406ada
regressed commit: 0987e41
bisected with cargo-bisect-rustc v0.6.8
Host triple: x86_64-pc-windows-gnu
Reproduce with:
Won't be as easy to debug as I hoped.
@weihanglo do you have any idea which change could case it?
EDIT: perhaps rust-lang/cargo#13468?
No idea how to test it without CI builds though.
weihanglo commentedon Jun 5, 2024
If I understand correctly, when
~/.rustup/toolchains/stable-x86_64-pc-windows-gnu/bin/is inPATHon Windows, it makes no difference. What the removed code path did was adding that toPATH. In rustup 1.27.1,RUSTUP_WINDOWS_PATH_ADD_BINwas changed to false by default (rust-lang/rustup#3703), so probably the rustup change is related.@mati865 is it possible for you to add
RUSTUP_WINDOWS_PATH_ADD_BIN=trueand check it again?I don't have a Windows machine available at hand :(
Also, could you check if rustc appends host tool bin to
PATH? It looks like it but I am not particularly sure.weihanglo commentedon Jun 5, 2024
Would you mind sharing the output of
rustup --versionthat shows the version of rustup you are using, @pbl-pw?mati865 commentedon Jun 5, 2024
Thought it might be important to add; all my tests were made with only
~/.cargo/binpresent in PATH:Yes, but apparently it's not in
PATHwhen tools from~/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu/binare called.$ PATH=$PATH:~/.rustup/toolchains/stable-x86_64-pc-windows-gnu/bin cargo +stable bworks fine so that sort of confirms it.Adding that env makes no difference:
I can do some builds during the weekend.
Judging from that code, it only adds
~/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu/bin.weihanglo commentedon Jun 5, 2024
My fault. Should be
RUSTUP_WINDOWS_PATH_ADD_BIN=1nottrue.mati865 commentedon Jun 5, 2024
Oh, I had missed that too 😄
RUSTUP_WINDOWS_PATH_ADD_BIN=1 cargo +stable bworks fine.4 remaining items
weihanglo commentedon Jun 6, 2024
@ChrisDenton are you talking about a fix in cargo or rustc?
What happens if we invoke rustc directly to cross-compile? If it doesn't work either, I feel like this should be addressed on rustc or linker invocation side.
mati865 commentedon Jun 6, 2024
Runtime libraries are located alongside rustc, so invoking it directly would work fine.
The same cannot be said about bins inside
~/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu/bin, but is it even supported to invoke them manually?ehuss commentedon Jun 6, 2024
This would be my inclination that rustc ensures that it has the PATH set up correctly. We just need to make sure that things like rust-lang/cargo#8531 and rust-lang/rustup#3036 don't regress again.
I suspect adding the
bindirectory to PATH will make proc-macros fail recursive calls to rustc or cargo via rustup. I'm not sure how much we should care about that. The only solution I can think there is to separate the DLLs into a separate directory.Ship MinGW-w64 runtime DLLs along with `rust-lld.exe` for `-pc-window…
Ship MinGW-w64 runtime DLLs along with `rust-lld.exe` for `-pc-window…
Ship MinGW-w64 runtime DLLs along with `rust-lld.exe` for `-pc-window…
ColinFinck commentedon Aug 9, 2024
I'm solving this now in my PR #128876 by shipping the required runtime DLLs along with
rust-lld.exetoo.It must be possible to run
rust-lld.exewithout relying on anyPATHvariable being set. We already ship these runtime DLLs alongsiderustc.exe, so doing the same forrust-lld.exefeels like a reasonable thing to do. This solution won't requireRUSTUP_WINDOWS_PATH_ADD_BINor any other modification to thePATHenvironment variable.Ship MinGW-w64 runtime DLLs along with `rust-lld.exe` for `-pc-window…
Ship MinGW-w64 runtime DLLs along with `rust-lld.exe` for `-pc-window…
Ship MinGW-w64 runtime DLLs along with `rust-lld.exe` for `-pc-window…
Auto merge of rust-lang#128876 - ColinFinck:rust-lld-with-runtime-dll…
Rollup merge of rust-lang#128876 - ColinFinck:rust-lld-with-runtime-d…
Rollup merge of rust-lang#128876 - ColinFinck:rust-lld-with-runtime-d…
Unrolled build for rust-lang#128876