Skip to content

Commit f270359

Browse files
wxjstzavpatel
authored andcommitted
Makefile: Improve the method to disable -m(no-)save-restore option
The commit 69d7e53 disables the -m(no-)save-restore option for clang, but clang11 supports this option. This patch uses the output information of the compiler to check whether the compiler supports this option. Signed-off-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
1 parent d249d65 commit f270359

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ endif
150150
# Check whether the linker supports creating PIEs
151151
OPENSBI_LD_PIE := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) $(USE_LD_FLAG) -fPIE -nostdlib -Wl,-pie -x c /dev/null -o /dev/null >/dev/null 2>&1 && echo y || echo n)
152152
153+
# Check whether the compiler supports -m(no-)save-restore
154+
CC_SUPPORT_SAVE_RESTORE := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -mno-save-restore -x c /dev/null -o /dev/null 2>&1 | grep "\-save\-restore" >/dev/null && echo n || echo y)
155+
153156
# Build Info:
154157
# OPENSBI_BUILD_TIME_STAMP -- the compilation time stamp
155158
# OPENSBI_BUILD_COMPILER_VERSION -- the compiler version info
@@ -276,8 +279,8 @@ GENFLAGS += $(firmware-genflags-y)
276279
277280
CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -O2
278281
CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls -mstrict-align
279-
# CLANG-10 (or lower) does not support -m(no-)save-restore option
280-
ifneq ($(CC_IS_CLANG),y)
282+
# enable -m(no-)save-restore option by CC_SUPPORT_SAVE_RESTORE
283+
ifeq ($(CC_SUPPORT_SAVE_RESTORE),y)
281284
CFLAGS += -mno-save-restore
282285
endif
283286
CFLAGS += -mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
@@ -294,8 +297,8 @@ CPPFLAGS += $(firmware-cppflags-y)
294297
295298
ASFLAGS = -g -Wall -nostdlib
296299
ASFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls -mstrict-align
297-
# CLANG-10 (or lower) does not support -m(no-)save-restore option
298-
ifneq ($(CC_IS_CLANG),y)
300+
# enable -m(no-)save-restore option by CC_SUPPORT_SAVE_RESTORE
301+
ifeq ($(CC_SUPPORT_SAVE_RESTORE),y)
299302
ASFLAGS += -mno-save-restore
300303
endif
301304
ASFLAGS += -mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)

0 commit comments

Comments
 (0)