From patchwork Thu Feb 2 08:55:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xianmiao Qu X-Patchwork-Id: 64137 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 86C9A3856975 for ; Thu, 2 Feb 2023 08:56:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 86C9A3856975 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675328167; bh=UO5B89vBqW0VyT/QrUEt6oP30efZi3oUbA5HFBbnUVs=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=nwgrQPuzrTUnSzTaShhjk4Ayvvn9go/ZfBBs13/YhELbjyV9H+5+4F4cUWkSJhx6O bi65TPjiDx7E/s3qJHfgBy0iUZZMPB/PTyigg00GW4iM9fpT14GnRisF1Q/JjMrcne 5ES6TOQ9uG5SISnujodxe4E4IdtvHUJbOjLwdGkI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from out30-97.freemail.mail.aliyun.com (out30-97.freemail.mail.aliyun.com [115.124.30.97]) by sourceware.org (Postfix) with ESMTPS id DA5023858C30 for ; Thu, 2 Feb 2023 08:55:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DA5023858C30 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R171e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045170; MF=cooper.qu@linux.alibaba.com; NM=1; PH=DS; RN=5; SR=0; TI=SMTPD_---0VakGEMj_1675328132; Received: from localhost(mailfrom:cooper.qu@linux.alibaba.com fp:SMTPD_---0VakGEMj_1675328132) by smtp.aliyun-inc.com; Thu, 02 Feb 2023 16:55:32 +0800 To: libc-alpha@sourceware.org, han_mao@linux.alibaba.com, adhemerval.zanella@linaro.org Cc: fweimer@redhat.com, quxm Subject: [PATCH] C-SKY: Strip hard float abi from hard float feature. Date: Thu, 2 Feb 2023 16:55:16 +0800 Message-Id: <20230202085515.14283-1-cooper.qu@linux.alibaba.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) MIME-Version: 1.0 X-Spam-Status: No, score=-20.1 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Xianmiao Qu via Libc-alpha From: Xianmiao Qu Reply-To: Xianmiao Qu Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" From: quxm The hard float abi and hard float are different, Hard float abi: Use float register to pass float type arguments. Hard float: Enable the hard float ISA feature. So the with_fp_cond cannot represent these two features. When -mfloat-abi=softfp, the float abi is soft and hard float is enabled. So add 'with_hard_float_abi' in preconfigure and define 'CSKY_HARD_FLOAT_ABI' if float abi is hard, and use 'CSKY_HARD_FLOAT_ABI' to determine dynamic linker because it is what determines compatibility. And with_fp_cond is still needed to tell glibc whether to enable hard floating feature. In addition, use AC_TRY_COMMAND to test gcc to ensure compatibility between different versions of gcc. The original way has a problem that __CSKY_HARD_FLOAT_FPU_SF__ means the target only has single hard float-points ISA, so it's not defined in CPUs like ck810f. Reviewed-by: Adhemerval Zanella --- config.h.in | 5 +- sysdeps/csky/preconfigure | 55 +++++++++++++-------- sysdeps/csky/preconfigure.ac | 47 ++++++++++-------- sysdeps/unix/sysv/linux/csky/shlib-versions | 4 +- 4 files changed, 68 insertions(+), 43 deletions(-) mode change 100644 => 100755 sysdeps/csky/preconfigure diff --git a/config.h.in b/config.h.in index 43d32518ab..09730d9d52 100644 --- a/config.h.in +++ b/config.h.in @@ -123,9 +123,12 @@ /* C-SKY ABI version. */ #undef CSKYABI -/* C-SKY floating-point ABI. */ +/* C-SKY floating-point instructions. */ #undef CSKY_HARD_FLOAT +/* C-SKY floating-point ABI. */ +#undef CSKY_HARD_FLOAT_ABI + /* RISC-V integer ABI for ld.so. */ #undef RISCV_ABI_XLEN diff --git a/sysdeps/csky/preconfigure b/sysdeps/csky/preconfigure old mode 100644 new mode 100755 index 8a6136dd8d..7f8621b607 --- a/sysdeps/csky/preconfigure +++ b/sysdeps/csky/preconfigure @@ -5,10 +5,8 @@ case "$machine" in csky*) abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __CSKYABI__ \(.*\)/\1/p'` - hard_float=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | - sed -n 's/^#define __CSKY_HARD_FLOAT__ \(.*\)/\1/p'` - hard_float_sf=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | - sed -n 's/^#define __CSKY_HARD_FLOAT_FPU_SF__ \(.*\)/\1/p'` + soft_float=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | + sed -n 's/^#define __CSKY_SOFT_FLOAT__ \(.*\)/\1/p'` hard_float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __CSKY_HARD_FLOAT_ABI__ \(.*\)/\1/p'` @@ -24,26 +22,39 @@ csky*) ;; esac - # __CSKY_HARD_FLOAT_ABI__ was added on gcc 11 to specify whether - # -mfloat-abi=hard is set. On older gcc, the float ABI is defined solely - # with __CSKY_HARD_FLOAT__. If __CSKY_HARD_FLOAT__ is set, it can be - # either a hard-float ABI (gcc older than 11, or gcc11 -mfloat-abi=hard - # (__CSKY_HARD_FLOAT_ABI__ is set) or -mfloat-abi=softfp - # (__CSKY_HARD_FLOAT_ABI__ is not set). To be compatible with older gcc, - # use __CSKY_HARD_FLOAT_FPU_SF__ identify if -mfloat-abi is supported, - # because it is added to gcc at the same time as -mfloat-abi. - if test -n "$hard_float"; then - if test -z "$hard_float_sf"; then - with_fp_cond=1 - else + # This check is for compatibility with GCC versions earlier than 11. + # The older versions of C-SKY GCC do not support the '-mfloat-abi=softfp' option + # and never define the '__CSKY_HARD_FLOAT_ABI__'. + # Therefore, if a check for '-mfloat-abi=softfp' is added as the expression + # 'defined(__CSKY_HARD_FLOAT__) && !defined(__CSKY_HARD_FLOAT_ABI__)' + # which is correct for newer versions of GCC will not work for those older versions. + # Since no expression compatible with all versions of GCC exists, + # a check for the '-mfloat-abi=softfp' option is added. + if { ac_try='${CC-cc} -S -mfloat-abi=softfp /dev/null 1>&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + soft_float_abi_support=1 + else + soft_float_abi_support=0 + fi + + if test -n "$soft_float"; then + with_fp_cond=0 + with_hard_float_abi=0 + else + with_fp_cond=1 + if test -n "$soft_float_abi_support"; then if test -n "$hard_float_abi"; then - with_fp_cond=1 + with_hard_float_abi=1 else - with_fp_cond=0 + with_hard_float_abi=0 fi + else + with_hard_float_abi=1 fi - else - with_fp_cond=0 fi base_machine=csky @@ -55,6 +66,10 @@ _ACEOF cat >>confdefs.h <<_ACEOF #define CSKY_HARD_FLOAT $with_fp_cond +_ACEOF + + cat >>confdefs.h <<_ACEOF +#define CSKY_HARD_FLOAT_ABI $with_hard_float_abi _ACEOF ;; diff --git a/sysdeps/csky/preconfigure.ac b/sysdeps/csky/preconfigure.ac index 332c0f1cab..9a4083dda5 100644 --- a/sysdeps/csky/preconfigure.ac +++ b/sysdeps/csky/preconfigure.ac @@ -5,10 +5,8 @@ case "$machine" in csky*) abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __CSKYABI__ \(.*\)/\1/p'` - hard_float=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | - sed -n 's/^#define __CSKY_HARD_FLOAT__ \(.*\)/\1/p'` - hard_float_sf=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | - sed -n 's/^#define __CSKY_HARD_FLOAT_FPU_SF__ \(.*\)/\1/p'` + soft_float=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | + sed -n 's/^#define __CSKY_SOFT_FLOAT__ \(.*\)/\1/p'` hard_float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __CSKY_HARD_FLOAT_ABI__ \(.*\)/\1/p'` @@ -24,26 +22,34 @@ csky*) ;; esac - # __CSKY_HARD_FLOAT_ABI__ was added on gcc 11 to specify whether - # -mfloat-abi=hard is set. On older gcc, the float ABI is defined solely - # with __CSKY_HARD_FLOAT__. If __CSKY_HARD_FLOAT__ is set, it can be - # either a hard-float ABI (gcc older than 11, or gcc11 -mfloat-abi=hard - # (__CSKY_HARD_FLOAT_ABI__ is set) or -mfloat-abi=softfp - # (__CSKY_HARD_FLOAT_ABI__ is not set). To be compatible with older gcc, - # use __CSKY_HARD_FLOAT_FPU_SF__ identify if -mfloat-abi is supported, - # because it is added to gcc at the same time as -mfloat-abi. - if test -n "$hard_float"; then - if test -z "$hard_float_sf"; then - with_fp_cond=1 - else + # This check is for compatibility with GCC versions earlier than 11. + # The older versions of C-SKY GCC do not support the '-mfloat-abi=softfp' option + # and never define the '__CSKY_HARD_FLOAT_ABI__'. + # Therefore, if a check for '-mfloat-abi=softfp' is added as the expression + # 'defined(__CSKY_HARD_FLOAT__) && !defined(__CSKY_HARD_FLOAT_ABI__)' + # which is correct for newer versions of GCC will not work for those older versions. + # Since no expression compatible with all versions of GCC exists, + # a check for the '-mfloat-abi=softfp' option is added. + if AC_TRY_COMMAND(${CC-cc} -S -mfloat-abi=softfp /dev/null 1>&AS_MESSAGE_LOG_FD); then + soft_float_abi_support=1 + else + soft_float_abi_support=0 + fi + + if test -n "$soft_float"; then + with_fp_cond=0 + with_hard_float_abi=0 + else + with_fp_cond=1 + if test -n "$soft_float_abi_support"; then if test -n "$hard_float_abi"; then - with_fp_cond=1 + with_hard_float_abi=1 else - with_fp_cond=0 + with_hard_float_abi=0 fi + else + with_hard_float_abi=1 fi - else - with_fp_cond=0 fi base_machine=csky @@ -51,5 +57,6 @@ csky*) AC_DEFINE_UNQUOTED([CSKYABI], [$abi]) AC_DEFINE_UNQUOTED([CSKY_HARD_FLOAT], [$with_fp_cond]) + AC_DEFINE_UNQUOTED([CSKY_HARD_FLOAT_ABI], [$with_hard_float_abi]) ;; esac diff --git a/sysdeps/unix/sysv/linux/csky/shlib-versions b/sysdeps/unix/sysv/linux/csky/shlib-versions index 8c026356ef..4ab7d6b83e 100644 --- a/sysdeps/unix/sysv/linux/csky/shlib-versions +++ b/sysdeps/unix/sysv/linux/csky/shlib-versions @@ -1,8 +1,8 @@ DEFAULT GLIBC_2.29 -%if CSKYABI == 2 && CSKY_HARD_FLOAT == 1 +%if CSKYABI == 2 && CSKY_HARD_FLOAT_ABI == 1 ld=ld-linux-cskyv2-hf.so.1 -%elif CSKYABI == 2 && CSKY_HARD_FLOAT == 0 +%elif CSKYABI == 2 && CSKY_HARD_FLOAT_ABI == 0 ld=ld-linux-cskyv2.so.1 %else %error cannot determine ABI