Skip to content

Commit b80970f

Browse files
committed
Sync from rust 8521a8c
2 parents 9054e66 + b8169a6 commit b80970f

File tree

6 files changed

+22
-13
lines changed

6 files changed

+22
-13
lines changed

src/abi/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
342342

343343
let ret_place = codegen_place(fx, destination);
344344

345-
// Handle special calls like instrinsics and empty drop glue.
345+
// Handle special calls like intrinsics and empty drop glue.
346346
let instance = if let ty::FnDef(def_id, substs) = *fn_ty.kind() {
347347
let instance = ty::Instance::resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, substs)
348348
.unwrap()

src/base.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -925,8 +925,11 @@ pub(crate) fn codegen_panic_inner<'tcx>(
925925
args: &[Value],
926926
span: Span,
927927
) {
928-
let def_id =
929-
fx.tcx.lang_items().require(lang_item).unwrap_or_else(|s| fx.tcx.sess.span_fatal(span, &s));
928+
let def_id = fx
929+
.tcx
930+
.lang_items()
931+
.require(lang_item)
932+
.unwrap_or_else(|e| fx.tcx.sess.span_fatal(span, e.to_string()));
930933

931934
let instance = Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx);
932935
let symbol_name = fx.tcx.symbol_name(instance).name;

src/constant.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, '_>) -> bool {
5959
ErrorHandled::TooGeneric => {
6060
span_bug!(
6161
constant.span,
62-
"codgen encountered polymorphic constant: {:?}",
62+
"codegen encountered polymorphic constant: {:?}",
6363
err
6464
);
6565
}
@@ -430,7 +430,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
430430
let bytes = alloc.inspect_with_uninit_and_ptr_outside_interpreter(0..alloc.len()).to_vec();
431431
data_ctx.define(bytes.into_boxed_slice());
432432

433-
for &(offset, alloc_id) in alloc.relocations().iter() {
433+
for &(offset, alloc_id) in alloc.provenance().iter() {
434434
let addend = {
435435
let endianness = tcx.data_layout.endian;
436436
let offset = offset.bytes() as usize;

src/intrinsics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
203203
sym::transmute => {
204204
crate::base::codegen_panic(fx, "Transmuting to uninhabited type.", source_info);
205205
}
206-
_ => unimplemented!("unsupported instrinsic {}", intrinsic),
206+
_ => unimplemented!("unsupported intrinsic {}", intrinsic),
207207
}
208208
return;
209209
};

src/intrinsics/simd.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
186186
let size = Size::from_bytes(
187187
4 * ret_lane_count, /* size_of([u32; ret_lane_count]) */
188188
);
189-
alloc.inner().get_bytes(fx, alloc_range(offset, size)).unwrap()
189+
alloc
190+
.inner()
191+
.get_bytes_strip_provenance(fx, alloc_range(offset, size))
192+
.unwrap()
190193
}
191194
_ => unreachable!("{:?}", idx_const),
192195
};

src/main_shim.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_hir::LangItem;
22
use rustc_middle::ty::subst::GenericArg;
33
use rustc_middle::ty::AssocKind;
4-
use rustc_session::config::EntryFnType;
4+
use rustc_session::config::{sigpipe, EntryFnType};
55
use rustc_span::symbol::Ident;
66

77
use crate::prelude::*;
@@ -15,12 +15,12 @@ pub(crate) fn maybe_create_entry_wrapper(
1515
is_jit: bool,
1616
is_primary_cgu: bool,
1717
) {
18-
let (main_def_id, is_main_fn) = match tcx.entry_fn(()) {
18+
let (main_def_id, (is_main_fn, sigpipe)) = match tcx.entry_fn(()) {
1919
Some((def_id, entry_ty)) => (
2020
def_id,
2121
match entry_ty {
22-
EntryFnType::Main => true,
23-
EntryFnType::Start => false,
22+
EntryFnType::Main { sigpipe } => (true, sigpipe),
23+
EntryFnType::Start => (false, sigpipe::DEFAULT),
2424
},
2525
),
2626
None => return,
@@ -35,7 +35,7 @@ pub(crate) fn maybe_create_entry_wrapper(
3535
return;
3636
}
3737

38-
create_entry_fn(tcx, module, unwind_context, main_def_id, is_jit, is_main_fn);
38+
create_entry_fn(tcx, module, unwind_context, main_def_id, is_jit, is_main_fn, sigpipe);
3939

4040
fn create_entry_fn(
4141
tcx: TyCtxt<'_>,
@@ -44,6 +44,7 @@ pub(crate) fn maybe_create_entry_wrapper(
4444
rust_main_def_id: DefId,
4545
ignore_lang_start_wrapper: bool,
4646
is_main_fn: bool,
47+
sigpipe: u8,
4748
) {
4849
let main_ret_ty = tcx.fn_sig(rust_main_def_id).output();
4950
// Given that `main()` has no arguments,
@@ -83,6 +84,7 @@ pub(crate) fn maybe_create_entry_wrapper(
8384
bcx.switch_to_block(block);
8485
let arg_argc = bcx.append_block_param(block, m.target_config().pointer_type());
8586
let arg_argv = bcx.append_block_param(block, m.target_config().pointer_type());
87+
let arg_sigpipe = bcx.ins().iconst(types::I8, sigpipe as i64);
8688

8789
let main_func_ref = m.declare_func_in_func(main_func_id, &mut bcx.func);
8890

@@ -143,7 +145,8 @@ pub(crate) fn maybe_create_entry_wrapper(
143145
let main_val = bcx.ins().func_addr(m.target_config().pointer_type(), main_func_ref);
144146

145147
let func_ref = m.declare_func_in_func(start_func_id, &mut bcx.func);
146-
let call_inst = bcx.ins().call(func_ref, &[main_val, arg_argc, arg_argv]);
148+
let call_inst =
149+
bcx.ins().call(func_ref, &[main_val, arg_argc, arg_argv, arg_sigpipe]);
147150
bcx.inst_results(call_inst)[0]
148151
} else {
149152
// using user-defined start fn

0 commit comments

Comments
 (0)