Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,53 @@ pub mod simd {
}

include!("primitive_docs.rs");

// Global metadata markers for the Enzyme autodiff backend.
// These are not read or written to by Rust code. They are required to survive
// Link-Time Optimization (LTO) so that Enzyme can correctly identify them
// as constant metadata variables when computing derivatives.
#[unstable(feature = "autodiff", issue = "124509")]
#[allow(non_upper_case_globals)]
#[allow(missing_docs)]
#[doc(hidden)]
pub mod enzyme_globals {
#[unsafe(no_mangle)]
#[unstable(feature = "autodiff", issue = "124509")]
#[doc(hidden)]
pub static enzyme_const: u8 = 0;

#[unsafe(no_mangle)]
#[unstable(feature = "autodiff", issue = "124509")]
#[doc(hidden)]
pub static enzyme_out: u8 = 0;

#[unsafe(no_mangle)]
#[unstable(feature = "autodiff", issue = "124509")]
#[doc(hidden)]
pub static enzyme_dup: u8 = 0;

#[unsafe(no_mangle)]
#[unstable(feature = "autodiff", issue = "124509")]
#[doc(hidden)]
pub static enzyme_dupv: u8 = 0;

#[unsafe(no_mangle)]
#[unstable(feature = "autodiff", issue = "124509")]
#[doc(hidden)]
pub static enzyme_dupnoneed: u8 = 0;

#[unsafe(no_mangle)]
#[unstable(feature = "autodiff", issue = "124509")]
#[doc(hidden)]
pub static enzyme_dupnoneedv: u8 = 0;

#[unsafe(no_mangle)]
#[unstable(feature = "autodiff", issue = "124509")]
#[doc(hidden)]
pub static enzyme_primal_return: u8 = 0;

#[unsafe(no_mangle)]
#[unstable(feature = "autodiff", issue = "124509")]
#[doc(hidden)]
pub static enzyme_width: u8 = 0;
}
4 changes: 4 additions & 0 deletions tests/run-make/symbols-all-mangled/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ fn symbols_check_archive(path: &str) {
continue; // Unfortunately LLVM doesn't allow us to mangle this symbol
}

if name.starts_with("enzyme_") {
continue; // Enzyme metadata markers are allowed to be unmangled
}

if name.contains(".llvm.") {
// Starting in LLVM 21 we get various implementation-detail functions which
// contain .llvm. that are not a problem.
Expand Down
Loading