Skip to content

Commit 6fcfc3d

Browse files
committed
Add -Z oom={panic,abort} command-line option
1 parent e855e2d commit 6fcfc3d

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
@@ -1,7 +1,8 @@
1-
use gccjit::{FunctionType, ToRValue};
1+
use gccjit::{FunctionType, GlobalKind, ToRValue};
22
use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
33
use rustc_middle::bug;
44
use rustc_middle::ty::TyCtxt;
5+
use rustc_session::config::OomStrategy;
56
use rustc_span::symbol::sym;
67

78
use crate::GccContext;
@@ -113,4 +114,10 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut GccContext, _module_nam
113114
let _ret = context.new_call(None, callee, &args);
114115
//llvm::LLVMSetTailCall(ret, True);
115116
block.end_with_void_return(None);
117+
118+
let name = OomStrategy::SYMBOL.to_string();
119+
let global = context.new_global(None, GlobalKind::Exported, i8, name);
120+
let value = tcx.sess.opts.debugging_opts.oom.should_panic();
121+
let value = context.new_rvalue_from_int(i8, value as i32);
122+
global.global_set_initializer_rvalue(value);
116123
}

0 commit comments

Comments
 (0)