mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
rlib handling
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
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;
|
||||
@@ -1136,8 +1137,17 @@ fn codegen_autodiff<'ll, 'tcx>(
|
||||
if !tcx.sess.opts.unstable_opts.autodiff.contains(&rustc_session::config::AutoDiff::Enable) {
|
||||
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutEnable);
|
||||
}
|
||||
if tcx.sess.lto() != rustc_session::config::Lto::Fat {
|
||||
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutLto);
|
||||
|
||||
let ct = tcx.crate_types();
|
||||
let lto = tcx.sess.lto();
|
||||
if ct.len() == 1 && ct.contains(&CrateType::Executable) {
|
||||
if lto != rustc_session::config::Lto::Fat {
|
||||
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutLto);
|
||||
}
|
||||
} else {
|
||||
if lto != rustc_session::config::Lto::Fat && !tcx.sess.opts.cg.linker_plugin_lto.enabled() {
|
||||
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutLto);
|
||||
}
|
||||
}
|
||||
|
||||
let fn_args = instance.args;
|
||||
|
||||
@@ -34,6 +34,14 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIXME(autodiff): replace this as per discussion in https://github.com/rust-lang/rust/pull/149033#discussion_r2535465880
|
||||
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;
|
||||
}
|
||||
|
||||
if tcx.has_attr(def_id, sym::rustc_intrinsic) {
|
||||
// Intrinsic fallback bodies are always cross-crate inlineable.
|
||||
// To ensure that the MIR inliner doesn't cluelessly try to inline fallback
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
// mono so this does not interfere in `autodiff` intrinsics
|
||||
// codegen process. If they are unused, LLVM will remove them when
|
||||
// compiling with O3.
|
||||
// FIXME(autodiff): Remove this whole file, as per discussion in
|
||||
// https://github.com/rust-lang/rust/pull/149033#discussion_r2535465880
|
||||
pub(crate) fn collect_autodiff_fn<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
instance: ty::Instance<'tcx>,
|
||||
|
||||
Reference in New Issue
Block a user