Skip to content

Commit e75f796

Browse files
committed
Fix autodiff incorrectly applying fat-lto to proc-macro crates
Fixes #147487 When -Z autodiff=Enable is used, the compiler automatically enables fat-lto for all crates. However, proc-macro crates cannot use fat-lto without the -Zdylib-lto flag, causing compilation errors. This commit modifies the lto() method in Session to exclude proc-macro crates from fat-lto when autodiff is enabled, while preserving the existing behavior for all other crate types. The fix ensures that: - Non-proc-macro crates still get fat-lto when autodiff is enabled - Proc-macro crates are excluded from fat-lto when autodiff is enabled - Existing autodiff functionality remains unchanged for regular crates Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
1 parent 779e19d commit e75f796

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/rustc_session/src/session.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,10 @@ impl Session {
604604
// fat-lto is the easiest solution to this requirement, but quite expensive.
605605
// FIXME(autodiff): Make autodiff also work with embed-bc instead of fat-lto.
606606
if self.opts.autodiff_enabled() {
607-
return config::Lto::Fat;
607+
// Don't apply fat-lto to proc-macro crates as they cannot use fat-lto without -Zdylib-lto
608+
if !self.opts.crate_types.contains(&CrateType::ProcMacro) {
609+
return config::Lto::Fat;
610+
}
608611
}
609612

610613
// If our target has codegen requirements ignore the command line

0 commit comments

Comments
 (0)