diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index b52c5b4cd663b..78cec5a58448e 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -482,6 +482,10 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se config.using_internal_features, config.expanded_args, ); + // Forces lto="fat" if autodiff is enabled. + if sess.opts.unstable_opts.autodiff.contains(&config::AutoDiff::Enable) { + sess.opts.cg.lto = config::LtoCli::Fat; + } codegen_backend.init(&sess);