C-SKY: Strip hard float abi from hard float feature.

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  <adhemerval.zanella@linaro.org>
This commit is contained in:
quxm 2023-01-25 17:47:33 +08:00 committed by Mao Han
parent 41f67ccbe9
commit ec6d2b83f2
4 changed files with 72 additions and 47 deletions

View file

@ -123,9 +123,12 @@
/* C-SKY ABI version. */ /* C-SKY ABI version. */
#undef CSKYABI #undef CSKYABI
/* C-SKY floating-point ABI. */ /* C-SKY floating-point instructions. */
#undef CSKY_HARD_FLOAT #undef CSKY_HARD_FLOAT
/* C-SKY floating-point ABI. */
#undef CSKY_HARD_FLOAT_ABI
/* RISC-V integer ABI for ld.so. */ /* RISC-V integer ABI for ld.so. */
#undef RISCV_ABI_XLEN #undef RISCV_ABI_XLEN

59
sysdeps/csky/preconfigure Normal file → Executable file
View file

@ -5,10 +5,8 @@ case "$machine" in
csky*) csky*)
abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
sed -n 's/^#define __CSKYABI__ \(.*\)/\1/p'` sed -n 's/^#define __CSKYABI__ \(.*\)/\1/p'`
hard_float=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | soft_float=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
sed -n 's/^#define __CSKY_HARD_FLOAT__ \(.*\)/\1/p'` sed -n 's/^#define __CSKY_SOFT_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'`
hard_float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | hard_float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
sed -n 's/^#define __CSKY_HARD_FLOAT_ABI__ \(.*\)/\1/p'` sed -n 's/^#define __CSKY_HARD_FLOAT_ABI__ \(.*\)/\1/p'`
@ -24,26 +22,39 @@ csky*)
;; ;;
esac esac
# __CSKY_HARD_FLOAT_ABI__ was added on gcc 11 to specify whether # This check is for compatibility with GCC versions earlier than 11.
# -mfloat-abi=hard is set. On older gcc, the float ABI is defined solely # The older versions of C-SKY GCC do not support the '-mfloat-abi=softfp' option
# with __CSKY_HARD_FLOAT__. If __CSKY_HARD_FLOAT__ is set, it can be # and never define the '__CSKY_HARD_FLOAT_ABI__'.
# either a hard-float ABI (gcc older than 11, or gcc11 -mfloat-abi=hard # Therefore, if a check for '-mfloat-abi=softfp' is added as the expression
# (__CSKY_HARD_FLOAT_ABI__ is set) or -mfloat-abi=softfp # 'defined(__CSKY_HARD_FLOAT__) && !defined(__CSKY_HARD_FLOAT_ABI__)'
# (__CSKY_HARD_FLOAT_ABI__ is not set). To be compatible with older gcc, # which is correct for newer versions of GCC will not work for those older versions.
# use __CSKY_HARD_FLOAT_FPU_SF__ identify if -mfloat-abi is supported, # Since no expression compatible with all versions of GCC exists,
# because it is added to gcc at the same time as -mfloat-abi. # a check for the '-mfloat-abi=softfp' option is added.
if test -n "$hard_float"; then if { ac_try='${CC-cc} -S -mfloat-abi=softfp /dev/null 1>&5'
if test -z "$hard_float_sf"; then { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
with_fp_cond=1 (eval $ac_try) 2>&5
else ac_status=$?
if test -n "$hard_float_abi"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
with_fp_cond=1 test $ac_status = 0; }; }; then
else soft_float_abi_support=1
with_fp_cond=0
fi
fi
else else
soft_float_abi_support=0
fi
if test -n "$soft_float"; then
with_fp_cond=0 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_hard_float_abi=1
else
with_hard_float_abi=0
fi
else
with_hard_float_abi=1
fi
fi fi
base_machine=csky base_machine=csky
@ -55,6 +66,10 @@ _ACEOF
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
#define CSKY_HARD_FLOAT $with_fp_cond #define CSKY_HARD_FLOAT $with_fp_cond
_ACEOF
cat >>confdefs.h <<_ACEOF
#define CSKY_HARD_FLOAT_ABI $with_hard_float_abi
_ACEOF _ACEOF
;; ;;

View file

@ -5,10 +5,8 @@ case "$machine" in
csky*) csky*)
abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
sed -n 's/^#define __CSKYABI__ \(.*\)/\1/p'` sed -n 's/^#define __CSKYABI__ \(.*\)/\1/p'`
hard_float=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | soft_float=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
sed -n 's/^#define __CSKY_HARD_FLOAT__ \(.*\)/\1/p'` sed -n 's/^#define __CSKY_SOFT_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'`
hard_float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | hard_float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
sed -n 's/^#define __CSKY_HARD_FLOAT_ABI__ \(.*\)/\1/p'` sed -n 's/^#define __CSKY_HARD_FLOAT_ABI__ \(.*\)/\1/p'`
@ -24,26 +22,34 @@ csky*)
;; ;;
esac esac
# __CSKY_HARD_FLOAT_ABI__ was added on gcc 11 to specify whether # This check is for compatibility with GCC versions earlier than 11.
# -mfloat-abi=hard is set. On older gcc, the float ABI is defined solely # The older versions of C-SKY GCC do not support the '-mfloat-abi=softfp' option
# with __CSKY_HARD_FLOAT__. If __CSKY_HARD_FLOAT__ is set, it can be # and never define the '__CSKY_HARD_FLOAT_ABI__'.
# either a hard-float ABI (gcc older than 11, or gcc11 -mfloat-abi=hard # Therefore, if a check for '-mfloat-abi=softfp' is added as the expression
# (__CSKY_HARD_FLOAT_ABI__ is set) or -mfloat-abi=softfp # 'defined(__CSKY_HARD_FLOAT__) && !defined(__CSKY_HARD_FLOAT_ABI__)'
# (__CSKY_HARD_FLOAT_ABI__ is not set). To be compatible with older gcc, # which is correct for newer versions of GCC will not work for those older versions.
# use __CSKY_HARD_FLOAT_FPU_SF__ identify if -mfloat-abi is supported, # Since no expression compatible with all versions of GCC exists,
# because it is added to gcc at the same time as -mfloat-abi. # a check for the '-mfloat-abi=softfp' option is added.
if test -n "$hard_float"; then if AC_TRY_COMMAND(${CC-cc} -S -mfloat-abi=softfp /dev/null 1>&AS_MESSAGE_LOG_FD); then
if test -z "$hard_float_sf"; then soft_float_abi_support=1
with_fp_cond=1
else
if test -n "$hard_float_abi"; then
with_fp_cond=1
else
with_fp_cond=0
fi
fi
else else
soft_float_abi_support=0
fi
if test -n "$soft_float"; then
with_fp_cond=0 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_hard_float_abi=1
else
with_hard_float_abi=0
fi
else
with_hard_float_abi=1
fi
fi fi
base_machine=csky base_machine=csky
@ -51,5 +57,6 @@ csky*)
AC_DEFINE_UNQUOTED([CSKYABI], [$abi]) AC_DEFINE_UNQUOTED([CSKYABI], [$abi])
AC_DEFINE_UNQUOTED([CSKY_HARD_FLOAT], [$with_fp_cond]) AC_DEFINE_UNQUOTED([CSKY_HARD_FLOAT], [$with_fp_cond])
AC_DEFINE_UNQUOTED([CSKY_HARD_FLOAT_ABI], [$with_hard_float_abi])
;; ;;
esac esac

View file

@ -1,8 +1,8 @@
DEFAULT GLIBC_2.29 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 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 ld=ld-linux-cskyv2.so.1
%else %else
%error cannot determine ABI %error cannot determine ABI