Skip to contentSkip to conversation

Makefile: don't pass -mstrict-align to clang

PATCH New Kalle Wachsmuth 2 participants 2 messages Jan 11, 2024 – Jan 18, 2024 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: don't pass -mstrict-align to clang

Support for that option will be added in LLVM 18:
https://github.com/llvm/llvm-project/commit/23ce5368409c760f3dd49d0f17f34772b0b869d8

Clang 17.0.6, however, will error when passed the
-mstrict-align flag.
(I'm using Homebrew Clang on macOS.)

Sticking to aligned accesses is the default
behavior anyway.

---
 Makefile | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
Makefile +6 -2
index de4e73a..45332a0 100644
@@ -337,7 +337,7 @@ CFLAGS		+=	-O0
 else
 CFLAGS		+=	-O2
 endif
-CFLAGS		+=	-fno-omit-frame-pointer -fno-optimize-sibling-calls -mstrict-align
+CFLAGS		+=	-fno-omit-frame-pointer -fno-optimize-sibling-calls
 # enable -m(no-)save-restore option by CC_SUPPORT_SAVE_RESTORE
 ifeq ($(CC_SUPPORT_SAVE_RESTORE),y)
 CFLAGS		+=	-mno-save-restore
@@ -345,6 +345,9 @@ endif
 CFLAGS		+=	-mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
 CFLAGS		+=	-mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
 CFLAGS		+=	$(RELAX_FLAG)
+ifneq ($(CC_IS_CLANG),y)
+CFLAGS		+=	-mstrict-align
+endif
 CFLAGS		+=	$(GENFLAGS)
 CFLAGS		+=	$(platform-cflags-y)
 CFLAGS		+=	-fno-pie -no-pie
@@ -355,7 +358,7 @@ CPPFLAGS	+=	$(platform-cppflags-y)
 CPPFLAGS	+=	$(firmware-cppflags-y)
 
 ASFLAGS		=	-g -Wall -nostdlib
-ASFLAGS		+=	-fno-omit-frame-pointer -fno-optimize-sibling-calls -mstrict-align
+ASFLAGS		+=	-fno-omit-frame-pointer -fno-optimize-sibling-calls
 # enable -m(no-)save-restore option by CC_SUPPORT_SAVE_RESTORE
 ifeq ($(CC_SUPPORT_SAVE_RESTORE),y)
 ASFLAGS		+=	-mno-save-restore
@@ -364,6 +367,7 @@ ASFLAGS		+=	-mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
 ASFLAGS		+=	-mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
 ASFLAGS		+=	$(RELAX_FLAG)
 ifneq ($(CC_IS_CLANG),y)
+CFLAGS		+=	-mstrict-align
 ifneq ($(RELAX_FLAG),)
 ASFLAGS		+=	-Wa,$(RELAX_FLAG)
 endif
Signature · 1 line
2.39.3 (Apple Git-145)
#1 lore raw

PATCH 1/1 Makefile: don't pass -mstrict-align to clang

? 2024-01-11???? 10:26 +0100?Kalle Wachsmuth???

Quoted 10 lines

Support for that option will be added in LLVM 18:
https://github.com/llvm/llvm-project/commit/23ce5368409c760f3dd49d0f17f34772b0b869d8

Clang 17.0.6, however, will error when passed the
-mstrict-align flag.
(I'm using Homebrew Clang on macOS.)

Sticking to aligned accesses is the default
behavior anyway.

If this option will be added in the future, it is best to check whether the compiler supports this option through the shell.

Regards,
Xiang W

Quoted 49 lines

---
?Makefile | 8 ++++++--
?1 file changed, 6 insertions(+), 2 deletions(-)

Makefile +0 -0
index de4e73a..45332a0 100644
@@ -337,7 +337,7 @@ CFLAGS		+=	-O0

?else
?CFLAGS += -O2
?endif

Makefile +1 -1
-CFLAGS		+=	-fno-omit-frame-pointer -fno-optimize-sibling-calls -mstrict-align
+CFLAGS		+=	-fno-omit-frame-pointer -fno-optimize-sibling-calls

?# enable -m(no-)save-restore option by CC_SUPPORT_SAVE_RESTORE ?ifeq ($(CC_SUPPORT_SAVE_RESTORE),y)
?CFLAGS += -mno-save-restore

Makefile +3 -0
@@ -345,6 +345,9 @@ endif
 ?CFLAGS		+=	-mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
 ?CFLAGS		+=	-mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
 ?CFLAGS		+=	$(RELAX_FLAG)
+ifneq ($(CC_IS_CLANG),y)
+CFLAGS		+=	-mstrict-align
+endif
 ?CFLAGS		+=	$(GENFLAGS)
 ?CFLAGS		+=	$(platform-cflags-y)

?CFLAGS += -fno-pie -no-pie

Makefile +0 -0
@@ -355,7 +358,7 @@ CPPFLAGS	+=	$(platform-cppflags-y)
 ?CPPFLAGS	+=	$(firmware-cppflags-y)

?
?ASFLAGS = -g -Wall -nostdlib

Makefile +1 -1
-ASFLAGS		+=	-fno-omit-frame-pointer -fno-optimize-sibling-calls -mstrict-align
+ASFLAGS		+=	-fno-omit-frame-pointer -fno-optimize-sibling-calls

?# enable -m(no-)save-restore option by CC_SUPPORT_SAVE_RESTORE ?ifeq ($(CC_SUPPORT_SAVE_RESTORE),y)
?ASFLAGS += -mno-save-restore

Makefile +1 -0
@@ -364,6 +367,7 @@ ASFLAGS		+=	-mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
 ?ASFLAGS		+=	-mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
 ?ASFLAGS		+=	$(RELAX_FLAG)
 ?ifneq ($(CC_IS_CLANG),y)
+CFLAGS		+=	-mstrict-align
 ?ifneq ($(RELAX_FLAG),)
 ?ASFLAGS		+=	-Wa,$(RELAX_FLAG)

?endif

Signature · 1 line
2.39.3 (Apple Git-145)