Skip to content

Commit 87c2552

Browse files
committed
Link extra libraries when using mcount on *-windows-gnu targets
libgmon needs to be linked. This also requires readding a few other system libraries to satisfy its dependencies.
1 parent cc2c5f9 commit 87c2552

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,13 @@ impl<'a> Linker for GccLinker<'a> {
737737
// This flag is also used when linking to choose target specific
738738
// libraries needed to enable profiling.
739739
self.cc_arg("-pg");
740+
// On windows-gnu targets, libgmon also needs to be linked, and this
741+
// requires readding libraries to satisfy its dependencies.
742+
if self.sess.target.is_like_windows {
743+
self.cc_arg("-lgmon");
744+
self.cc_arg("-lkernel32");
745+
self.cc_arg("-lmsvcrt");
746+
}
740747
}
741748

742749
fn control_flow_guard(&mut self) {}

0 commit comments

Comments
 (0)