about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc/src/allocator.rs
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2022-09-10 11:33:44 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-05-11 14:35:09 +0000
commit66982a383b6f7d3a933fc6896202632bee7161a4 (patch)
treeed731f72cfa4b15ef644e34a1bca986a580a588a /compiler/rustc_codegen_gcc/src/allocator.rs
parent145b0574efd63603f35beda4d6b69933c8a01c1f (diff)
downloadrust-66982a383b6f7d3a933fc6896202632bee7161a4.tar.gz
rust-66982a383b6f7d3a933fc6896202632bee7161a4.zip
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;
Diffstat (limited to 'compiler/rustc_codegen_gcc/src/allocator.rs')
-rw-r--r--compiler/rustc_codegen_gcc/src/allocator.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_gcc/src/allocator.rs b/compiler/rustc_codegen_gcc/src/allocator.rs
index ff68de8c8f1..13f88192bbc 100644
--- a/compiler/rustc_codegen_gcc/src/allocator.rs
+++ b/compiler/rustc_codegen_gcc/src/allocator.rs
@@ -3,7 +3,7 @@ use gccjit::FnAttribute;
 use gccjit::{FunctionType, GlobalKind, ToRValue};
 use rustc_ast::expand::allocator::{
     alloc_error_handler_name, default_fn_name, global_fn_name, AllocatorKind, AllocatorTy,
-    ALLOCATOR_METHODS,
+    ALLOCATOR_METHODS, NO_ALLOC_SHIM_IS_UNSTABLE,
 };
 use rustc_middle::bug;
 use rustc_middle::ty::TyCtxt;
@@ -127,4 +127,9 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut GccContext, _module_nam
     let value = tcx.sess.opts.unstable_opts.oom.should_panic();
     let value = context.new_rvalue_from_int(i8, value as i32);
     global.global_set_initializer_rvalue(value);
+
+    let name = NO_ALLOC_SHIM_IS_UNSTABLE.to_string();
+    let global = context.new_global(None, GlobalKind::Exported, i8, name);
+    let value = context.new_rvalue_from_int(i8, 0);
+    global.global_set_initializer_rvalue(value);
 }