Skip to content

Commit e67d502

Browse files
committed
Fix autodiff incorrectly applying fat-lto to proc-macro crates
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 <[email protected]>
1 parent 779e19d commit e67d502

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compiler/rustc_session/src/session.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,8 @@ impl Session {
603603
// Autodiff currently requires fat-lto to have access to the llvm-ir of all (indirectly) used functions and types.
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.
606-
if self.opts.autodiff_enabled() {
606+
// Don't apply fat-lto to proc-macro crates as they cannot use fat-lto without -Zdylib-lto
607+
if self.opts.autodiff_enabled() && !self.opts.crate_types.contains(&CrateType::ProcMacro) {
607608
return config::Lto::Fat;
608609
}
609610

0 commit comments

Comments
 (0)