Skip to content

Commit 18d728c

Browse files
authored
Rollup merge of rust-lang#61005 - michaelwoerister:error-pgo-windows-unwind, r=zackmdavis
Emit error when trying to use PGO in conjunction with unwinding on Windows. This PR makes `rustc` emit an error when trying use PGO in conjunction with `-Cpanic=unwind` on Windows, isn't supported by LLVM yet. The error messages points to rust-lang#61002, which documents this known limitation.
2 parents c778205 + dd94dc3 commit 18d728c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/librustc/session/mod.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,18 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
12721272
sess.err("Linker plugin based LTO is not supported together with \
12731273
`-C prefer-dynamic` when targeting MSVC");
12741274
}
1275+
1276+
// PGO does not work reliably with panic=unwind on Windows. Let's make it
1277+
// an error to combine the two for now. It always runs into an assertions
1278+
// if LLVM is built with assertions, but without assertions it sometimes
1279+
// does not crash and will probably generate a corrupted binary.
1280+
if sess.opts.debugging_opts.pgo_gen.enabled() &&
1281+
sess.target.target.options.is_like_windows &&
1282+
sess.panic_strategy() == PanicStrategy::Unwind {
1283+
sess.err("Profile-guided optimization does not yet work in conjunction \
1284+
with `-Cpanic=unwind` on Windows. \
1285+
See https://github.com/rust-lang/rust/issues/61002 for details.");
1286+
}
12751287
}
12761288

12771289
/// Hash value constructed out of all the `-C metadata` arguments passed to the

0 commit comments

Comments
 (0)