From 67d1e72e8b8343d8dd83b011234582c0e6009bbb Mon Sep 17 00:00:00 2001 From: gxw Date: Thu, 8 Jun 2023 20:20:47 +0800 Subject: [PATCH] LoongArch64: Add ABI detection for loongarch64 If lp64d ABI is supported, it is used; otherwise, it falls back to the lp64 ABI. --- Makefile.system | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile.system b/Makefile.system index 343b94bb3..7dc17c486 100644 --- a/Makefile.system +++ b/Makefile.system @@ -932,8 +932,12 @@ BINARY_DEFINED = 1 endif ifeq ($(ARCH), loongarch64) -CCOMMON_OPT += -march=loongarch64 -mabi=lp64 -FCOMMON_OPT += -march=loongarch64 -mabi=lp64 +LA64_ABI=$(shell $(CC) -mabi=lp64d -c $(TOPDIR)/cpuid_loongarch64.c -o /dev/null > /dev/null 2> /dev/null && echo lp64d) +ifneq ($(LA64_ABI), lp64d) +LA64_ABI=lp64 +endif +CCOMMON_OPT += -march=loongarch64 -mabi=$(LA64_ABI) +FCOMMON_OPT += -march=loongarch64 -mabi=$(LA64_ABI) endif endif