rust-lang / rust-lang/rustc_codegen_cranelift
link error: undefined symbol in Window msvc : link dynamic library
Open
Nobody has claimed this yet.
C-bug
O-windows
- Dominant language
- Rust
- Stars
- 2.1k
- Forks
- 157
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 3
Description
rustc 1.94.0-nightly (37aa2135b 2025-12-08)
.cargo/config.toml
opt-level = 0 # 关闭优化 加快编译
panic = "unwind" # 开启 panic 处理 -> 避免运行时错误
lto = "off" # 禁用链接时优化
[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe"
codegen-backend = "cranelift"
rustflags = [
"-C",
"prefer-dynamic",
- If use msvc linker rather than rust-lld , the error still exist
- If i don't use "prefer-dynamic", the error disappear
use std::io::{self, Write};
fn main() {
eprintln!("This is an error message to stderr");
let mut stderr = io::stderr();
writeln!(stderr, "Another stderr message").expect("Failed to write to stderr");
println!("This is normal output to stdout");
}
Link Error
error: linking with `rust-lld.exe` failed: exit code: 1
|
= note: "rust-lld.exe" "-flavor" "link" "/NOLOGO" "D:\\Temp\\rustcSoEzPa\\symbols.o" "<15 object files omitted>" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\std-4e1e2ae26c8967c0.dll.lib" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib/libcompiler_builtins-*.rlib" "kernel32.lib" "kernel32.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "dbghelp.lib" "/defaultlib:msvcrt" "D:\\Temp\\rustcSoEzPa\\api-ms-win-core-synch-l1-2-0.dll_imports_indirect.lib" "D:\\Temp\\rustcSoEzPa\\bcryptprimitives.dll_imports_indirect.lib" "/NXCOMPAT" "/OUT:D:\\project\\target\\debug\\deps\\project.exe" "/OPT:REF,NOICF" "/DEBUG" "/PDBALTPATH:%_PDB%" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\libstd.natvis"
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note: rust-lld: error: undefined symbol: std::io::stdio::stderr::INSTANCE
>>> referenced by D:\project\target\debug\deps\project.5rcvp1v3l83aolc4wpj6y2vwk.19skkgm.rcgu.o:(.refptr._RNvNvNtNtCsaVqoImmYiGb_3std2io5stdio6stderr8INSTANCE)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the .cargo/config.toml settings and the minimal Rust program, then reproduce the Windows MSVC link failure using rustc 1.94.0-nightly, Cranelift, and prefer-dynamic. Compare builds using rust-lld versus the MSVC linker and with prefer-dynamic disabled; done means identifying the cause of the undefined stderr::INSTANCE symbol and establishing a verified fix or compatibility boundary.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100