Skip to content

Conversation

@ZuseZ4
Copy link
Member

@ZuseZ4 ZuseZ4 commented Nov 12, 2025

Based on your feedback, I started to provide a nice error message for a lack of lto=fat, instead of us forcing it.

In a next step, we should replace RUSTFLAGS="-Zautodiff=Enable" with another Cargo.toml setting, as discussed here: #147487 (comment)

As another improvement, we should also figure out why rlib builds do not properly obey the fat=lto setting.

@bjorn3

@rustbot
Copy link
Collaborator

rustbot commented Nov 12, 2025

r? @madsmtm

rustbot has assigned @madsmtm.
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 A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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 Nov 12, 2025
@rustbot

This comment has been minimized.

@ZuseZ4 ZuseZ4 changed the title provide an error if an autodiff user does not set in their Cargo.toml provide an error if an autodiff user does not enable lto=fat in their Cargo.toml Nov 12, 2025
@ZuseZ4 ZuseZ4 changed the title provide an error if an autodiff user does not enable lto=fat in their Cargo.toml Error if an autodiff user does not set lto=fat Nov 12, 2025
@ZuseZ4
Copy link
Member Author

ZuseZ4 commented Nov 12, 2025

r? @bjorn3

@rustbot
Copy link
Collaborator

rustbot commented Nov 12, 2025

Failed to set assignee to bjorn: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@rustbot rustbot assigned bjorn3 and unassigned madsmtm Nov 12, 2025
@ZuseZ4 ZuseZ4 force-pushed the autodiff-lto-error branch from b097bb6 to 370542e Compare November 12, 2025 03:50
@rustbot
Copy link
Collaborator

rustbot commented Nov 12, 2025

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@ZuseZ4 ZuseZ4 force-pushed the autodiff-lto-error branch from 370542e to 9b84ba2 Compare November 12, 2025 03:53
@rust-log-analyzer

This comment has been minimized.

@ZuseZ4 ZuseZ4 force-pushed the autodiff-lto-error branch from 9b84ba2 to b07b6fa Compare November 12, 2025 04:01
@rust-log-analyzer

This comment has been minimized.

@ZuseZ4 ZuseZ4 force-pushed the autodiff-lto-error branch from b07b6fa to 1f700b6 Compare November 12, 2025 04:12
@rust-log-analyzer

This comment has been minimized.

@ZuseZ4 ZuseZ4 force-pushed the autodiff-lto-error branch from 1f700b6 to c8bae8c Compare November 12, 2025 04:44
@rustbot
Copy link
Collaborator

rustbot commented Nov 16, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rust-log-analyzer

This comment has been minimized.

@bjorn3
Copy link
Member

bjorn3 commented Nov 16, 2025

The first two commits LGTM.

@rustbot
Copy link
Collaborator

rustbot commented Nov 16, 2025

This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp.

@rustbot rustbot added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Nov 16, 2025
@rust-log-analyzer
Copy link
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[TIMING:end] tool::ToolBuild { build_compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu, tool: "tidy", path: "src/tools/tidy", mode: ToolBootstrap, source_type: InTree, extra_features: [], allow_features: "", cargo_args: [], artifact_kind: Binary } -- 11.798
[TIMING:end] tool::Tidy { compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu } -- 0.000
fmt check
Diff in /checkout/compiler/rustc_codegen_llvm/src/intrinsic.rs:15:
 use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, HasTypingEnv, LayoutOf};
 use rustc_middle::ty::{self, GenericArgsRef, Instance, SimdAlign, Ty, TyCtxt, TypingEnv};
 use rustc_middle::{bug, span_bug};
+use rustc_session::config::CrateType;
 use rustc_span::{Span, Symbol, sym};
 use rustc_symbol_mangling::{mangle_internal_symbol, symbol_name_for_instance_in_crate};
 use rustc_target::callconv::PassMode;
Diff in /checkout/compiler/rustc_codegen_llvm/src/intrinsic.rs:21:
 use rustc_target::spec::Os;
 use tracing::debug;
 
-use rustc_session::config::CrateType;
-
 use crate::abi::FnAbiLlvmExt;
 use crate::builder::Builder;
 use crate::builder::autodiff::{adjust_activity_to_abi, generate_enzyme_call};
Diff in /checkout/compiler/rustc_codegen_llvm/src/intrinsic.rs:1148:
     if !tcx.sess.opts.unstable_opts.autodiff.contains(&rustc_session::config::AutoDiff::Enable) {
         let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutEnable);
     }
-//pub enum CrateType {
-//    Executable,
-//    Dylib,
-//    Rlib,
-//    Staticlib,
-//    Cdylib,
-//    ProcMacro,
-//    Sdylib,
-//}
+    //pub enum CrateType {
+    //    Executable,
+    //    Dylib,
+    //    Rlib,
+    //    Staticlib,
+    //    Cdylib,
+    //    ProcMacro,
+    //    Sdylib,
+    //}
     let ct = tcx.crate_types();
     let lto = tcx.sess.lto();
     if ct.len() == 1 && ct.contains(&CrateType::Executable) {
Diff in /checkout/compiler/rustc_codegen_llvm/src/intrinsic.rs:1164:
             //let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithIncompatibleCrateType);
         }
     } else {
-        ;
-        if lto != rustc_session::config::Lto::Fat && !tcx.sess.opts.cg.linker_plugin_lto.enabled(){
+        if lto != rustc_session::config::Lto::Fat && !tcx.sess.opts.cg.linker_plugin_lto.enabled() {
             //let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithIncompatibleCrateType);
         }
     }
Diff in /checkout/compiler/rustc_mir_transform/src/cross_crate_inline.rs:34:
         return true;
     }
 
-    if tcx.has_attr(def_id, sym::autodiff_forward) || tcx.has_attr(def_id, sym::autodiff_reverse) || tcx.has_attr(def_id, sym::rustc_autodiff) {
+    if tcx.has_attr(def_id, sym::autodiff_forward)
+        || tcx.has_attr(def_id, sym::autodiff_reverse)
+        || tcx.has_attr(def_id, sym::rustc_autodiff)
+    {
         return true;
     }
 
fmt: checked 6547 files

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

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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