From 9ebeb284b588c0549dca2169227cabb7417825be Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Sun, 24 Apr 2022 13:13:41 +0100 Subject: [PATCH] Fix MSVC hang issue --- compiler/rustc_codegen_ssa/src/back/link.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 45ae5ffc513..2dc3f4e8f3a 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1691,6 +1691,12 @@ fn add_linked_symbol_object( return; }; + // NOTE(nbdd0121): MSVC will hang if the input object file contains no sections, + // so add an empty section. + if file.format() == object::BinaryFormat::Coff { + file.add_section(Vec::new(), ".text".into(), object::SectionKind::Text); + } + for (sym, kind) in symbols.iter() { file.add_symbol(object::write::Symbol { name: sym.clone().into(),