Skip to content

Commit 7914e6f

Browse files
authored
Rollup merge of #45094 - japaric:strict-align, r=alexcrichton
enable strict alignment (+strict-align) on ARMv6 As discovered in #44538 ARMv6 devices may or may not support unaligned memory accesses. ARMv6 Linux *seems* to have no problem with unaligned accesses but this is because the kernel is stepping in to fix each unaligned memory access -- this incurs in a performance penalty. This commit enforces aligned memory accesses on all our in-tree ARM targets that may be used with ARMv6 devices. This should improve performance of Rust programs on ARMv6 devices. For the record, clang also applies this attribute when targeting ARMv6 devices that are not running Darwin or NetBSD. closes #44538 r? @alexcrichton
2 parents 0489497 + 2b8f190 commit 7914e6f

5 files changed

+5
-5
lines changed

src/librustc_back/target/arm_linux_androideabi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use target::{Target, TargetOptions, TargetResult};
1414
pub fn target() -> TargetResult {
1515
let mut base = super::android_base::opts();
1616
// https://developer.android.com/ndk/guides/abis.html#armeabi
17-
base.features = "+v5te".to_string();
17+
base.features = "+strict-align,+v5te".to_string();
1818
base.max_atomic_width = Some(64);
1919

2020
Ok(Target {

src/librustc_back/target/arm_unknown_linux_gnueabi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn target() -> TargetResult {
2727
linker_flavor: LinkerFlavor::Gcc,
2828

2929
options: TargetOptions {
30-
features: "+v6".to_string(),
30+
features: "+strict-align,+v6".to_string(),
3131
abi_blacklist: super::arm_base::abi_blacklist(),
3232
.. base
3333
},

src/librustc_back/target/arm_unknown_linux_gnueabihf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn target() -> TargetResult {
2727
linker_flavor: LinkerFlavor::Gcc,
2828

2929
options: TargetOptions {
30-
features: "+v6,+vfp2".to_string(),
30+
features: "+strict-align,+v6,+vfp2".to_string(),
3131
abi_blacklist: super::arm_base::abi_blacklist(),
3232
.. base
3333
}

src/librustc_back/target/arm_unknown_linux_musleabi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn target() -> TargetResult {
1616

1717
// Most of these settings are copied from the arm_unknown_linux_gnueabi
1818
// target.
19-
base.features = "+v6".to_string();
19+
base.features = "+strict-align,+v6".to_string();
2020
base.max_atomic_width = Some(64);
2121
Ok(Target {
2222
// It's important we use "gnueabi" and not "musleabi" here. LLVM uses it

src/librustc_back/target/arm_unknown_linux_musleabihf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn target() -> TargetResult {
1616

1717
// Most of these settings are copied from the arm_unknown_linux_gnueabihf
1818
// target.
19-
base.features = "+v6,+vfp2".to_string();
19+
base.features = "+strict-align,+v6,+vfp2".to_string();
2020
base.max_atomic_width = Some(64);
2121
Ok(Target {
2222
// It's important we use "gnueabihf" and not "musleabihf" here. LLVM

0 commit comments

Comments
 (0)