From 61ca4eff94d1d759273fe3ee0c228afc6486ef97 Mon Sep 17 00:00:00 2001 From: Xiaotian Wu Date: Fri, 1 Mar 2024 10:35:33 +0800 Subject: [PATCH] [loong64] Disable vector instructions and linker relaxation Signed-off-by: Xiaotian Wu --- src/arch/loong64/Makefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/arch/loong64/Makefile b/src/arch/loong64/Makefile index fd0bf137fb4..a2f2b68bb3e 100644 --- a/src/arch/loong64/Makefile +++ b/src/arch/loong64/Makefile @@ -8,6 +8,18 @@ ASM_TCHAR_OPS := @ CFLAGS += -fstrength-reduce -fomit-frame-pointer CFLAGS += -falign-jumps=1 -falign-loops=1 -falign-functions=1 +## Check if the follow options is valid for current toolchains +# -mno-lsx: Disable 128-bit SIMD instructions, added after gcc-14 +# -mno-lasx: Disable 256-bit SIMD instructions, added after gcc-14 +# -mno-relax: Disable linker relaxation, added after gcc-14 +# -Wa,-mno-relax: Disable linker relaxation, added after binutils-2.41 +CHECK_CC_FLAGS := -mno-lsx -mno-lasx -mno-relax -Wa,-mno-relax + +define check_cc_flag + $(shell $(CC) $(1) -x c -c /dev/null -o /dev/null > /dev/null 2>&1 && echo $(1)) +endef +CFLAGS += $(foreach flag,$(CHECK_CC_FLAGS),$(call check_cc_flag,$(flag))) + # Check if -mno-explicit-relocs is valid ifeq ($(CCTYPE),gcc) MNER_TEST = $(CC) -mno-explicit-relocs -x c -c /dev/null -o /dev/null >/dev/null 2>&1