Skip to content

Conversation

@sgasho
Copy link
Contributor

@sgasho sgasho commented Jan 17, 2026

Export LLVM symbols from rustc_driver on Apple when autodiff is enabled.

On Apple targets, Enzyme can hang if rustc and Enzyme each embed their own LLVM. Exporting LLVM symbols from rustc_driver lets Enzyme reuse

dependencies: rust-lang/enzyme#31
This PR can be merged after rust-lang/enzyme#31 has been merged and enzyme submodule has been updated.

I applied diffs on this PR to #151063 then produced artifacts at https://github.com/rust-lang/rust/actions/runs/21091289355

I confirmed that /path/to/rustc -Zautodiff=Enable -Clto=fat test.rs successfully finished when I used those artifacts↑

r? @ZuseZ4

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 17, 2026
@sgasho sgasho marked this pull request as ready for review January 17, 2026 12:56
@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 Jan 17, 2026
@bjorn3
Copy link
Member

bjorn3 commented Jan 17, 2026

This seems like it has the same goal as #150992 except implemented in a hackier way.

@sgasho
Copy link
Contributor Author

sgasho commented Jan 17, 2026

Thanks for informing!
I took a look at #150992 and indeed that approach would be better.
I think I can wait until the PR to be merged

@sgasho sgasho marked this pull request as draft January 18, 2026 04:42
@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 Jan 18, 2026
@sgasho
Copy link
Contributor Author

sgasho commented Jan 19, 2026

After #150992 has been merged, I'll modify this PR or create a new PR to export LLVM symobls for autodiff on Apple target

I leave this PR as a draft for now

@ZuseZ4
Copy link
Member

ZuseZ4 commented Jan 20, 2026

Also @Kobzol , just for awareness.
As a trade-off for using libloading we'll need to make llvm symbols visible on macos, since we can't have two llvm copies embedded into rustc and enzyme. Making the symbols public might have a perf impact.

@Kobzol
Copy link
Member

Kobzol commented Jan 20, 2026

Is there any other potential perf. impact other than making the toolchain larger?

@ZuseZ4
Copy link
Member

ZuseZ4 commented Jan 21, 2026

I don't expect it to have any relevant runtime perf impact, but given the surface of LLVM and the complexity of our bootstrap (e.g. PGO) I also wouldn't be too surprised if there's a corner case where this affects a benchmark. On Linux I would have started a perf run, but since we don't have those for apple I'd just merge it when ready. I mainly wanted to make sure that you're aware and ok with this change.

@Kobzol
Copy link
Member

Kobzol commented Jan 21, 2026

Ok. Go ahead :)

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

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 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.

5 participants