Skip to content

Commit cc16d04

Browse files
Rollup merge of rust-lang#62615 - wesleywiser:pgo_error, r=nagisa
Only error about MSVC + PGO + unwind if we're generating code In rust-lang#61853, we changed the error when using PGO & MSVC toolchain & panic=unwind into a warning. However, in the compiler team meeting on 2019-07-11, we found that not everybody was in favor of that change because of the possibility of broken binaries. This PR reverts that change so this is again an error. However, to work around an [issue the Firefox team is having](rust-lang#61002 (comment)), we will only emit the error if we're actually supposed to generate a binary. If the `rustc` is invoked with `--print` arguments (which means that no binary will actually be emitted), then we won't emit the error because there is not a possibility of the issue occurring. cc @EricRahm @nikomatsakis @pnkfelix @Centril
2 parents 7fc80b6 + 3622311 commit cc16d04

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/librustc/session/mod.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::lint;
99
use crate::lint::builtin::BuiltinLintDiagnostics;
1010
use crate::middle::allocator::AllocatorKind;
1111
use crate::middle::dependency_format;
12-
use crate::session::config::{OutputType, SwitchWithOptPath};
12+
use crate::session::config::{OutputType, PrintRequest, SwitchWithOptPath};
1313
use crate::session::search_paths::{PathKind, SearchPath};
1414
use crate::util::nodemap::{FxHashMap, FxHashSet};
1515
use crate::util::common::{duration_to_secs_str, ErrorReported};
@@ -1303,15 +1303,18 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
13031303
}
13041304

13051305
// PGO does not work reliably with panic=unwind on Windows. Let's make it
1306-
// a warning to combine the two for now. It always runs into an assertions
1306+
// an error to combine the two for now. It always runs into an assertions
13071307
// if LLVM is built with assertions, but without assertions it sometimes
13081308
// does not crash and will probably generate a corrupted binary.
1309+
// We should only display this error if we're actually going to run PGO.
1310+
// If we're just supposed to print out some data, don't show the error (#61002).
13091311
if sess.opts.cg.profile_generate.enabled() &&
13101312
sess.target.target.options.is_like_msvc &&
1311-
sess.panic_strategy() == PanicStrategy::Unwind {
1312-
sess.warn("Profile-guided optimization does not yet work in conjunction \
1313-
with `-Cpanic=unwind` on Windows when targeting MSVC. \
1314-
See https://github.com/rust-lang/rust/issues/61002 for details.");
1313+
sess.panic_strategy() == PanicStrategy::Unwind &&
1314+
sess.opts.prints.iter().all(|&p| p == PrintRequest::NativeStaticLibs) {
1315+
sess.err("Profile-guided optimization does not yet work in conjunction \
1316+
with `-Cpanic=unwind` on Windows when targeting MSVC. \
1317+
See https://github.com/rust-lang/rust/issues/61002 for details.");
13151318
}
13161319
}
13171320

0 commit comments

Comments
 (0)