Skip to content

Commit a0ffcb9

Browse files
committed
LLVM 18 x86 data layout update
With https://reviews.llvm.org/D86310 LLVM now has i128 aligned to 16-bytes on x86 based platforms. This will be in LLVM-18. This patch updates all our spec targets to be 16-byte aligned, and removes the alignment when speaking to older LLVM. This results in Rust overaligning things relative to LLVM on older LLVMs. See #54341
1 parent 3c23df4 commit a0ffcb9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+86
-77
lines changed

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,15 @@ pub unsafe fn create_module<'ll>(
157157
.replace("-Fi64", "");
158158
}
159159
}
160+
if llvm_version < (18, 0, 0) {
161+
if sess.target.arch == "i386" || sess.target.arch == "i686" || sess.target.arch == "x86_64"
162+
{
163+
// LLVM 18 adjusts i128 to be 128-bit aligned on x86 variants.
164+
// Earlier LLVMs leave this as default alignment, so remove it.
165+
// See https://reviews.llvm.org/D86310
166+
target_data_layout = target_data_layout.replace("-i128:128", "");
167+
}
168+
}
160169

161170
// Ensure the data-layout values hardcoded remain the defaults.
162171
if sess.target.is_builtin {

compiler/rustc_target/src/spec/i386_apple_ios.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn target() -> Target {
1111
llvm_target: ios_sim_llvm_target(arch).into(),
1212
pointer_width: 32,
1313
data_layout: "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
14-
f64:32:64-f80:128-n8:16:32-S128"
14+
i128:128-f64:32:64-f80:128-n8:16:32-S128"
1515
.into(),
1616
arch: arch.target_arch(),
1717
options: TargetOptions {

compiler/rustc_target/src/spec/i686_apple_darwin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn target() -> Target {
1919
llvm_target: macos_llvm_target(Arch::I686).into(),
2020
pointer_width: 32,
2121
data_layout: "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
22-
f64:32:64-f80:128-n8:16:32-S128"
22+
i128:128-f64:32:64-f80:128-n8:16:32-S128"
2323
.into(),
2424
arch: arch.target_arch(),
2525
options: TargetOptions { mcount: "\u{1}mcount".into(), ..base },

compiler/rustc_target/src/spec/i686_linux_android.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn target() -> Target {
1717
llvm_target: "i686-linux-android".into(),
1818
pointer_width: 32,
1919
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
20-
f64:32:64-f80:32-n8:16:32-S128"
20+
i128:128-f64:32:64-f80:32-n8:16:32-S128"
2121
.into(),
2222
arch: "x86".into(),
2323
options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base },

compiler/rustc_target/src/spec/i686_unknown_freebsd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn target() -> Target {
1111
llvm_target: "i686-unknown-freebsd".into(),
1212
pointer_width: 32,
1313
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
14-
f64:32:64-f80:32-n8:16:32-S128"
14+
i128:128-f64:32:64-f80:32-n8:16:32-S128"
1515
.into(),
1616
arch: "x86".into(),
1717
options: base,

compiler/rustc_target/src/spec/i686_unknown_haiku.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn target() -> Target {
1111
llvm_target: "i686-unknown-haiku".into(),
1212
pointer_width: 32,
1313
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
14-
f64:32:64-f80:32-n8:16:32-S128"
14+
i128:128-f64:32:64-f80:32-n8:16:32-S128"
1515
.into(),
1616
arch: "x86".into(),
1717
options: base,

compiler/rustc_target/src/spec/i686_unknown_hurd_gnu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn target() -> Target {
1111
llvm_target: "i686-unknown-hurd-gnu".into(),
1212
pointer_width: 32,
1313
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
14-
f64:32:64-f80:32-n8:16:32-S128"
14+
i128:128-f64:32:64-f80:32-n8:16:32-S128"
1515
.into(),
1616
arch: "x86".into(),
1717
options: base,

compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn target() -> Target {
1212
llvm_target: "i686-unknown-linux-gnu".into(),
1313
pointer_width: 32,
1414
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
15-
f64:32:64-f80:32-n8:16:32-S128"
15+
i128:128-f64:32:64-f80:32-n8:16:32-S128"
1616
.into(),
1717
arch: "x86".into(),
1818
options: base,

compiler/rustc_target/src/spec/i686_unknown_linux_musl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn target() -> Target {
2525
llvm_target: "i686-unknown-linux-musl".into(),
2626
pointer_width: 32,
2727
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
28-
f64:32:64-f80:32-n8:16:32-S128"
28+
i128:128-f64:32:64-f80:32-n8:16:32-S128"
2929
.into(),
3030
arch: "x86".into(),
3131
options: base,

compiler/rustc_target/src/spec/i686_unknown_netbsd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn target() -> Target {
1111
llvm_target: "i686-unknown-netbsdelf".into(),
1212
pointer_width: 32,
1313
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
14-
f64:32:64-f80:32-n8:16:32-S128"
14+
i128:128-f64:32:64-f80:32-n8:16:32-S128"
1515
.into(),
1616
arch: "x86".into(),
1717
options: TargetOptions { mcount: "__mcount".into(), ..base },

0 commit comments

Comments
 (0)