Skip to content

Commit cf60705

Browse files
authored
Rollup merge of rust-lang#156000 - pmur:murp/fix-155972, r=wesleywiser
Fix ICE when using -Zinstrument-mcount and -Clinker-flavor=lld -Zinstrument-mcount passes -pg to the gnu linker command. This option is only supported by the cc frontend. This fixes rust-lang#155972
2 parents b39cdf5 + 74060d4 commit cf60705

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -736,13 +736,15 @@ impl<'a> Linker for GccLinker<'a> {
736736
fn enable_profiling(&mut self) {
737737
// This flag is also used when linking to choose target specific
738738
// libraries needed to enable profiling.
739-
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");
739+
if !self.is_ld {
740+
self.cc_arg("-pg");
741+
// On windows-gnu targets, libgmon also needs to be linked, and this
742+
// requires readding libraries to satisfy its dependencies.
743+
if self.sess.target.is_like_windows {
744+
self.cc_arg("-lgmon");
745+
self.cc_arg("-lkernel32");
746+
self.cc_arg("-lmsvcrt");
747+
}
746748
}
747749
}
748750

0 commit comments

Comments
 (0)