Add -Zvirtual-function-elimination flag

Adds the virtual-function-elimination unstable compiler flag and a check
that this flag is only used in combination with -Clto. LLVM can only
apply this optimization with fat LTO.
This commit is contained in:
flip1995
2022-04-21 13:29:45 +01:00
committed by Philipp Krones
parent da895e7938
commit def3fd8e92
3 changed files with 10 additions and 6 deletions

View File

@@ -1431,14 +1431,14 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
);
}
// LLVM CFI requires LTO.
if sess.is_sanitizer_cfi_enabled() {
if sess.opts.cg.lto == config::LtoCli::Unspecified
|| sess.opts.cg.lto == config::LtoCli::No
|| sess.opts.cg.lto == config::LtoCli::Thin
{
// LLVM CFI and VFE both require LTO.
if sess.lto() != config::Lto::Fat {
if sess.is_sanitizer_cfi_enabled() {
sess.err("`-Zsanitizer=cfi` requires `-Clto`");
}
if sess.opts.debugging_opts.virtual_function_elimination {
sess.err("`-Zvirtual-function-elimination` requires `-Clto`");
}
}
if sess.opts.debugging_opts.stack_protector != StackProtector::None {