-use cranelift_codegen::binemit::{NullStackMapSink, NullTrapSink};
use rustc_hir::LangItem;
use rustc_middle::ty::subst::GenericArg;
use rustc_middle::ty::AssocKind;
module: &mut impl Module,
unwind_context: &mut UnwindContext,
is_jit: bool,
+ is_primary_cgu: bool,
) {
- let (main_def_id, is_main_fn) = match tcx.entry_fn(LOCAL_CRATE) {
+ let (main_def_id, is_main_fn) = match tcx.entry_fn(()) {
Some((def_id, entry_ty)) => (
def_id,
match entry_ty {
None => return,
};
- let instance = Instance::mono(tcx, main_def_id).polymorphize(tcx);
- if !is_jit && module.get_name(&*tcx.symbol_name(instance).name).is_none() {
+ if main_def_id.is_local() {
+ let instance = Instance::mono(tcx, main_def_id).polymorphize(tcx);
+ if !is_jit && module.get_name(&*tcx.symbol_name(instance).name).is_none() {
+ return;
+ }
+ } else if !is_primary_cgu {
return;
}
// late-bound regions, since late-bound
// regions must appear in the argument
// listing.
- let main_ret_ty = tcx.erase_regions(main_ret_ty.no_bound_vars().unwrap());
+ let main_ret_ty = tcx.normalize_erasing_regions(
+ ty::ParamEnv::reveal_all(),
+ main_ret_ty.no_bound_vars().unwrap(),
+ );
let cmain_sig = Signature {
params: vec![
bcx.seal_all_blocks();
bcx.finalize();
}
- m.define_function(cmain_func_id, &mut ctx, &mut NullTrapSink {}, &mut NullStackMapSink {})
- .unwrap();
+ m.define_function(cmain_func_id, &mut ctx).unwrap();
unwind_context.add_function(cmain_func_id, &ctx, m.isa());
}
}