Fix ABI CFLAGS setting on new-world LoongArch

See: https://bugs.gentoo.org/844013
This commit is contained in:
WANG Xuerui 2022-05-13 16:23:46 +08:00
parent 869061c783
commit 699c57d376
No known key found for this signature in database
GPG Key ID: 83EF2D9C2A5D6927
3 changed files with 26 additions and 2 deletions

View File

@ -1,4 +1,13 @@
ifeq ($(CORE), LOONGSON3R5) ifeq ($(CORE), LOONGSON3R5)
CCOMMON_OPT += -march=loongarch64 -mabi=lp64 CCOMMON_OPT += -march=loongarch64
FCOMMON_OPT += -march=loongarch64 -mabi=lp64 FCOMMON_OPT += -march=loongarch64
ifeq ($(LOONGARCH_CC_FLAVOR), NEW)
CCOMMON_OPT += -mabi=lp64d
FCOMMON_OPT += -mabi=lp64d
endif
ifeq ($(LOONGARCH_CC_FLAVOR), OLD)
CCOMMON_OPT += -mabi=lp64
FCOMMON_OPT += -mabi=lp64
endif
endif endif

View File

@ -1702,6 +1702,7 @@ export TARGET_CORE
export NO_AVX512 export NO_AVX512
export NO_AVX2 export NO_AVX2
export BUILD_BFLOAT16 export BUILD_BFLOAT16
export LOONGARCH_CC_FLAVOR
export NO_LASX export NO_LASX
export SBGEMM_UNROLL_M export SBGEMM_UNROLL_M

14
c_check
View File

@ -240,8 +240,19 @@ if [ "$architecture" = "riscv64" ]; then
rm -rf "$tmpd" rm -rf "$tmpd"
fi fi
loongarch_cc_flavor=""
no_lasx=0 no_lasx=0
if [ "$architecture" = "loongarch64" ]; then if [ "$architecture" = "loongarch64" ]; then
# Currently there are only 2 flavors: new-world and old-world.
# They differ in ABI names accepted, so check it to avoid creating temp
# files.
loongarch_cc_flavor="NEW"
{
$compiler_name -mabi=lp64d -E -o - /dev/null >/dev/null 2>&1
} || {
loongarch_cc_flavor="OLD"
}
tmpd=`mktemp -d` tmpd=`mktemp -d`
tmpf="$tmpd/a.c" tmpf="$tmpd/a.c"
# Old-world assembly flavor: LASX registers named "$xrNN", different # Old-world assembly flavor: LASX registers named "$xrNN", different
@ -260,6 +271,7 @@ if [ "$architecture" = "loongarch64" ]; then
} || { } || {
no_lasx=1 no_lasx=1
} }
rm -rf "$tmpd" rm -rf "$tmpd"
fi fi
@ -377,6 +389,7 @@ done
[ "$no_avx512" -eq 1 ] && printf "NO_AVX512=1\n" [ "$no_avx512" -eq 1 ] && printf "NO_AVX512=1\n"
[ "$no_avx2" -eq 1 ] && printf "NO_AVX2=1\n" [ "$no_avx2" -eq 1 ] && printf "NO_AVX2=1\n"
[ "$oldgcc" -eq 1 ] && printf "OLDGCC=1\n" [ "$oldgcc" -eq 1 ] && printf "OLDGCC=1\n"
[ -n "$loongarch_cc_flavor" ] && printf "LOONGARCH_CC_FLAVOR=%s\n" "$loongarch_cc_flavor"
exit 0 exit 0
} }
@ -408,6 +421,7 @@ done
[ "$no_avx512" -eq 1 ] && printf "NO_AVX512=1\n" [ "$no_avx512" -eq 1 ] && printf "NO_AVX512=1\n"
[ "$no_avx2" -eq 1 ] && printf "NO_AVX2=1\n" [ "$no_avx2" -eq 1 ] && printf "NO_AVX2=1\n"
[ "$oldgcc" -eq 1 ] && printf "OLDGCC=1\n" [ "$oldgcc" -eq 1 ] && printf "OLDGCC=1\n"
[ -n "$loongarch_cc_flavor" ] && printf "LOONGARCH_CC_FLAVOR=%s\n" "$loongarch_cc_flavor"
} >> "$makefile" } >> "$makefile"
os=`echo "$os" | tr '[[:lower:]]' '[[:upper:]]'/ ` os=`echo "$os" | tr '[[:lower:]]' '[[:upper:]]'/ `