diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index 18b5c001f9922..647dce9f596d5 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -87,12 +87,12 @@ pub trait ArchiveBuilderBuilder { items: Vec, output_path: &Path, ) { - if common::is_using_dlltool(&sess.target) { - // The binutils linker used on -windows-gnu targets cannot read the import - // libraries generated by LLVM: in our attempts, the linker produced an .EXE - // that loaded but crashed with an AV upon calling one of the imported - // functions. Therefore, use binutils to create the import library instead, - // by writing a .DEF file to the temp dir and calling binutils's dlltool. + if common::is_using_dlltool(&sess.target) && sess.opts.cg.dlltool.is_some() { + // Previously we always used dlltool on -windows-gnu targets due to the binutils + // linker not entirely correctly handling import libraries generated by + // LLVM/ar_archive_writer. This has since been fixed. To ease the transition, will + // temporarily still use dlltool if explicitly specified, but use ar_archive_writer + // like on MSVC if not. create_mingw_dll_import_lib(sess, lib_name, items, output_path); } else { trace!("creating import library");