diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2022-03-19 13:28:22 +0100 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2022-03-19 13:28:22 +0100 |
| commit | 670ee7ec280c6638d902bc97ef2f16536f6507f8 (patch) | |
| tree | 122d7fc1c3fc7d56d10d3ec857d90427abe5a834 | |
| parent | ef4512b7dcaf2ae10e80e3aeb9b014c4128364b2 (diff) | |
| parent | 86daae2e6b7b494d5ea96dda145ad3c409fc3286 (diff) | |
| download | rust-670ee7ec280c6638d902bc97ef2f16536f6507f8.tar.gz rust-670ee7ec280c6638d902bc97ef2f16536f6507f8.zip | |
Sync from rust 31535841701e0bf7ef33998024376f2cedd8b3e3
| -rw-r--r-- | src/allocator.rs | 17 | ||||
| -rw-r--r-- | src/constant.rs | 3 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/allocator.rs b/src/allocator.rs index 82247b47888..c3b99b64263 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -4,6 +4,7 @@ use crate::prelude::*; use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; +use rustc_session::config::OomStrategy; /// Returns whether an allocator shim was created pub(crate) fn codegen( @@ -18,7 +19,13 @@ pub(crate) fn codegen( if any_dynamic_crate { false } else if let Some(kind) = tcx.allocator_kind(()) { - codegen_inner(module, unwind_context, kind, tcx.lang_items().oom().is_some()); + codegen_inner( + module, + unwind_context, + kind, + tcx.lang_items().oom().is_some(), + tcx.sess.opts.debugging_opts.oom, + ); true } else { false @@ -30,6 +37,7 @@ fn codegen_inner( unwind_context: &mut UnwindContext, kind: AllocatorKind, has_alloc_error_handler: bool, + oom_strategy: OomStrategy, ) { let usize_ty = module.target_config().pointer_type(); @@ -129,4 +137,11 @@ fn codegen_inner( } module.define_function(func_id, &mut ctx).unwrap(); unwind_context.add_function(func_id, &ctx, module.isa()); + + let data_id = module.declare_data(OomStrategy::SYMBOL, Linkage::Export, false, false).unwrap(); + let mut data_ctx = DataContext::new(); + data_ctx.set_align(1); + let val = oom_strategy.should_panic(); + data_ctx.define(Box::new([val])); + module.define_data(data_id, &data_ctx).unwrap(); } diff --git a/src/constant.rs b/src/constant.rs index 473e6fcb2a3..ef01897b67b 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,7 +1,6 @@ //! Handling of `static`s, `const`s and promoted allocations use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_errors::ErrorGuaranteed; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::mir::interpret::{ read_target_uint, AllocId, ConstAllocation, ConstValue, ErrorHandled, GlobalAlloc, Scalar, @@ -54,7 +53,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, '_>) -> bool { { all_constants_ok = false; match err { - ErrorHandled::Reported(ErrorGuaranteed) | ErrorHandled::Linted => { + ErrorHandled::Reported(_) | ErrorHandled::Linted => { fx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); } ErrorHandled::TooGeneric => { |
