From 374daa7985ec779b1c674fdab2e04e47f4c4094e Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Thu, 11 Jul 2019 21:50:00 -0400 Subject: [PATCH 1/2] Revert "Emit warning when trying to use PGO in conjunction with unwinding on Windows." This reverts commit 74a39a39a4a0650d110083afa6e0b226f7b61ca9. --- src/librustc/session/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index b17ba8de73049..3cbf0ee213ae3 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -1303,15 +1303,15 @@ fn validate_commandline_args_with_session_available(sess: &Session) { } // PGO does not work reliably with panic=unwind on Windows. Let's make it - // a warning to combine the two for now. It always runs into an assertions + // an error to combine the two for now. It always runs into an assertions // if LLVM is built with assertions, but without assertions it sometimes // does not crash and will probably generate a corrupted binary. if sess.opts.cg.profile_generate.enabled() && sess.target.target.options.is_like_msvc && sess.panic_strategy() == PanicStrategy::Unwind { - sess.warn("Profile-guided optimization does not yet work in conjunction \ - with `-Cpanic=unwind` on Windows when targeting MSVC. \ - See https://github.com/rust-lang/rust/issues/61002 for details."); + sess.err("Profile-guided optimization does not yet work in conjunction \ + with `-Cpanic=unwind` on Windows when targeting MSVC. \ + See https://github.com/rust-lang/rust/issues/61002 for details."); } } From 3622311d53b6aeb454bfc55cec5e6b06f88597c8 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Thu, 11 Jul 2019 21:46:32 -0400 Subject: [PATCH 2/2] Only error about MSVC + PGO + unwind if we're generating code When `rustc` is invoked with the `--print` argument, we don't actually generate any code (unless it's the `native-static-libs` option). So we don't need to error our in this case since there's no risk of generating either LLVM assertions or corrupted binaries. --- src/librustc/session/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 3cbf0ee213ae3..664926a152f14 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -9,7 +9,7 @@ use crate::lint; use crate::lint::builtin::BuiltinLintDiagnostics; use crate::middle::allocator::AllocatorKind; use crate::middle::dependency_format; -use crate::session::config::{OutputType, SwitchWithOptPath}; +use crate::session::config::{OutputType, PrintRequest, SwitchWithOptPath}; use crate::session::search_paths::{PathKind, SearchPath}; use crate::util::nodemap::{FxHashMap, FxHashSet}; use crate::util::common::{duration_to_secs_str, ErrorReported}; @@ -1306,9 +1306,12 @@ fn validate_commandline_args_with_session_available(sess: &Session) { // an error to combine the two for now. It always runs into an assertions // if LLVM is built with assertions, but without assertions it sometimes // does not crash and will probably generate a corrupted binary. + // We should only display this error if we're actually going to run PGO. + // If we're just supposed to print out some data, don't show the error (#61002). if sess.opts.cg.profile_generate.enabled() && sess.target.target.options.is_like_msvc && - sess.panic_strategy() == PanicStrategy::Unwind { + sess.panic_strategy() == PanicStrategy::Unwind && + sess.opts.prints.iter().all(|&p| p == PrintRequest::NativeStaticLibs) { sess.err("Profile-guided optimization does not yet work in conjunction \ with `-Cpanic=unwind` on Windows when targeting MSVC. \ See https://github.com/rust-lang/rust/issues/61002 for details.");