Closed
Description
How to reproduce:
"<build>\x86_64-pc-windows-msvc\stage1\bin\rustc.exe" -Clinker=lld hello.rs
where hello.rs
is
// The important thing here is accessing thread-local `static LOCAL_STDERR` in libstd.
fn main() {
eprint!("Hello");
}
rustc
must be built locally, the issue doesn't reproduce on nightly rustc, I don't know due to which differences.lld
can be eitherrust-lld
shipped with rustc, orlld
from a msys2 package, the issue reproduces on both, and it doesn't happen without lld.- the produced executable must be run using a path, not just an executable name, an absolute path like
"C:\msys64\home\me\hello.exe"
works for sure. UPD: The program invocation string should just be long enough, not necessarily a path. - libstd must be build with
opt-level = 3
(the default), lowering the opt level to improve debugging removes the issue :( but full debuginfo can still be enabled. - The exception and backtrace look like this - rustbuild: Remove one LLD workaround #76127 (comment)
I'll try to step through disassembly and look what happens in more detail tomorrow.