gcc/libgcc/config/t-softfp
Joseph Myers e610393ca7 Make soft-fp symbols into compat symbols for powerpc*-*-linux*.
Continuing preparations for implementing
TARGET_ATOMIC_ASSIGN_EXPAND_FENV for powerpc*-*-linux* soft-float and
e500, this patch makes soft-fp symbols used for those targets into
compat symbols when building with glibc >= 2.19, so that they are only
in shared libgcc for existing binaries requiring them, not in static
libgcc and not available for new links using shared libgcc.  Instead,
new links will get the symbols from libc, which has exported all of
them since 2.19.  (Actually all the symbols were exported from glibc
since 2.4, but some of them were exported by glibc as compat symbols
only - because of a confusion between deliberately present soft-fp
symbols and old accidental reexports of libgcc functions from glibc
2.0 - until 2.19.)

This allows user floating-point arithmetic to interoperate properly
with the state handled by <fenv.h> functions, whether software state
(for soft-float; TLS variables that don't form a public part of
glibc's ABI, so can only be accessed directly by functions within
glibc) or hardware state (for e500 - the copies of the soft-fp
functions in glibc being built to interoperate with the hardware state
whereas those in libgcc aren't).  Previously only glibc's own
functions, and those operations done in hardware on e500, properly
worked with that state, not direct floating-point arithmetic
operations that were implemented in software.

The intended next step is the actual TARGET_ATOMIC_ASSIGN_EXPAND_FENV
implementation.

The test of glibc >= 2.19 uses the same --with-glibc-version configure
option as in the gcc/ directory (but differently implemented; in gcc/
the fallback is to examine headers to find the version, while in
libgcc/ we can use compile for the target and so use AC_COMPUTE_INT).
The TARGET_ATOMIC_ASSIGN_EXPAND_FENV implementation will also only do
anything for glibc >= 2.19, as it will depend on generating calls to
functions __atomic_feholdexcept __atomic_feclearexcept
__atomic_feupdateenv that were added in 2.19 for that purpose (even
for e500, inline code is not readily possible because of the need to
make prctl syscalls from the implementation of these functions).

In order to make symbols compat symbols, the soft-fp files need
wrapping with generated wrappers including asm .symver directives,
which need to name the symbol version in question.  This is extracted
by an awk script from an intermediate stage of generating the .map
file for linking libgcc (that .map itself depends on the objects that
go into the library, so can't be used for this purpose as that would
mean a circular dependency); the extraction is not fully general
regarding the features available in .map generation, but suffices for
the present purpose.

It would make sense for hardfp.c symbols to be compat symbols as well
(in the cases where hardfp.c gets used, the functions in question
should not be used for new links), but this isn't required for the
present purpose, which is only concerned with ensuring that where
functions that should be affected by rounding modes or exceptions get
used, those functions are actually affected by those rounding modes or
exceptions.

Tested with no regressions with cross to powerpc-linux-gnu
(soft-float); c11-atomic-exec-5.c moves from UNSUPPORTED to FAIL, as
expected, now that floating-point arithmetic in user programs uses the
same state as <fenv.h> functions, so the fenv_exceptions test passes,
but TARGET_ATOMIC_ASSIGN_EXPAND_FENV isn't yet implemented.  (For
e500, c11-atomic-exec-5.c was already FAILing, as enough operations
worked with the hardware state for the fenv_exceptions effective
target test to pass.)  Also verified that the exported symbols and
versions are unchanged, with the expected symbols becoming compat
symbols at the same versions, and that with --with-glibc-version=2.18
the symbols remain normal rather than compat symbols.

	* Makefile.in (libgcc.map.in): New target.
	(libgcc.map): Use libgcc.map.in.
	* config/t-softfp (softfp_compat): New variable to be set by
	users.
	[$(softfp_compat) = y] (softfp_map_dep, softfp_set_symver): New
	variables.
	[$(softfp_compat) = y] (softfp_file_list): Use files in the build
	directory.
	[$(softfp_compat) = y] ($(softfp_file_list)): Generate wrappers
	that use compat symbols and disable all code unless [SHARED].
	* config/t-softfp-compat: New file.
	* find-symver.awk: New file.
	* configure.ac (--with-glibc-version): New configure option.
	(ppc_fp_compat): New variable set for powerpc*-*-linux*.
	* configure: Regenerate.
	* config.host (powerpc*-*-linux*): Use ${ppc_fp_compat} for
	soft-float and e500.

From-SVN: r216942
2014-10-30 17:28:30 +00:00

143 lines
5.3 KiB
Plaintext

# Copyright (C) 2006-2014 Free Software Foundation, Inc.
# This file is part of GCC.
# GCC is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
# GCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
# Targets using soft-fp should define the following variables:
#
# softfp_float_modes: a list of soft-float floating-point modes,
# e.g. sf df
# softfp_int_modes: a list of integer modes for which to define conversions,
# e.g. si di
# softfp_extensions: a list of extensions between floating-point modes,
# e.g. sfdf
# softfp_truncations: a list of truncations between floating-point modes,
# e.g. dfsf
#
# Extensions and truncations should include those where only one mode
# is a soft-float mode; for example, sftf where sf is hard-float and
# tf is soft-float.
#
# If some additional functions should be built that are not implied by
# the above settings, also define softfp_extras as a list of those
# functions, e.g. unorddf2.
#
# If the functions should only be built as compat symbols for shared
# libgcc, not available for new links, also define:
#
# softfp_compat := y
#
# If the libgcc2.c functions should not be replaced, also define:
#
# softfp_exclude_libgcc2 := y
#
# Avoiding replacing the libgcc2.c functions is a temporary measure
# for targets with both hard-float and soft-float multilibs, since
# these variables apply for all multilibs. With toplevel libgcc,
# soft-fp can be used conditionally on the multilib instead.
#
# If the code should not be compiled at all for some multilibs, define:
#
# softfp_wrap_start: text to put at the start of wrapper source files,
# output with echo
# e.g. '#ifndef __powerpc64__'
# softfp_wrap_end: text to put at the end of wrapper source files,
# e.g. '#endif'
#
# This is another temporary measure, and cannot be used together with
# softfp_compat.
softfp_float_funcs = add$(m)3 div$(m)3 eq$(m)2 ge$(m)2 le$(m)2 mul$(m)3 \
neg$(m)2 sub$(m)3 unord$(m)2
softfp_floatint_funcs = fix$(m)$(i) fixuns$(m)$(i) \
float$(i)$(m) floatun$(i)$(m)
softfp_func_list := \
$(foreach m,$(softfp_float_modes), \
$(softfp_float_funcs) \
$(foreach i,$(softfp_int_modes), \
$(softfp_floatint_funcs))) \
$(foreach e,$(softfp_extensions),extend$(e)2) \
$(foreach t,$(softfp_truncations),trunc$(t)2) \
$(softfp_extras)
ifeq ($(softfp_exclude_libgcc2),y)
# This list is taken from mklibgcc.in and doesn't presently allow for
# 64-bit targets where si should become di and di should become ti.
softfp_func_list := $(filter-out floatdidf floatdisf fixunsdfsi fixunssfsi \
fixunsdfdi fixdfdi fixunssfdi fixsfdi fixxfdi fixunsxfdi \
floatdixf fixunsxfsi fixtfdi fixunstfdi floatditf \
floatundidf floatundisf floatundixf floatunditf,$(softfp_func_list))
endif
ifeq ($(softfp_compat),y)
softfp_file_list := $(addsuffix .c,$(softfp_func_list))
ifeq ($(enable_shared),yes)
softfp_map_dep := libgcc.map.in
else
softfp_map_dep :=
endif
softfp_set_symver = echo "asm (\".symver $(1),$(1)@`$(AWK) -f $(srcdir)/find-symver.awk -v symbol=$(1) libgcc.map.in`\");" >> $@
$(softfp_file_list): $(softfp_map_dep)
echo '#ifdef SHARED' > $@
echo '#include "soft-fp/$@"' >> $@
ifeq ($(enable_shared),yes)
$(call softfp_set_symver,__$(*F))
if grep strong_alias $(srcdir)/soft-fp/$@ > /dev/null; then \
alias=`grep strong_alias $(srcdir)/soft-fp/$@ | sed -e 's/.*, *//' -e 's/).*//'`; \
$(call softfp_set_symver,$$alias); \
fi
endif
echo '#endif' >> $@
else ifneq ($(softfp_wrap_start),)
softfp_file_list := $(addsuffix .c,$(softfp_func_list))
$(softfp_file_list):
echo $(softfp_wrap_start) > $@
echo '#include "soft-fp/$@"' >> $@
echo $(softfp_wrap_end) >> $@
else
softfp_file_list := \
$(addsuffix .c,$(addprefix $(srcdir)/soft-fp/,$(softfp_func_list)))
endif
# Disable missing prototype and type limit warnings. The prototypes
# for the functions in the soft-fp files have not been brought across
# from glibc.
soft-fp-objects-base = $(basename $(notdir $(softfp_file_list)))
soft-fp-objects = $(addsuffix $(objext), $(soft-fp-objects-base)) \
$(addsuffix _s$(objext), $(soft-fp-objects-base))
$(soft-fp-objects) : INTERNAL_CFLAGS += -Wno-missing-prototypes -Wno-type-limits
LIB2ADD += $(softfp_file_list)
ifneq ($(softfp_exclude_libgcc2),y)
# Functions in libgcc2.c are excluded for each soft-float mode (a
# target may have both soft-float and hard-float modes), for the fixed
# list of integer modes (si and di) for which libgcc2.c defines any
# such functions. Depending on the target, the si and di symbols may
# in fact define di and ti functions.
LIB2FUNCS_EXCLUDE += \
$(addprefix _,$(foreach m,$(softfp_float_modes), \
$(foreach i,si di, \
$(softfp_floatint_funcs))))
endif