rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.88k stars 12.67k forks source link

rustc 1.82.0 doesn't add LIBPATH when invoking link.exe #132016

Open nandin-borjigin opened 5 hours ago

nandin-borjigin commented 5 hours ago

Rust-to-rust dynamic linking (through import library) on Windows fails with toolchain version 1.82.0.

The build log shows that 1.82.0 is not adding any /LIBPATH arguments when invoking link.exe.

I tried this code: nandin-borjigin/rustc-1.82.0-repro

Image

I expected to see this happen: Successful build

Instead, this happened: LINK : fatal error LNK1181: cannot open input file 'mylib.dll.lib'

Image

Meta

rustc --version --verbose:

rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-pc-windows-msvc
release: 1.82.0
LLVM version: 19.1.1
Backtrace

Possibly related

ChrisDenton commented 4 hours ago

cc @petrochenkov, I believe there were some changes to linking with msvc?

nandin-borjigin commented 4 hours ago

Adding this build script helps, but I think this should only be considered a workaround and rustc should emit library search path by default.

    println!("cargo:rustc-link-search=native={}/deps", out_dir.display());