Skip to content

Commit 2253e86

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 a1d0a90 commit 2253e86

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/allocator.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::prelude::*;
55

66
use rustc_ast::expand::allocator::{
77
alloc_error_handler_name, default_fn_name, global_fn_name, AllocatorKind, AllocatorTy,
8-
ALLOCATOR_METHODS,
8+
ALLOCATOR_METHODS, NO_ALLOC_SHIM_IS_UNSTABLE,
99
};
1010
use rustc_codegen_ssa::base::allocator_kind_for_codegen;
1111
use rustc_session::config::OomStrategy;
@@ -94,4 +94,11 @@ fn codegen_inner(
9494
let val = oom_strategy.should_panic();
9595
data_ctx.define(Box::new([val]));
9696
module.define_data(data_id, &data_ctx).unwrap();
97+
98+
let data_id =
99+
module.declare_data(NO_ALLOC_SHIM_IS_UNSTABLE, Linkage::Export, false, false).unwrap();
100+
let mut data_ctx = DataContext::new();
101+
data_ctx.set_align(1);
102+
data_ctx.define(Box::new([0]));
103+
module.define_data(data_id, &data_ctx).unwrap();
97104
}

0 commit comments

Comments
 (0)