Skip to contentSkip to conversation

arm: Switch to -mno-unaligned-access when supported by the compiler

PATCH New Tom Rini 2 participants 3 messages Jan 28, 2014

Subsystems (3)
lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 arm: Switch to -mno-unaligned-access when supported by the compiler

When we tell the compiler to optimize for ARMv7 it assumes a default of unaligned accesses being supported at the hardware level and can make use of this to perform what it deems as an optimization in any case, including allowing for data to become unaligned. We explicitly disallow this hardware feature so we must tell the compiler.

Cc Albert ARIBAUD <[email protected]>
Cc Mans Rullgard <[email protected]>
---
 arch/arm/cpu/armv7/config.mk      |    6 +-
 arch/arm/cpu/armv8/config.mk      |    5 +-
 common/Makefile                   |    4 --
 doc/README.arm-unaligned-accesses |  122 -------------------------------------
 fs/ubifs/Makefile                 |    3 -
 lib/Makefile                      |    3 -
 6 files changed, 5 insertions(+), 138 deletions(-)
 delete mode 100644 doc/README.arm-unaligned-accesses
arch/arm/cpu/armv7/config.mk +4 -2
index 38b7c40..ae4427c 100644
@@ -10,9 +10,11 @@
 PF_CPPFLAGS_ARMV7 := $(call cc-option, -march=armv7-a, -march=armv5)
 PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARMV7)
 
-# SEE README.arm-unaligned-accesses
+# On supported platforms we clear the bit which allows for hardware
+# unaligned access so we must tell the compiler so it can make the correct
+# decision.
 PF_NO_UNALIGNED := $(call cc-option, -mno-unaligned-access,)
-PLATFORM_NO_UNALIGNED := $(PF_NO_UNALIGNED)
+PLATFORM_CPPFLAGS += $(PF_NO_UNALIGNED)
 
 ifneq ($(CONFIG_IMX_CONFIG),)
 ifdef CONFIG_SPL
arch/arm/cpu/armv8/config.mk +1 -4
index 027a68c..f5b9559 100644
@@ -6,10 +6,7 @@
 #
 PLATFORM_RELFLAGS += -fno-common -ffixed-x18
 
-# SEE README.arm-unaligned-accesses
-PF_NO_UNALIGNED := $(call cc-option, -mstrict-align)
-PLATFORM_NO_UNALIGNED := $(PF_NO_UNALIGNED)
-
 PF_CPPFLAGS_ARMV8 := $(call cc-option, -march=armv8-a)
+PF_NO_UNALIGNED := $(call cc-option, -mstrict-align)
 PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARMV8)
 PLATFORM_CPPFLAGS += $(PF_NO_UNALIGNED)
common/Makefile +0 -4
index 4d99ecd..53d1798 100644
@@ -238,7 +238,3 @@ $(obj)env_embedded.o: $(src)env_embedded.c
 	$(CC) $(AFLAGS) -Wa,--no-warn \
 		-DENV_CRC=$(shell $(obj)../tools/envcrc) \
 		-c -o $@ $(src)env_embedded.c
-
-# SEE README.arm-unaligned-accesses
-$(obj)hush.o: CFLAGS += $(PLATFORM_NO_UNALIGNED)
-$(obj)fdt_support.o: CFLAGS += $(PLATFORM_NO_UNALIGNED)
doc/README.arm-unaligned-accesses deleted +0 -122

122 lines not on this page · raw message

fs/ubifs/Makefile +0 -3
index 389b0e3..8c8c6ac 100644
@@ -13,6 +13,3 @@ obj-y := ubifs.o io.o super.o sb.o master.o lpt.o
 obj-y += lpt_commit.o scan.o lprops.o
 obj-y += tnc.o tnc_misc.o debug.o crc16.o budget.o
 obj-y += log.o orphan.o recovery.o replay.o
-
-# SEE README.arm-unaligned-accesses
-$(obj)super.o: CFLAGS += $(PLATFORM_NO_UNALIGNED)
lib/Makefile +0 -3
index 760340f..dedb97b 100644
@@ -65,6 +65,3 @@ obj-y += vsprintf.o
 obj-$(CONFIG_RANDOM_MACADDR) += rand.o
 obj-$(CONFIG_BOOTP_RANDOM_DELAY) += rand.o
 obj-$(CONFIG_CMD_LINK_LOCAL) += rand.o
-
-# SEE README.arm-unaligned-accesses
-$(obj)bzlib.o: CFLAGS += $(PLATFORM_NO_UNALIGNED)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 arm: Switch to -mno-unaligned-access when supported by the compiler

Quoted 9 lines · Tom Rini

When we tell the compiler to optimize for ARMv7 it assumes a default of unaligned accesses being supported at the hardware level and can make use of this to perform what it deems as an optimization in any case, including allowing for data to become unaligned. We explicitly disallow this hardware feature so we must tell the compiler.

Cc Albert ARIBAUD <[email protected]>
Cc Mans Rullgard <[email protected]>
Quoted 9 lines
---
 arch/arm/cpu/armv7/config.mk      |    6 +-
 arch/arm/cpu/armv8/config.mk      |    5 +-
 common/Makefile                   |    4 --
 doc/README.arm-unaligned-accesses |  122 -------------------------------------
 fs/ubifs/Makefile                 |    3 -
 lib/Makefile                      |    3 -
 6 files changed, 5 insertions(+), 138 deletions(-)
 delete mode 100644 doc/README.arm-unaligned-accesses

Awesome.

You should also remove the reference to the (deleted) readme file from arch/arm/lib/interrupts.c

Signature · 2 lines
M?ns Rullg?rd
mans at mansr.com
author
#2 lore raw

PATCH 1/1 arm: Switch to -mno-unaligned-access when supported by the compiler

Quoted 21 lines · M?ns Rullg?rd
Quoted 9 lines · Tom Rini

When we tell the compiler to optimize for ARMv7 it assumes a default of unaligned accesses being supported at the hardware level and can make use of this to perform what it deems as an optimization in any case, including allowing for data to become unaligned. We explicitly disallow this hardware feature so we must tell the compiler.

Cc Albert ARIBAUD <[email protected]>
Cc Mans Rullgard <[email protected]>
Quoted 9 lines
---
 arch/arm/cpu/armv7/config.mk      |    6 +-
 arch/arm/cpu/armv8/config.mk      |    5 +-
 common/Makefile                   |    4 --
 doc/README.arm-unaligned-accesses |  122 -------------------------------------
 fs/ubifs/Makefile                 |    3 -
 lib/Makefile                      |    3 -
 6 files changed, 5 insertions(+), 138 deletions(-)
 delete mode 100644 doc/README.arm-unaligned-accesses
Quoted 4 lines

Awesome.

You should also remove the reference to the (deleted) readme file from arch/arm/lib/interrupts.c

And top-level README. I'll do that in a v2 later, thanks.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140128/8d0badd6/attachment.pgp>