Skip to content

Commit 3572f9a

Browse files
authored
Unrolled build for #144578
Rollup merge of #144578 - FractalFir:m68k_fix, r=compiler-errors Ensure correct aligement of rustc_hir::Lifetime on platforms with lower default alignments. The compiler relies on `hir::Lifetime` being aligned to at least 4 bytes(for the purposes of pointer tagging). However, on some systems(like m68k) with lower alignment requirements(eg. usize / u32 aligned to 2 bytes),`hir::Lifetime` will be aligned to only 2 bytes. This causes the compilation to fail on those systems - a const assert in the compiler fails. This PR makes the aligement requriement of hir::Lifetime explict. This has no effect on platforms where that already is the case(repr align can only raise alignment), but ensures the alignment will stay correct no matter what.
2 parents cb6785f + 72927f6 commit 3572f9a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

compiler/rustc_hir/src/hir.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ impl From<Ident> for LifetimeSyntax {
148148
/// `LifetimeSource::OutlivesBound` or `LifetimeSource::PreciseCapturing`
149149
/// — there's no way to "elide" these lifetimes.
150150
#[derive(Debug, Copy, Clone, HashStable_Generic)]
151+
// Raise the aligement to at least 4 bytes - this is relied on in other parts of the compiler(for pointer tagging):
152+
// https://github.com/rust-lang/rust/blob/ce5fdd7d42aba9a2925692e11af2bd39cf37798a/compiler/rustc_data_structures/src/tagged_ptr.rs#L163
153+
// Removing this `repr(4)` will cause the compiler to not build on platforms like `m68k` Linux, where the aligement of u32 and usize is only 2.
154+
// Since `repr(align)` may only raise aligement, this has no effect on platforms where the aligement is already sufficient.
155+
#[repr(align(4))]
151156
pub struct Lifetime {
152157
#[stable_hasher(ignore)]
153158
pub hir_id: HirId,

0 commit comments

Comments
 (0)