store target.min_global_align as an Align

This commit is contained in:
Folkert de Vries
2025-06-07 21:31:21 +02:00
parent 44f415c1d6
commit a50bd7ca24
10 changed files with 37 additions and 63 deletions

View File

@@ -2,9 +2,6 @@ codegen_gcc_unknown_ctarget_feature_prefix =
unknown feature specified for `-Ctarget-feature`: `{$feature}`
.note = features must begin with a `+` to enable or `-` to disable it
codegen_gcc_invalid_minimum_alignment =
invalid minimum global alignment: {$err}
codegen_gcc_forbidden_ctarget_feature =
target feature `{$feature}` cannot be toggled with `-Ctarget-feature`: {$reason}

View File

@@ -18,7 +18,6 @@ use rustc_span::def_id::DefId;
use crate::base;
use crate::context::CodegenCx;
use crate::errors::InvalidMinimumAlignment;
use crate::type_of::LayoutGccExt;
fn set_global_alignment<'gcc, 'tcx>(
@@ -29,13 +28,8 @@ fn set_global_alignment<'gcc, 'tcx>(
// The target may require greater alignment for globals than the type does.
// Note: GCC and Clang also allow `__attribute__((aligned))` on variables,
// which can force it to be smaller. Rust doesn't support this yet.
if let Some(min) = cx.sess().target.min_global_align {
match Align::from_bits(min) {
Ok(min) => align = align.max(min),
Err(err) => {
cx.sess().dcx().emit_err(InvalidMinimumAlignment { err: err.to_string() });
}
}
if let Some(min_global) = cx.sess().target.min_global_align {
align = Ord::max(align, min_global);
}
gv.set_alignment(align.bytes() as i32);
}

View File

@@ -47,12 +47,6 @@ pub(crate) struct UnwindingInlineAsm {
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(codegen_gcc_invalid_minimum_alignment)]
pub(crate) struct InvalidMinimumAlignment {
pub err: String,
}
#[derive(Diagnostic)]
#[diag(codegen_gcc_copy_bitcode)]
pub(crate) struct CopyBitcode {