Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit d71b3f4

Browse files
committed
Auto merge of rust-lang#124813 - maurer:llvm-aarch64-fn32, r=nikic
Adjust 64-bit ARM data layouts for LLVM update LLVM has updated data layouts to specify `Fn32` on 64-bit ARM to avoid C++ accidentally underaligning functions when trying to comply with member function ABIs. This should only affect Rust in cases where we had a similar bug (I don't believe we have one), but our data layout must match to generate code. As a compatibility adaptatation, if LLVM is not version 19 yet, `Fn32` gets voided from the data layout. See llvm/llvm-project#90415 `@rustbot` label: +llvm-main cc `@krasimirgg` r? `@durin42`
2 parents 5ae5d13 + 4d397d3 commit d71b3f4

Some content is hidden

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

41 files changed

+49
-40
lines changed

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ pub unsafe fn create_module<'ll>(
133133
}
134134
}
135135

136+
if llvm_version < (19, 0, 0) {
137+
if sess.target.arch == "aarch64" || sess.target.arch.starts_with("arm64") {
138+
// LLVM 19 sets -Fn32 in its data layout string for 64-bit ARM
139+
// Earlier LLVMs leave this default, so remove it.
140+
// See https://github.com/llvm/llvm-project/pull/90702
141+
target_data_layout = target_data_layout.replace("-Fn32", "");
142+
}
143+
}
144+
136145
// Ensure the data-layout values hardcoded remain the defaults.
137146
{
138147
let tm = crate::back::write::create_informational_target_machine(tcx.sess);

compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn target() -> Target {
2222
std: None,
2323
},
2424
pointer_width: 64,
25-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
25+
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
2626
arch: arch.target_arch(),
2727
options: TargetOptions {
2828
mcount: "\u{1}mcount".into(),

compiler/rustc_target/src/spec/targets/aarch64_apple_ios.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn target() -> Target {
1919
std: None,
2020
},
2121
pointer_width: 64,
22-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
22+
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
2323
arch: arch.target_arch(),
2424
options: TargetOptions {
2525
features: "+neon,+fp-armv8,+apple-a7".into(),

compiler/rustc_target/src/spec/targets/aarch64_apple_ios_macabi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn target() -> Target {
1515
std: None,
1616
},
1717
pointer_width: 64,
18-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
18+
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
1919
arch: arch.target_arch(),
2020
options: TargetOptions {
2121
features: "+neon,+fp-armv8,+apple-a12".into(),

compiler/rustc_target/src/spec/targets/aarch64_apple_ios_sim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn target() -> Target {
1919
std: None,
2020
},
2121
pointer_width: 64,
22-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
22+
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
2323
arch: arch.target_arch(),
2424
options: TargetOptions {
2525
features: "+neon,+fp-armv8,+apple-a7".into(),

compiler/rustc_target/src/spec/targets/aarch64_apple_tvos.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn target() -> Target {
1212
std: None,
1313
},
1414
pointer_width: 64,
15-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
15+
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
1616
arch: arch.target_arch(),
1717
options: TargetOptions {
1818
features: "+neon,+fp-armv8,+apple-a7".into(),

compiler/rustc_target/src/spec/targets/aarch64_apple_tvos_sim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn target() -> Target {
1212
std: None,
1313
},
1414
pointer_width: 64,
15-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
15+
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
1616
arch: arch.target_arch(),
1717
options: TargetOptions {
1818
features: "+neon,+fp-armv8,+apple-a7".into(),

compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn target() -> Target {
1515
std: Some(false),
1616
},
1717
pointer_width: 64,
18-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
18+
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
1919
arch: arch.target_arch(),
2020
options: TargetOptions {
2121
features: "+neon,+fp-armv8,+apple-a16".into(),

compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn target() -> Target {
1515
std: Some(false),
1616
},
1717
pointer_width: 64,
18-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
18+
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
1919
arch: arch.target_arch(),
2020
options: TargetOptions {
2121
features: "+neon,+fp-armv8,+apple-a16".into(),

compiler/rustc_target/src/spec/targets/aarch64_apple_watchos.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn target() -> Target {
1212
std: None,
1313
},
1414
pointer_width: 64,
15-
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
15+
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128-Fn32".into(),
1616
arch: "aarch64".into(),
1717
options: TargetOptions {
1818
features: "+v8a,+neon,+fp-armv8,+apple-a7".into(),

0 commit comments

Comments
 (0)