Skip to content

Commit da466a2

Browse files
committed
Prevent insta-stable no alloc shim support
You will need to add the following as replacement for the old __rust_* definitions when not using the alloc shim. #[no_mangle] static __rust_no_alloc_shim_is_unstable: u8 = 0;
1 parent 2be697f commit da466a2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/allocator.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use gccjit::FnAttribute;
33
use gccjit::{FunctionType, GlobalKind, ToRValue};
44
use rustc_ast::expand::allocator::{
55
alloc_error_handler_name, default_fn_name, global_fn_name, AllocatorKind, AllocatorTy,
6-
ALLOCATOR_METHODS,
6+
ALLOCATOR_METHODS, NO_ALLOC_SHIM_IS_UNSTABLE,
77
};
88
use rustc_middle::bug;
99
use rustc_middle::ty::TyCtxt;
@@ -127,4 +127,9 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut GccContext, _module_nam
127127
let value = tcx.sess.opts.unstable_opts.oom.should_panic();
128128
let value = context.new_rvalue_from_int(i8, value as i32);
129129
global.global_set_initializer_rvalue(value);
130+
131+
let name = NO_ALLOC_SHIM_IS_UNSTABLE.to_string();
132+
let global = context.new_global(None, GlobalKind::Exported, i8, name);
133+
let value = context.new_rvalue_from_int(i8, 0);
134+
global.global_set_initializer_rvalue(value);
130135
}

0 commit comments

Comments
 (0)