Open
Description
Cargo.toml
:
[package]
name = "x"
edition = "2024"
[profile.dev]
lto = "fat"
panic = "abort"
[lib]
crate-type = ["staticlib"]
lib.rs
:
#![no_std]
#![feature(autodiff)]
#[core::autodiff::autodiff_forward(fd_inner, Dual)]
fn f(_x: &mut f64) {}
#[unsafe(no_mangle)]
pub extern "C" fn fd(x: &mut f64, xd: &mut f64) {
fd_inner(x, xd);
}
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
Shell:
$ RUSTFLAGS="-Zautodiff=Enable" cargo +enzyme build -Zbuild-std=core
Command output
thread 'lto everything' panicked at compiler/rustc_codegen_llvm/src/back/lto.rs:682:17:
Expected __enzyme function to have 'noinline' before adding 'alwaysinline'
stack backtrace:
0: 0x7f88c79f7ae2 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h3f25e7a042e0f78f
1: 0x7f88c7a46453 - core::fmt::write::h9228492c07172c71
2: 0x7f88c79ec1e3 - std::io::Write::write_fmt::hbc89b049541b1f3f
3: 0x7f88c79f7932 - std::sys::backtrace::BacktraceLock::print::h84d9c59f112a45df
4: 0x7f88c79fb50c - std::panicking::default_hook::{{closure}}::h5230ec8d3834b5dc
5: 0x7f88c79fb30f - std::panicking::default_hook::h82fc2bc32e1ed222
6: 0x7f88c4183f64 - std[c965b0aa6c3056df]::panicking::update_hook::<alloc[d932a86623700fa6]::boxed::Box<rustc_driver_impl[28dea0fc8a3e7921]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7f88c79fbfdb - std::panicking::rust_panic_with_hook::h7841a0c9dd31384d
8: 0x7f88c79fbc96 - std::panicking::begin_panic_handler::{{closure}}::h83c1a92f8f557062
9: 0x7f88c79f7fd9 - std::sys::backtrace::__rust_end_short_backtrace::h7938b01b46b63f31
10: 0x7f88c79fb95d - __rustc[b7e3ce0d707010f2]::rust_begin_unwind
11: 0x7f88c4117620 - core::panicking::panic_fmt::hd8c0c8aacdff9232
12: 0x7f88c45dcdad - rustc_codegen_llvm[bce89ecd7059794]::back::lto::run_pass_manager
13: 0x7f88c45a94f0 - <rustc_codegen_ssa[7df531b5a2ead9db]::back::lto::LtoModuleCodegen<rustc_codegen_llvm[bce89ecd7059794]::LlvmCodegenBackend>>::optimize
14: 0x7f88c455cad4 - std[c965b0aa6c3056df]::sys::backtrace::__rust_begin_short_backtrace::<<rustc_codegen_llvm[bce89ecd7059794]::LlvmCodegenBackend as rustc_codegen_ssa[7df531b5a2ead9db]::traits::backend::ExtraBackendMethods>::spawn_named_thread<rustc_codegen_ssa[7df531b5a2ead9db]::back::write::spawn_work<rustc_codegen_llvm[bce89ecd7059794]::LlvmCodegenBackend>::{closure#0}, ()>::{closure#0}, ()>
15: 0x7f88c4565180 - <<std[c965b0aa6c3056df]::thread::Builder>::spawn_unchecked_<<rustc_codegen_llvm[bce89ecd7059794]::LlvmCodegenBackend as rustc_codegen_ssa[7df531b5a2ead9db]::traits::backend::ExtraBackendMethods>::spawn_named_thread<rustc_codegen_ssa[7df531b5a2ead9db]::back::write::spawn_work<rustc_codegen_llvm[bce89ecd7059794]::LlvmCodegenBackend>::{closure#0}, ()>::{closure#0}, ()>::{closure#1} as core[53647cb28d9a8e2]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
16: 0x7f88c7a00667 - std::sys::pal::unix::thread::Thread::new::thread_start::h208e5045c7868bf5
17: 0x7f88c368c579 - start_thread
at ./nptl/pthread_create.c:448:8
18: 0x7f88c3706858 - __GI___clone3
at /builddir/glibc-2.41/misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
19: 0x0 - <unknown>
error: the compiler unexpectedly panicked. this is a
[rustc-ice-2025-07-15T23_26_35-31913.txt](https://github.com/user-attachments/files/21244947/rustc-ice-2025-07-15T23_26_35-31913.txt)
bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: please make sure that you have updated to the latest nightly
note: please attach the file at `/home/sabrina/resources/downloads/x/rustc-ice-2025-07-15T23_26_35-31913.txt` to your bug report
note: compiler flags: --crate-type staticlib -C panic=abort -C lto=fat -C debuginfo=2 -C linker=/usr/bin/clang -C incremental=[REDACTED] -Z unstable-options -Z autodiff=Enable
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
thread 'coordinator' panicked at /home/sabrina/.local/src/enzyme-rust/compiler/rustc_codegen_ssa/src/back/write.rs:1679:29:
/home/sabrina/.local/src/enzyme-rust/compiler/rustc_codegen_ssa/src/back/write.rs:1679:29: worker thread panicked
stack backtrace:
0: 0x7f88c79f7ae2 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h3f25e7a042e0f78f
1: 0x7f88c7a46453 - core::fmt::write::h9228492c07172c71
2: 0x7f88c79ec1e3 - std::io::Write::write_fmt::hbc89b049541b1f3f
3: 0x7f88c79f7932 - std::sys::backtrace::BacktraceLock::print::h84d9c59f112a45df
4: 0x7f88c79fb50c - std::panicking::default_hook::{{closure}}::h5230ec8d3834b5dc
5: 0x7f88c79fb30f - std::panicking::default_hook::h82fc2bc32e1ed222
6: 0x7f88c4183f64 - std[c965b0aa6c3056df]::panicking::update_hook::<alloc[d932a86623700fa6]::boxed::Box<rustc_driver_impl[28dea0fc8a3e7921]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7f88c79fbfdb - std::panicking::rust_panic_with_hook::h7841a0c9dd31384d
8: 0x7f88c73cc391 - std[c965b0aa6c3056df]::panicking::begin_panic::<alloc[d932a86623700fa6]::string::String>::{closure#0}
9: 0x7f88c73cbb46 - std[c965b0aa6c3056df]::sys::backtrace::__rust_end_short_backtrace::<std[c965b0aa6c3056df]::panicking::begin_panic<alloc[d932a86623700fa6]::string::String>::{closure#0}, !>
10: 0x7f88c40d93ce - std[c965b0aa6c3056df]::panicking::begin_panic::<alloc[d932a86623700fa6]::string::String>
11: 0x7f88c7350873 - rustc_middle[e08a5b757b72e5be]::util::bug::opt_span_bug_fmt::<rustc_span[77eec0292c158de8]::span_encoding::Span>::{closure#0}
12: 0x7f88c734e12e - rustc_middle[e08a5b757b72e5be]::ty::context::tls::with_opt::<rustc_middle[e08a5b757b72e5be]::util::bug::opt_span_bug_fmt<rustc_span[77eec0292c158de8]::span_encoding::Span>::{closure#0}, !>::{closure#0}
13: 0x7f88c734e0eb - rustc_middle[e08a5b757b72e5be]::ty::context::tls::with_context_opt::<rustc_middle[e08a5b757b72e5be]::ty::context::tls::with_opt<rustc_middle[e08a5b757b72e5be]::util::bug::opt_span_bug_fmt<rustc_span[77eec0292c158de8]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
14: 0x7f88c40bfaa2 - rustc_middle[e08a5b757b72e5be]::util::bug::bug_fmt
15: 0x7f88c455feaf - std[c965b0aa6c3056df]::sys::backtrace::__rust_begin_short_backtrace::<<rustc_codegen_llvm[bce89ecd7059794]::LlvmCodegenBackend as rustc_codegen_ssa[7df531b5a2ead9db]::traits::backend::ExtraBackendMethods>::spawn_named_thread<rustc_codegen_ssa[7df531b5a2ead9db]::back::write::start_executing_work<rustc_codegen_llvm[bce89ecd7059794]::LlvmCodegenBackend>::{closure#5}, core[53647cb28d9a8e2]::result::Result<rustc_codegen_ssa[7df531b5a2ead9db]::back::write::CompiledModules, ()>>::{closure#0}, core[53647cb28d9a8e2]::result::Result<rustc_codegen_ssa[7df531b5a2ead9db]::back::write::CompiledModules, ()>>
16: 0x7f88c45654d7 - <<std[c965b0aa6c3056df]::thread::Builder>::spawn_unchecked_<<rustc_codegen_llvm[bce89ecd7059794]::LlvmCodegenBackend as rustc_codegen_ssa[7df531b5a2ead9db]::traits::backend::ExtraBackendMethods>::spawn_named_thread<rustc_codegen_ssa[7df531b5a2ead9db]::back::write::start_executing_work<rustc_codegen_llvm[bce89ecd7059794]::LlvmCodegenBackend>::{closure#5}, core[53647cb28d9a8e2]::result::Result<rustc_codegen_ssa[7df531b5a2ead9db]::back::write::CompiledModules, ()>>::{closure#0}, core[53647cb28d9a8e2]::result::Result<rustc_codegen_ssa[7df531b5a2ead9db]::back::write::CompiledModules, ()>>::{closure#1} as core[53647cb28d9a8e2]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
17: 0x7f88c7a00667 - std::sys::pal::unix::thread::Thread::new::thread_start::h208e5045c7868bf5
18: 0x7f88c368c579 - start_thread
at ./nptl/pthread_create.c:448:8
19: 0x7f88c3706858 - __GI___clone3
at /builddir/glibc-2.41/misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
20: 0x0 - <unknown>
error: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: please make sure that you have updated to the latest nightly
note: please attach the file at `/home/sabrina/resources/downloads/x/rustc-ice-2025-07-15T23_26_35-31913.txt` to your bug report
note: compiler flags: --crate-type staticlib -C panic=abort -C lto=fat -C debuginfo=2 -C linker=/usr/bin/clang -C incremental=[REDACTED] -Z unstable-options -Z autodiff=Enable
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
thread 'rustc' panicked at /home/sabrina/.local/src/enzyme-rust/compiler/rustc_codegen_ssa/src/back/write.rs:2048:17:
/home/sabrina/.local/src/enzyme-rust/compiler/rustc_codegen_ssa/src/back/write.rs:2048:17: panic during codegen/LLVM phase
stack backtrace:
0: 0x7f88c79f7ae2 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h3f25e7a042e0f78f
1: 0x7f88c7a46453 - core::fmt::write::h9228492c07172c71
2: 0x7f88c79ec1e3 - std::io::Write::write_fmt::hbc89b049541b1f3f
3: 0x7f88c79f7932 - std::sys::backtrace::BacktraceLock::print::h84d9c59f112a45df
4: 0x7f88c79fb50c - std::panicking::default_hook::{{closure}}::h5230ec8d3834b5dc
5: 0x7f88c79fb30f - std::panicking::default_hook::h82fc2bc32e1ed222
6: 0x7f88c4183f64 - std[c965b0aa6c3056df]::panicking::update_hook::<alloc[d932a86623700fa6]::boxed::Box<rustc_driver_impl[28dea0fc8a3e7921]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7f88c79fbfdb - std::panicking::rust_panic_with_hook::h7841a0c9dd31384d
8: 0x7f88c73cc391 - std[c965b0aa6c3056df]::panicking::begin_panic::<alloc[d932a86623700fa6]::string::String>::{closure#0}
9: 0x7f88c73cbb46 - std[c965b0aa6c3056df]::sys::backtrace::__rust_end_short_backtrace::<std[c965b0aa6c3056df]::panicking::begin_panic<alloc[d932a86623700fa6]::string::String>::{closure#0}, !>
10: 0x7f88c40d93ce - std[c965b0aa6c3056df]::panicking::begin_panic::<alloc[d932a86623700fa6]::string::String>
11: 0x7f88c7350873 - rustc_middle[e08a5b757b72e5be]::util::bug::opt_span_bug_fmt::<rustc_span[77eec0292c158de8]::span_encoding::Span>::{closure#0}
12: 0x7f88c734e12e - rustc_middle[e08a5b757b72e5be]::ty::context::tls::with_opt::<rustc_middle[e08a5b757b72e5be]::util::bug::opt_span_bug_fmt<rustc_span[77eec0292c158de8]::span_encoding::Span>::{closure#0}, !>::{closure#0}
13: 0x7f88c734e0eb - rustc_middle[e08a5b757b72e5be]::ty::context::tls::with_context_opt::<rustc_middle[e08a5b757b72e5be]::ty::context::tls::with_opt<rustc_middle[e08a5b757b72e5be]::util::bug::opt_span_bug_fmt<rustc_span[77eec0292c158de8]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
14: 0x7f88c40bfaa2 - rustc_middle[e08a5b757b72e5be]::util::bug::bug_fmt
15: 0x7f88c456e242 - <rustc_codegen_llvm[bce89ecd7059794]::LlvmCodegenBackend as rustc_codegen_ssa[7df531b5a2ead9db]::traits::backend::CodegenBackend>::join_codegen
16: 0x7f88c4477e8d - <rustc_session[e31657d8de1833ae]::session::Session>::time::<(rustc_codegen_ssa[7df531b5a2ead9db]::CodegenResults, indexmap[f276a117077b3f49]::map::IndexMap<rustc_query_system[faaf69be6e3ce6f9]::dep_graph::dep_node::WorkProductId, rustc_query_system[faaf69be6e3ce6f9]::dep_graph::graph::WorkProduct, core[53647cb28d9a8e2]::hash::BuildHasherDefault<rustc_hash[6e3d156247ef71f7]::FxHasher>>), <rustc_interface[10c066c5fa93f038]::queries::Linker>::link::{closure#0}>
17: 0x7f88c43c2d78 - <rustc_interface[10c066c5fa93f038]::queries::Linker>::link
18: 0x7f88c415ad1d - rustc_interface[10c066c5fa93f038]::interface::run_compiler::<(), rustc_driver_impl[28dea0fc8a3e7921]::run_compiler::{closure#0}>::{closure#1}
19: 0x7f88c4150fec - <scoped_tls[e1331b77299fe260]::ScopedKey<rustc_span[77eec0292c158de8]::SessionGlobals>>::set::<rustc_interface[10c066c5fa93f038]::util::run_in_thread_with_globals<rustc_interface[10c066c5fa93f038]::util::run_in_thread_pool_with_globals<rustc_interface[10c066c5fa93f038]::interface::run_compiler<(), rustc_driver_impl[28dea0fc8a3e7921]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>
20: 0x7f88c41c0abf - std[c965b0aa6c3056df]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[10c066c5fa93f038]::util::run_in_thread_with_globals<rustc_interface[10c066c5fa93f038]::util::run_in_thread_pool_with_globals<rustc_interface[10c066c5fa93f038]::interface::run_compiler<(), rustc_driver_impl[28dea0fc8a3e7921]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
21: 0x7f88c415bad6 - <<std[c965b0aa6c3056df]::thread::Builder>::spawn_unchecked_<rustc_interface[10c066c5fa93f038]::util::run_in_thread_with_globals<rustc_interface[10c066c5fa93f038]::util::run_in_thread_pool_with_globals<rustc_interface[10c066c5fa93f038]::interface::run_compiler<(), rustc_driver_impl[28dea0fc8a3e7921]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[53647cb28d9a8e2]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
22: 0x7f88c7a00667 - std::sys::pal::unix::thread::Thread::new::thread_start::h208e5045c7868bf5
23: 0x7f88c368c579 - start_thread
at ./nptl/pthread_create.c:448:8
24: 0x7f88c3706858 - __GI___clone3
at /builddir/glibc-2.41/misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
25: 0x0 - <unknown>
error: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: please make sure that you have updated to the latest nightly
note: please attach the file at `/home/sabrina/resources/downloads/x/rustc-ice-2025-07-15T23_26_35-31913.txt` to your bug report
note: compiler flags: --crate-type staticlib -C panic=abort -C lto=fat -C debuginfo=2 -C linker=/usr/bin/clang -C incremental=[REDACTED] -Z unstable-options -Z autodiff=Enable
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: could not compile `x` (lib)
Caused by:
process didn't exit successfully: `/home/sabrina/.local/share/rustup/toolchains/enzyme/bin/rustc --crate-name x --edition=2024 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=174 --crate-type staticlib --emit=dep-info,link -C panic=abort -C lto=fat -C debuginfo=2 --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=dcc3d9cd00e3150b -C extra-filename=-992b7a02b421674d --out-dir /home/sabrina/resources/downloads/x/target/debug/deps -C linker=/usr/bin/clang -C incremental=/home/sabrina/resources/downloads/x/target/debug/incremental -L dependency=/home/sabrina/resources/downloads/x/target/debug/deps --extern 'noprelude:compiler_builtins=/home/sabrina/resources/downloads/x/target/debug/deps/libcompiler_builtins-05171f310726c287.rlib' --extern 'noprelude:core=/home/sabrina/resources/downloads/x/target/debug/deps/libcore-e3e03fc1a89d1eb8.rlib' -Z unstable-options -Zautodiff=Enable` (exit status: 101)
Meta
rustc --version --verbose
:
rustc 1.90.0-nightly (3014e79f9 2025-07-15)
binary: rustc
commit-hash: 3014e79f9c8d5510ea7b3a3b70d171d0948b1e96
commit-date: 2025-07-15
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.8
The same code worked fine on 48aee7e, so this is a regression. I suspect this is related to #139308.