Skip to content

Conversation

osamakader
Copy link
Contributor

@osamakader osamakader commented Oct 16, 2025

Fixes #147487

@rustbot
Copy link
Collaborator

rustbot commented Oct 16, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 16, 2025
@rustbot

This comment has been minimized.

@petrochenkov
Copy link
Contributor

r=me after fixing up the commit message #147792 (comment).
@bors rollup
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 17, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 17, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

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]>
@osamakader osamakader force-pushed the fix-autodiff-proc-macro-lto branch from e75f796 to e67d502 Compare October 17, 2025 13:53
@osamakader
Copy link
Contributor Author

@rustbot ready.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 17, 2025
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 17, 2025

📌 Commit e67d502 has been approved by petrochenkov

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 17, 2025
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Oct 17, 2025
…-lto, r=petrochenkov

Fix autodiff incorrectly applying fat-lto to proc-macro crates

Fixes rust-lang#147487
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Oct 17, 2025
…-lto, r=petrochenkov

Fix autodiff incorrectly applying fat-lto to proc-macro crates

Fixes rust-lang#147487
bors added a commit that referenced this pull request Oct 17, 2025
Rollup of 7 pull requests

Successful merges:

 - #140153 (Implement `Debug` for `EncodeWide`)
 - #147454 (Fix backtraces with `-C panic=abort` on qnx; emit unwind tables by default)
 - #147468 (Implement fs api set_times and set_times_nofollow)
 - #147494 (std::thread spawn: Docs: Link to Builder::spawn; Make same.)
 - #147783 (bootstrap: migrate to object 0.37)
 - #147792 (Fix autodiff incorrectly applying fat-lto to proc-macro crates )
 - #147809 (rustdoc: Fix passes order so intra-doc links are collected after stripping passes)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Oct 18, 2025
Rollup of 6 pull requests

Successful merges:

 - #146509 (Result/Option layout guarantee clarifications)
 - #147494 (std::thread spawn: Docs: Link to Builder::spawn; Make same.)
 - #147532 ( Port `#[cfg_attr]` to the new attribute parsing infrastructure)
 - #147783 (bootstrap: migrate to object 0.37)
 - #147792 (Fix autodiff incorrectly applying fat-lto to proc-macro crates )
 - #147809 (rustdoc: Fix passes order so intra-doc links are collected after stripping passes)

Failed merges:

 - #147813 (Warn on unused_attributes in uitests )

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7fa2030 into rust-lang:master Oct 18, 2025
11 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Oct 18, 2025
rust-timer added a commit that referenced this pull request Oct 18, 2025
Rollup merge of #147792 - osamakader:fix-autodiff-proc-macro-lto, r=petrochenkov

Fix autodiff incorrectly applying fat-lto to proc-macro crates

Fixes #147487
@ZuseZ4
Copy link
Member

ZuseZ4 commented Oct 19, 2025

This unfortunately didn't fix the case I posted in the tracking issue, so I reopened it.
But I also ran into this new error when I tried to fix it myself, and I think it's a step in the right direction.

 RUSTFLAGS="-Z autodiff=Enable,LooseTypes" cargo +enzyme build       
 Compiling proc-macro2 v1.0.101
   Compiling libm v0.2.15
   Compiling autocfg v1.5.0
   Compiling unicode-ident v1.0.19
   Compiling quote v1.0.41
   Compiling crossbeam-utils v0.8.21
   Compiling rand_core v0.6.4
   Compiling bytemuck v1.24.0
   Compiling cfg-if v1.0.3
   Compiling nano-gemm-codegen v0.1.0
   Compiling rayon-core v1.13.0
   Compiling version_check v0.9.5
   Compiling libc v0.2.176
   Compiling either v1.15.0
   Compiling reborrow v0.5.5
   Compiling dyn-stack-macros v0.1.0
   Compiling bitflags v2.9.4
   Compiling paste v1.0.15
   Compiling memchr v2.7.6
   Compiling rand v0.8.5
   Compiling raw-cpuid v11.6.0
   Compiling dyn-stack v0.13.2
   Compiling getrandom v0.3.3
   Compiling pulp v0.21.5
   Compiling once_cell v1.21.3
   Compiling num-traits v0.2.19
error: failed to get bitcode from object file for LTO (Can't find section .llvmbc)

error: could not compile `pulp` (build script) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `num-traits` (build script) due to 1 previous error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

autodiff incorrectly applies fat-lto to proc-macro crate.

5 participants