Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle autodiff for lib builds #137570

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Conversation

ZuseZ4
Copy link
Contributor

@ZuseZ4 ZuseZ4 commented Feb 24, 2025

Work in Progress.

Tracking:

r? @oli-obk

@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 Feb 24, 2025
@rust-log-analyzer

This comment has been minimized.

@ZuseZ4
Copy link
Contributor Author

ZuseZ4 commented Feb 25, 2025

The third (iffy) commit let's me compile and run the thin-lto pipeline for dependencies, but it runs into the following assertion:

thread 'coordinator' panicked at compiler/rustc_codegen_llvm/src/back/lto.rs:224:9:
internal error: entered unreachable code: We should never reach this case if the LTO step is deferred to the linker

Removing the assertion runs into the next one:

thread 'coordinator' panicked at /home/manuel/prog/rust-middle/compiler/rustc_codegen_ssa/src/back/write.rs:1521:29:
assertion failed: running_with_own_token > 0

That sounds like an assertion which I probably shouldn't touch.

I would have preferred to just support thin-lto instead of having to alter the compilation pipeline even more and move all other workers to fat-lto, since I was worried that would break other assumptions. But it might be easier, I'll look more into it.

The enforcing of fat-lto should be coupled to the user setting -Zautodiff=Enable, which can be checked using
config.autodiff.contains(&config::AutoDiff::Enable)

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-18 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
#21 exporting to docker image format
#21 sending tarball 27.7s done
#21 DONE 37.7s
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Listening on address 127.0.0.1:4226
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
   Compiling rustc_sanitizers v0.0.0 (/checkout/compiler/rustc_sanitizers)
   Compiling rustc_hir_analysis v0.0.0 (/checkout/compiler/rustc_hir_analysis)
   Compiling rustc_traits v0.0.0 (/checkout/compiler/rustc_traits)
   Compiling rustc_codegen_ssa v0.0.0 (/checkout/compiler/rustc_codegen_ssa)
error: unused import: `AutodiffWithoutLto`
  --> compiler/rustc_codegen_ssa/src/back/write.rs:44:21
   |
44 | use crate::errors::{AutodiffWithoutLto, ErrorCreatingRemarkDir};
   |
   = note: `-D unused-imports` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(unused_imports)]`

@bors
Copy link
Contributor

bors commented Mar 8, 2025

☔ The latest upstream changes (presumably #138177) made this pull request unmergeable. Please resolve the merge conflicts.

@ZuseZ4
Copy link
Contributor Author

ZuseZ4 commented Mar 10, 2025

@rustbot label +F-autodiff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-autodiff `#![feature(autodiff)]` 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants