Change:
<!-- Thank you for filing a bug report! Please provide a short summary of the bug, along with any information you feel relevant to replicating the bug. --Hi all, I'm coming from to report an inconsistency in how Rust passes library names to Visual Studio's . In the project, which is driven through Meson, I expected all libraries to be found correctly. Instead, I get an error of library not found at linking time. This is caused by the following snippet of code. The above snippet hardcodes the convention when passing import or static libraries' names. However, this is not consistent with , which is already handled correctly in a separate portion of the Rust compiler: The result of the above is that Rust, under MSVC, will happily put together and , but will fail utterly when a is demanded under the present set of circumstances. This is the other half required to completely address the issue in -- I tried working around this by inserting plus setting the correct file name, as shown in , but it returns an error: This is already known and was never addressed: <!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summaryBacktrace of the big linker error</summary<p</p</details
Any update on this issue?
I see you have done quite a bit of work here, thank you! Is there anything I can do to help move this forward? I can try to build this custom branch and test if it works?
Apologies, I now see the relevant issue is already being worked on!

Discussion:
use cc::windows_registry; use rustc_hir::def_id::{CrateNum, LOCAL_CRATE}; <del> use rustc_metadata::{find_native_static_library, try_find_native_static_library}; </del> <ins> use rustc_metadata::{ find_native_static_library, try_find_native_dynamic_library, try_find_native_static_library, }; </ins> use rustc_middle::bug; use rustc_middle::middle::dependency_format::Linkage; use rustc_middle::middle::exported_symbols;

} fn link_dylib_by_name(&mut self, name: &str, verbatim: bool, _as_needed: bool) { <del> self.link_arg(format!("{}{}", name, if verbatim { "" } else { ".lib" })); </del> <ins> // On MSVC-like targets rustc supports import libraries using alternative naming // scheme (`libfoo.a`) unsupported by linker, search for such libraries manually. if let Some(path) = try_find_native_dynamic_library(self.sess, name, verbatim) { self.link_arg(path); } else { self.link_arg(format!("{}{}", name, if verbatim { "" } else { ".lib" })); } </ins> } fn link_dylib_by_path(&mut self, path: &Path, _as_needed: bool) {

pub use creader::{load_symbol_from_dylib, DylibError}; pub use fs::{emit_wrapper_file, METADATA_FILENAME}; pub use native_libs::{ <del> find_native_static_library, try_find_native_static_library, walk_native_lib_search_dirs, </del> <ins> find_native_static_library, try_find_native_dynamic_library, try_find_native_static_library, walk_native_lib_search_dirs, </ins> }; pub use rmeta::{encode_metadata, rendered_const, EncodedMetadata, METADATA_HEADER};

.break_value() } <ins> pub fn try_find_native_dynamic_library( sess: &Session, name: &str, verbatim: bool, ) -> Option<PathBuf> { let formats = if verbatim { vec![("".into(), "".into())] } else { // While the official naming convention for MSVC import libraries // is foo.lib... let os = (sess.target.staticlib_prefix.clone(), sess.target.staticlib_suffix.clone()); // ... Meson follows the libfoo.dll.a convention to // disambiguate .a for static libraries let meson = ("lib".into(), ".dll.a".into()); // and MinGW uses .a altogether let mingw = ("lib".into(), ".a".into()); vec![os, meson, mingw] }; walk_native_lib_search_dirs( sess, LinkSelfContainedComponents::empty(), None, |dir, is_framework| { if !is_framework { for (prefix, suffix) in &formats { let test = dir.join(format!("{prefix}{name}{suffix}")); if test.exists() { return ControlFlow::Break(test); } } } ControlFlow::Continue(()) }, ) .break_value() } </ins> pub fn find_native_static_library(name: &str, verbatim: bool, sess: &Session) -> PathBuf { try_find_native_static_library(sess, name, verbatim) .unwrap_or_else(|| sess.dcx().emit_fatal(errors::MissingNativeLibrary::new(name, verbatim)))