Skip to content

Commit 074f49a

Browse files
committed
Auto merge of #31283 - dotdash:32_64_cc, r=alexcrichton
When cross compiling for a target that has a larger usize type than the host system, we use a truncated value to mark data as dropped, eventually leading to drop calls on already dropped data. To properly handle this, the drop pattern needs to be of type u64. Since C_integral truncates its given value to the requested size anyway, we can also drop the function that chose between the u32 and u64 values, and always use the u64 constant. Fixes #31139 r? @pnkfelix
2 parents 0f196bc + fdf65e7 commit 074f49a

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

src/librustc_trans/trans/adt.rs

+2-18
Original file line numberDiff line numberDiff line change
@@ -229,28 +229,12 @@ pub const DTOR_NEEDED_HINT: u8 = 0x3d;
229229
pub const DTOR_MOVED_HINT: u8 = 0x2d;
230230

231231
pub const DTOR_NEEDED: u8 = 0xd4;
232-
pub const DTOR_NEEDED_U32: u32 = repeat_u8_as_u32(DTOR_NEEDED);
233-
pub const DTOR_NEEDED_U64: u64 = repeat_u8_as_u64(DTOR_NEEDED);
234232
#[allow(dead_code)]
235-
pub fn dtor_needed_usize(ccx: &CrateContext) -> usize {
236-
match &ccx.tcx().sess.target.target.target_pointer_width[..] {
237-
"32" => DTOR_NEEDED_U32 as usize,
238-
"64" => DTOR_NEEDED_U64 as usize,
239-
tws => panic!("Unsupported target word size for int: {}", tws),
240-
}
241-
}
233+
pub const DTOR_NEEDED_U64: u64 = repeat_u8_as_u64(DTOR_NEEDED);
242234

243235
pub const DTOR_DONE: u8 = 0x1d;
244-
pub const DTOR_DONE_U32: u32 = repeat_u8_as_u32(DTOR_DONE);
245-
pub const DTOR_DONE_U64: u64 = repeat_u8_as_u64(DTOR_DONE);
246236
#[allow(dead_code)]
247-
pub fn dtor_done_usize(ccx: &CrateContext) -> usize {
248-
match &ccx.tcx().sess.target.target.target_pointer_width[..] {
249-
"32" => DTOR_DONE_U32 as usize,
250-
"64" => DTOR_DONE_U64 as usize,
251-
tws => panic!("Unsupported target word size for int: {}", tws),
252-
}
253-
}
237+
pub const DTOR_DONE_U64: u64 = repeat_u8_as_u64(DTOR_DONE);
254238

255239
fn dtor_to_init_u8(dtor: bool) -> u8 {
256240
if dtor { DTOR_NEEDED } else { 0 }

src/librustc_trans/trans/glue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, g: DropGlueK
514514
// the special dtor markings.
515515

516516
let inttype = Type::int(bcx.ccx());
517-
let dropped_pattern = C_integral(inttype, adt::dtor_done_usize(bcx.fcx.ccx) as u64, false);
517+
let dropped_pattern = C_integral(inttype, adt::DTOR_DONE_U64, false);
518518

519519
match t.sty {
520520
ty::TyBox(content_ty) => {

0 commit comments

Comments
 (0)