Honor --disable-decimal-float in building _Float128 support. Joseph Myers reported that my previous patch to add conversions between _Float128 and the Decimal types was still being built even if GCC was configured with the --disable-decimal-float option. This patch fixes that by only building the conversion functions if both _Float128 and Decimal support are built into GCC.
In addition, I removed the dependency on the target having a valid stdio.h file to declare sprintf in building _sprintfkf.c. Finally I noticed I had a mismatch in the _sprintfkf.h include file, and I fixed that. Joseph, does this patch fix your problem? I have built cross compilers on the x86 with/without --disable-decimal-float and the conversion functions are not built if --disable-decimal-float was used. I have built stage1 compilers with all three long double formats on the native little endian system, and I verified that they conversions are only built if Decimal support is eabled. As I post this, the bootstrap builds are going on. Assuming the bootstrap builds are successful, can I check this patch into the master branch? libgcc/ 2021-02-26 Michael Meissner <meiss...@linux.ibm.com> * config.host (powerpc*-*-linux): Move the Decimal/_Float128 * conversions into t-float128-dec. * config/rs6000/_sprintfkf.c: Do not include stdio.h. Include _sprintfkf.h. * config/rs6000/_sprintfkf.h (__sprintfkf): Update calling signature. (sprintf): Add declaration. * config/rs6000/t-float128 (fp128_dec_funcs): Move to t-float128-dec. (fp128_decstr_funcs): Move to t-float128-dec. (ibm128_dec_funcs): Move to t-float128-dec. (fp128_dec_objs): Move to t-float128-dec. (fp128_decstr_objs): Move to t-float128-dec. (ibm128_dec_objs): Move to t-float128-dec. (FP128_CFLAGS_DECIMAL): Move to t-float128-dec. (IBM128_CFLAGS_DECIMAL): Move to t-float128-dec. * config/rs6000/t-float128-dec: New file. * configure.ac (libgcc_cv_powerpc_float128_dec): New variable, set to yes if both _Float128 and Decimal support are available. * configure: Regenerate. --- libgcc/config.host | 4 +++ libgcc/config/rs6000/_sprintfkf.c | 4 ++- libgcc/config/rs6000/_sprintfkf.h | 2 +- libgcc/config/rs6000/t-float128 | 42 +++++------------------------ libgcc/config/rs6000/t-float128-dec | 37 +++++++++++++++++++++++++ libgcc/configure | 22 ++++++++++++++- libgcc/configure.ac | 8 ++++++ 7 files changed, 80 insertions(+), 39 deletions(-) create mode 100644 libgcc/config/rs6000/t-float128-dec diff --git a/libgcc/config.host b/libgcc/config.host index f808b61be70..b5b4b0b3ba0 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -1220,6 +1220,10 @@ powerpc*-*-linux*) tmake_file="${tmake_file} rs6000/t-float128" fi + if test $libgcc_cv_powerpc_float128_dec = yes; then + tmake_file="${tmake_file} rs6000/t-float128-dec" + fi + if test $libgcc_cv_powerpc_float128_hw = yes; then tmake_file="${tmake_file} rs6000/t-float128-hw" fi diff --git a/libgcc/config/rs6000/_sprintfkf.c b/libgcc/config/rs6000/_sprintfkf.c index a7fdfb483c9..b367861fcc3 100644 --- a/libgcc/config/rs6000/_sprintfkf.c +++ b/libgcc/config/rs6000/_sprintfkf.c @@ -27,7 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include <stdlib.h> #include <soft-fp.h> #include <quad-float128.h> -#include <stdio.h> +#include <_sprintfkf.h> + +extern int sprintf (char *restrict, const char *restrict, ...); /* This function must be built with IBM 128-bit as long double, so that we can access the strfroml function if do not have an IEEE 128-bit version, and if diff --git a/libgcc/config/rs6000/_sprintfkf.h b/libgcc/config/rs6000/_sprintfkf.h index 637d104c882..22b245d2cbb 100644 --- a/libgcc/config/rs6000/_sprintfkf.h +++ b/libgcc/config/rs6000/_sprintfkf.h @@ -24,5 +24,5 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see /* Declaration of the conversion function to IEEE 128-bit floating point from string using snprintf. */ -extern int __sprintfkf (char *restrict, const char *restrict, ...); +extern int __sprintfkf (char *restrict, const char *restrict, _Float128); diff --git a/libgcc/config/rs6000/t-float128 b/libgcc/config/rs6000/t-float128 index 6fb1a3d871b..bbc66465050 100644 --- a/libgcc/config/rs6000/t-float128 +++ b/libgcc/config/rs6000/t-float128 @@ -22,18 +22,6 @@ fp128_softfp_static_obj = $(addsuffix -sw$(objext),$(fp128_softfp_funcs)) fp128_softfp_shared_obj = $(addsuffix -sw_s$(objext),$(fp128_softfp_funcs)) fp128_softfp_obj = $(fp128_softfp_static_obj) $(fp128_softfp_shared_obj) -# Decimal <-> _Float128 conversions -fp128_dec_funcs = _kf_to_sd _kf_to_dd _kf_to_td \ - _sd_to_kf _dd_to_kf _td_to_kf - -# _Float128 to/from string conversions that must be compiled with IBM 128-bit -# long double. -fp128_decstr_funcs = _strtokf _sprintfkf - -# Decimal <-> __ibm128 conversions -ibm128_dec_funcs = _tf_to_sd _tf_to_dd _tf_to_td \ - _sd_to_tf _dd_to_tf _td_to_tf - # New functions for software emulation fp128_ppc_funcs = floattikf floatuntikf fixkfti fixunskfti \ extendkftf2-sw trunctfkf2-sw \ @@ -48,13 +36,16 @@ fp128_ppc_obj = $(fp128_ppc_static_obj) $(fp128_ppc_shared_obj) # All functions fp128_funcs = $(fp128_softfp_funcs) $(fp128_ppc_funcs) \ - $(fp128_hw_funcs) $(fp128_ifunc_funcs) + $(fp128_hw_funcs) $(fp128_ifunc_funcs) \ + $(fp128_dec_funcs) fp128_src = $(fp128_softfp_src) $(fp128_ppc_src) \ - $(fp128_hw_src) $(fp128_ifunc_src) + $(fp128_hw_src) $(fp128_ifunc_src) \ + $(fp128_dec_src) fp128_obj = $(fp128_softfp_obj) $(fp128_ppc_obj) \ - $(fp128_hw_obj) $(fp128_ifunc_obj) + $(fp128_hw_obj) $(fp128_ifunc_obj) \ + $(fp128_dec_obj) fp128_sed = $(srcdir)/config/rs6000/float128-sed$(fp128_sed_hw) fp128_dep = $(fp128_sed) $(srcdir)/config/rs6000/t-float128 @@ -82,27 +73,6 @@ $(fp128_ppc_obj) : INTERNAL_CFLAGS += $(FP128_CFLAGS_SW) $(fp128_obj) : $(fp128_includes) $(fp128_obj) : $(srcdir)/config/rs6000/quad-float128.h -# Force the TF mode to/from decimal functions to be compiled with IBM long -# double. Add building the KF mode to/from decimal conversions with explict -# IEEE long double. -fp128_dec_objs = $(addsuffix $(objext),$(fp128_dec_funcs)) \ - $(addsuffix _s$(objext),$(fp128_dec_funcs)) - -fp128_decstr_objs = $(addsuffix $(objext),$(fp128_decstr_funcs)) \ - $(addsuffix _s$(objext),$(fp128_decstr_funcs)) - -ibm128_dec_objs = $(addsuffix $(objext),$(ibm128_dec_funcs)) \ - $(addsuffix _s$(objext),$(ibm128_dec_funcs)) - -FP128_CFLAGS_DECIMAL = -mno-gnu-attribute -Wno-psabi -mabi=ieeelongdouble -IBM128_CFLAGS_DECIMAL = -mno-gnu-attribute -Wno-psabi -mabi=ibmlongdouble - -$(fp128_dec_objs) : INTERNAL_CFLAGS += $(FP128_CFLAGS_DECIMAL) -$(fp128_decstr_objs) : INTERNAL_CFLAGS += $(IBM128_CFLAGS_DECIMAL) -$(ibm128_dec_objs) : INTERNAL_CFLAGS += $(IBM128_CFLAGS_DECIMAL) - -$(fp128_decstr_objs) : $(srcdir)/config/rs6000/_strtokf.h \ - $(srcdir)/config/rs6000/_sprintfkf.h \ $(fp128_softfp_src) : $(srcdir)/soft-fp/$(subst -sw,,$(subst kf,tf,$@)) $(fp128_dep) @src="$(srcdir)/soft-fp/$(subst -sw,,$(subst kf,tf,$@))"; \ diff --git a/libgcc/config/rs6000/t-float128-dec b/libgcc/config/rs6000/t-float128-dec new file mode 100644 index 00000000000..7a928260cec --- /dev/null +++ b/libgcc/config/rs6000/t-float128-dec @@ -0,0 +1,37 @@ +# Support for adding conversions between __float128 and Decimal to the powerpc. +# The t-float128 makefile fragment includes these objects if both float128 and +# decimal support is built-in. + +# Decimal <-> _Float128 conversions +fp128_dec_funcs = _kf_to_sd _kf_to_dd _kf_to_td \ + _sd_to_kf _dd_to_kf _td_to_kf + +# _Float128 to/from string conversions that must be compiled with IBM 128-bit +# long double. +fp128_decstr_funcs = _strtokf _sprintfkf + +# Decimal <-> __ibm128 conversions +ibm128_dec_funcs = _tf_to_sd _tf_to_dd _tf_to_td \ + _sd_to_tf _dd_to_tf _td_to_tf + +# Force the TF mode to/from decimal functions to be compiled with IBM long +# double. Add building the KF mode to/from decimal conversions with explict +# IEEE long double. +fp128_dec_objs = $(addsuffix $(objext),$(fp128_dec_funcs)) \ + $(addsuffix _s$(objext),$(fp128_dec_funcs)) + +fp128_decstr_objs = $(addsuffix $(objext),$(fp128_decstr_funcs)) \ + $(addsuffix _s$(objext),$(fp128_decstr_funcs)) + +ibm128_dec_objs = $(addsuffix $(objext),$(ibm128_dec_funcs)) \ + $(addsuffix _s$(objext),$(ibm128_dec_funcs)) + +FP128_CFLAGS_DECIMAL = $(FP128_CFLAGS_SW) -Wno-psabi -mabi=ieeelongdouble +IBM128_CFLAGS_DECIMAL = $(FP128_CFLAGS_SW) -Wno-psabi -mabi=ibmlongdouble + +$(fp128_dec_objs) : INTERNAL_CFLAGS += $(FP128_CFLAGS_DECIMAL) +$(fp128_decstr_objs) : INTERNAL_CFLAGS += $(IBM128_CFLAGS_DECIMAL) +$(ibm128_dec_objs) : INTERNAL_CFLAGS += $(IBM128_CFLAGS_DECIMAL) + +$(fp128_decstr_objs) : $(srcdir)/config/rs6000/_strtokf.h \ + $(srcdir)/config/rs6000/_sprintfkf.h \ diff --git a/libgcc/configure b/libgcc/configure index 78fc22a5784..0d8844e6d99 100755 --- a/libgcc/configure +++ b/libgcc/configure @@ -4913,7 +4913,7 @@ case "$host" in case "$enable_cet" in auto) # Check if target supports multi-byte NOPs - # and if assembler supports CET insn. + # and if compiler and assembler support CET insn. cet_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fcf-protection" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -5228,6 +5228,26 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgcc_cv_powerpc_float128" >&5 $as_echo "$libgcc_cv_powerpc_float128" >&6; } + CFLAGS="$CFLAGS -mvsx -mfloat128" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PowerPC __float128 libraries with decimal support" >&5 +$as_echo_n "checking for PowerPC __float128 libraries with decimal support... " >&6; } +if ${libgcc_cv_powerpc_float128_dec+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +_Float128 convert (_Decimal128 a) { return a; } +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + libgcc_cv_powerpc_float128_dec=yes +else + libgcc_cv_powerpc_float128_dec=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgcc_cv_powerpc_float128_dec" >&5 +$as_echo "$libgcc_cv_powerpc_float128_dec" >&6; } + CFLAGS="$CFLAGS -mpower9-vector -mfloat128-hardware" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PowerPC ISA 3.0 to build hardware __float128 libraries" >&5 $as_echo_n "checking for PowerPC ISA 3.0 to build hardware __float128 libraries... " >&6; } diff --git a/libgcc/configure.ac b/libgcc/configure.ac index ed50c0e9b49..b5176265296 100644 --- a/libgcc/configure.ac +++ b/libgcc/configure.ac @@ -435,6 +435,14 @@ powerpc*-*-linux*) [libgcc_cv_powerpc_float128=yes], [libgcc_cv_powerpc_float128=no])]) + CFLAGS="$CFLAGS -mvsx -mfloat128" + AC_CACHE_CHECK([for PowerPC __float128 libraries with decimal support], + [libgcc_cv_powerpc_float128_dec], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([_Float128 convert (_Decimal128 a) { return a; }])], + [libgcc_cv_powerpc_float128_dec=yes], + [libgcc_cv_powerpc_float128_dec=no])]) + CFLAGS="$CFLAGS -mpower9-vector -mfloat128-hardware" AC_CACHE_CHECK([for PowerPC ISA 3.0 to build hardware __float128 libraries], [libgcc_cv_powerpc_float128_hw], -- 2.22.0 -- Michael Meissner, IBM IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA email: meiss...@linux.ibm.com, phone: +1 (978) 899-4797