Hi Joseph, > On 2 Sep 2021, at 21:03, Joseph Myers <jos...@codesourcery.com> wrote: > > On Thu, 2 Sep 2021, Iain Sandoe via Gcc-patches wrote: > >> diff --git a/libgcc/soft-fp/eqdf2.c b/libgcc/soft-fp/eqdf2.c >> index 2a44ee377ce..a3bb664f5f1 100644 >> --- a/libgcc/soft-fp/eqdf2.c >> +++ b/libgcc/soft-fp/eqdf2.c >> @@ -28,6 +28,7 @@ >> License along with the GNU C Library; if not, see >> <http://www.gnu.org/licenses/>. */ >> >> +#define DarwinMode DF >> #include "soft-fp.h" >> #include "double.h" > > All these files are supposed to be taken unmodified from glibc. They > shouldn't contain any OS-specific code, such as a define of DarwinMode. > sfp-machine.h, however, is libgcc-local, hence putting the definition of > strong_alias there.
OK, that makes sense. > > So you need some other way to extract the argument type of name in order > to use it in a declaration of aliasname. E.g. > > __typeof (_Generic (name, > CMPtype (*) (HFtype, HFtype): (HFtype) 0, > CMPtype (*) (SFtype, SFtype): (SFtype) 0, > CMPtype (*) (DFtype, DFtype): (DFtype) 0, > CMPtype (*) (TFtype, TFtype): (TFtype) 0)) thanks for the suggestion > Now in fact I think the include ordering means none of the *type macros > are defined here. But if you do e.g. > > typedef float alias_SFtype __attribute__ ((mode (SF))); > > and similar, you could use alias_SFtype in the above. And so keep the > changes to the Darwin-specific parts of the libgcc-local sfp-machine.h. this is what I’m testing - OK if it bootstraps on x86_64-darwin, linux? thanks Iain [PATCH] libgcc, soft-float: Fix strong_alias macro use for Darwin. Darwin does not support strong symbol aliases and a work- around is provided in sfp-machine.h where a second function is created that simply calls the original. However this needs the arguments to the synthesized function to track the mode of the original function. So the fix here is to match known floating point modes from the incoming function and apply the one found to the new function args. The matching is highly specific to the current set of modes and will need adjusting should more cases be added. Signed-off-by: Iain Sandoe <i...@sandoe.co.uk> libgcc/ChangeLog: * config/i386/sfp-machine.h (alias_HFtype, alias_SFtype alias_DFtype, alias_TFtype): New. (ALIAS_SELECTOR): New. (strong_alias): Use __typeof and a _Generic selector to provide the type to the synthesized function. --- libgcc/config/i386/sfp-machine.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/libgcc/config/i386/sfp-machine.h b/libgcc/config/i386/sfp-machine.h index f15d29d3755..172ebc70c8d 100644 --- a/libgcc/config/i386/sfp-machine.h +++ b/libgcc/config/i386/sfp-machine.h @@ -75,10 +75,24 @@ void __sfp_handle_exceptions (int); /* Define ALIASNAME as a strong alias for NAME. */ #if defined __MACH__ -/* Mach-O doesn't support aliasing. If these functions ever return - anything but CMPtype we need to revisit this... */ +/* Mach-O doesn't support aliasing, so we build a secondary function for + the alias - we need to do a bit of a dance to find out what the type of + the arguments is and then apply that to the secondary function. + If these functions ever return anything but CMPtype we need to revisit + this... */ +typedef float alias_HFtype __attribute__ ((mode (HF))); +typedef float alias_SFtype __attribute__ ((mode (SF))); +typedef float alias_DFtype __attribute__ ((mode (DF))); +typedef float alias_TFtype __attribute__ ((mode (TF))); +#define ALIAS_SELECTOR \ + CMPtype (*) (alias_HFtype, alias_HFtype): (alias_HFtype) 0, \ + CMPtype (*) (alias_SFtype, alias_SFtype): (alias_SFtype) 0, \ + CMPtype (*) (alias_DFtype, alias_DFtype): (alias_DFtype) 0, \ + CMPtype (*) (alias_TFtype, alias_TFtype): (alias_TFtype) 0 #define strong_alias(name, aliasname) \ - CMPtype aliasname (TFtype a, TFtype b) { return name(a, b); } + CMPtype aliasname (__typeof (_Generic (name, ALIAS_SELECTOR)) a, \ + __typeof (_Generic (name, ALIAS_SELECTOR)) b) \ + { return name (a, b); } #else # define strong_alias(name, aliasname) _strong_alias(name, aliasname) # define _strong_alias(name, aliasname) \ --