File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -1085,6 +1085,20 @@ fn link_args(cmd: &mut Linker,
1085
1085
cmd. build_static_executable ( ) ;
1086
1086
}
1087
1087
1088
+ // If we're doing PGO generation stuff and on a GNU-like linker, use the
1089
+ // "-u" flag to properly pull in the profiler runtime bits.
1090
+ //
1091
+ // This is because LLVM otherwise won't add the needed initialization for us
1092
+ // on Linux (though the extra flag should be harmless if it does).
1093
+ //
1094
+ // See https://reviews.llvm.org/D14033 and https://reviews.llvm.org/D14030.
1095
+ //
1096
+ // Though it may be worth to try to revert those changes upstream, since the
1097
+ // overhead of the initialization should be minor.
1098
+ if sess. opts . cg . pgo_gen . is_some ( ) && sess. target . target . options . linker_is_gnu {
1099
+ cmd. args ( & [ "-u" . to_owned ( ) , "__llvm_profile_runtime" . to_owned ( ) ] ) ;
1100
+ }
1101
+
1088
1102
// FIXME (#2397): At some point we want to rpath our guesses as to
1089
1103
// where extern libraries might live, based on the
1090
1104
// addl_lib_search_paths
You can’t perform that action at this time.
0 commit comments