diff options
| author | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-02-19 02:04:49 +0100 |
|---|---|---|
| committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-03-25 03:30:05 +0200 |
| commit | 9c61c7284a39db3471b395ccc5704ef77dc653ed (patch) | |
| tree | 3cfbdfdaf11f3ac1041e35f55637098d0d4b7063 | |
| parent | 99127abca8c9678e14ee11bee4d46bc34ec8b164 (diff) | |
rustc_trans: Fix PGO generation linking on Linux by adding the relevant linker commands.
See the linked LLVM reviews for the clang counter-parts. Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
| -rw-r--r-- | src/librustc_trans/back/link.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 542cdc5baad..657563eac2c 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -1085,6 +1085,20 @@ fn link_args(cmd: &mut Linker, cmd.build_static_executable(); } + // If we're doing PGO generation stuff and on a GNU-like linker, use the + // "-u" flag to properly pull in the profiler runtime bits. + // + // This is because LLVM otherwise won't add the needed initialization for us + // on Linux (though the extra flag should be harmless if it does). + // + // See https://reviews.llvm.org/D14033 and https://reviews.llvm.org/D14030. + // + // Though it may be worth to try to revert those changes upstream, since the + // overhead of the initialization should be minor. + if sess.opts.cg.pgo_gen.is_some() && sess.target.target.options.linker_is_gnu { + cmd.args(&["-u".to_owned(), "__llvm_profile_runtime".to_owned()]); + } + // FIXME (#2397): At some point we want to rpath our guesses as to // where extern libraries might live, based on the // addl_lib_search_paths |
