-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-alignArea: alignment control (`repr(align(N))` and so on)Area: alignment control (`repr(align(N))` and so on)A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.Category: This is a bug.O-windowsOperating system: WindowsOperating system: WindowsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
On Windows link.exe
requires that the alignment of any section is less than or equal to the /ALIGN
value. Statics with an alignment of 8192 or greater cause the section to have an alignment of 8192 (but not greater, see #70022), but link.exe
has a default /ALIGN
of 4096 causing fatal error LNK1164: section 0x6 alignment (8192) greater than /ALIGN value
. Specifying -Clink-arg="/ALIGN:8192"
causes the error to go away.
Minimal example
#[repr(align(0x100000))]
struct Aligned(u8);
static X: Aligned = Aligned(0);
fn main() {
println!("{:#x}", &X as *const _ as usize);
}
Metadata
Metadata
Assignees
Labels
A-alignArea: alignment control (`repr(align(N))` and so on)Area: alignment control (`repr(align(N))` and so on)A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.Category: This is a bug.O-windowsOperating system: WindowsOperating system: WindowsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.