Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Build failure with MKPIC=no, PR port-powerpc/43042



christos%astron.com@localhost said:
> Matthias Drochner  <M.Drochner%fz-juelich.de@localhost> wrote:
> >This is likely due to the "USE_LIBM" hack -- see
> >lib/libc/compat/gen/Makefile.inc
> >I'd suggest to remove it and add a warn_reference to the
> >libc compat version. If we don't, we'll never be able to
> >clean up this compatibility mess.

Almost forgot about that, but now we got PR port-powerpc/43042.

> The hack should work as long as both the libm and libc .o files export
> the same symbols. Isn't that the case?

I think the problem is that the libm ldexp() depends on other
libm functions (finite and scalbn) which get pulled into
the same .o within the .a. If "finite" or "scalbn" get pulled
in from libm due to other references we get the conflict later
when ldexp is pulled from libc.

This points to another problem: "finite" and "scalbn" need
to be namespace protected. With the USE_LIBM hack in place,
this would make the mess even worse.

Further, USE_LIBM doesn't hold the promise of unification
anyway, at least on x86: in libc, the C versions of "finite"
and "scalbn" are used while libm uses the i387 ones.

As said, I'd just give up on this and use the old libc versions
for binary compatibility.
For the warn_reference to work we would have to rename the
libm versions, otherwise we'd get false positives. I'm not
sure this is worth the effort, programs using this kind
of math functions most likely link against libm anyway.
These compat functions are left out if one builds a (mostly)
legacy-free libc with BUILDCOLD, and they shouldn't even
be pulled in for new ports (as ppc64) where it is not needed
for binary compatibility.

The appended patch does this, and it renames scalbn/scalbnf,
as a starter. finite() needs some more work due to md asm code.
(I've been using that renamed version for many months, but only
on i386. The 68881 case still needs testing.)

best regards
Matthias



------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
#
# old_revision [06e7c3b3041ac05ff6feb399f6cd54fcebe801ee]
#
# patch "lib/libc/compat/gen/Makefile.inc"
#  from [d6a6d87db58cbbd46a6f9fef67f5d1a5673b8af3]
#    to [ac5188ff11187eacb39e0fba997576001c116f13]
# 
# patch "lib/libc/compat/gen/compat_frexp_ieee754.c"
#  from [5f9d050dfd86bcae109c7fe69a53685a10363745]
#    to [8a756dbb524ace92e770b305588f14298d547a93]
# 
# patch "lib/libc/compat/gen/compat_ldexp_ieee754.c"
#  from [e5f7b3bd3385a0fbc5666caf2c0c55840eeba2ec]
#    to [a39903798e097ae6acb07c4706380f1bfcee1555]
# 
# patch "lib/libc/compat/gen/compat_modf_ieee754.c"
#  from [f45d4f4e8547bf87b359060b3a6c73fe0c03f6ce]
#    to [cceb587f8b878bb03e4ef2cc14d97f8483de95f5]
# 
# patch "lib/libm/Makefile"
#  from [b03c798fa9c3503616dacad15f6360f8d15e0899]
#    to [a06ffdfe241bd53da4fd2eae67f21168259c8db5]
# 
# patch "lib/libm/arch/i387/s_scalbn.S"
#  from [d3b32c1c0bb037e19c97576f52d2ce15c329ea2f]
#    to [18867d485b3bb8669f51bb526919a27af8326fd9]
# 
# patch "lib/libm/arch/i387/s_scalbnf.S"
#  from [3d1622cbbb0f88e7aebc66670fcaefce1f5065f5]
#    to [4bc1b965ae52a3c2a3df90ef3f44d6edd10e0b9b]
# 
# patch "lib/libm/arch/mc68881/s_scalbn.S"
#  from [ff256c241d062ceafdcaacd28c4828cb5c64c81b]
#    to [6c457574b4c5d4ec229288c96810726d5cd04fca]
# 
# patch "lib/libm/src/e_pow.c"
#  from [4c1971af070dd9c3b64b4483220ad2b2f6faf67c]
#    to [0fd5b41e0fd78a031d65d8957a6ca67d0a29ffa3]
# 
# patch "lib/libm/src/e_powf.c"
#  from [570caaef530bbee572c156d4857ee7bafcf95965]
#    to [0d7fc4c61868dc3ef5d37c0cd9d5d5168600bc0f]
# 
# patch "lib/libm/src/e_scalb.c"
#  from [519e6d5e19bde12b1d254074e8a9a5b646e93540]
#    to [f38406216d0cd9126462fc2d6ce77960805fcc39]
# 
# patch "lib/libm/src/e_scalbf.c"
#  from [93844f2d92e55c82690c4cf934c686f661d446ea]
#    to [ab4c82978285cb5a8030861baf4316794df58681]
# 
# patch "lib/libm/src/k_rem_pio2.c"
#  from [6ad838867433e881de8a4f5f30cf1ea662bb30cf]
#    to [7d8b4a6d949cade81ee156ae04bdd91d9e279e9b]
# 
# patch "lib/libm/src/k_rem_pio2f.c"
#  from [15efc8a60dc509ca12b2cba6b1cd8f5bdf2fd654]
#    to [82acec895a0188935d9c262cf5b32008da64454d]
# 
# patch "lib/libm/src/namespace.h"
#  from [6d920d281d600ef75eced41746b6c0f062c014e4]
#    to [2470243dc1437be1e6c214d6f4334002e46e75b1]
# 
# patch "lib/libm/src/s_ldexp.c"
#  from [f7b48cf4145c23a838c6af97f90da961c78dc58c]
#    to [1bba2b420d619cbd562d1c3997e0c26adc926f8f]
# 
# patch "lib/libm/src/s_ldexpf.c"
#  from [191e19463ffbceffd1c1e8a981e4ab17643dea78]
#    to [902a0850284a8f887a3d620e3b69767124233970]
# 
# patch "lib/libm/src/s_scalbn.c"
#  from [2a886893a21269289050a5e932df8bce43bf593e]
#    to [39b77964faa44a089848af50b0b7f5193927bca8]
# 
# patch "lib/libm/src/s_scalbnf.c"
#  from [b3bf6c8c54c55ef1ab85282053244246440eed42]
#    to [d1b0d0d9271c400a3ac01a6cd257f2ee0f38ebdf]
#
============================================================
--- lib/libc/compat/gen/Makefile.inc    d6a6d87db58cbbd46a6f9fef67f5d1a5673b8af3
+++ lib/libc/compat/gen/Makefile.inc    ac5188ff11187eacb39e0fba997576001c116f13
@@ -9,9 +9,3 @@ SRCS+=compat_errlist.c compat_fts.c comp
     compat__sys_errlist.c compat__sys_nerr.c compat__sys_siglist.c \
     compat_time.c compat_utime.c compat_devname.c compat_alphasort.c \
     compat_getpwent.c compat___fts32.c compat_utmp.c compat___fts50.c
-
-LIBMINC=-I${LIBCDIR}/../libm/src -DUSE_LIBM
-CPPFLAGS.compat_frexp_ieee754.c += ${LIBMINC}
-CPPFLAGS.compat_ldexp_ieee754.c += ${LIBMINC}
-CPPFLAGS.compat_modf_ieee754.c += ${LIBMINC}
-
============================================================
--- lib/libc/compat/gen/compat_frexp_ieee754.c  
5f9d050dfd86bcae109c7fe69a53685a10363745
+++ lib/libc/compat/gen/compat_frexp_ieee754.c  
8a756dbb524ace92e770b305588f14298d547a93
@@ -35,9 +35,6 @@
  * from: Header: frexp.c,v 1.1 91/07/07 04:45:01 torek Exp
  */
 
-#ifdef USE_LIBM
-#include "s_frexp.c"
-#else
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
 #if 0
@@ -49,8 +46,9 @@ __RCSID("$NetBSD: compat_frexp_ieee754.c
 
 #include <sys/types.h>
 #include <machine/ieee.h>
-#include <math.h>
 
+double frexp(double, int *);
+
 /*
  * Split the given value into a fraction in the range [0.5, 1.0) and
  * an exponent, such that frac * (2^exp) == value.  If value is 0,
@@ -83,4 +81,3 @@ frexp(double value, int *eptr)
                return (value);
        }
 }
-#endif
============================================================
--- lib/libc/compat/gen/compat_ldexp_ieee754.c  
e5f7b3bd3385a0fbc5666caf2c0c55840eeba2ec
+++ lib/libc/compat/gen/compat_ldexp_ieee754.c  
a39903798e097ae6acb07c4706380f1bfcee1555
@@ -29,11 +29,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifdef USE_LIBM
-#include "s_finite.c"
-#include "s_scalbn.c"
-#include "s_ldexp.c"
-#else
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
 __RCSID("$NetBSD: compat_ldexp_ieee754.c,v 1.4 2008/09/28 18:54:30 christos 
Exp $");
@@ -42,8 +37,9 @@ __RCSID("$NetBSD: compat_ldexp_ieee754.c
 #include <sys/types.h>
 #include <machine/ieee.h>
 #include <errno.h>
-#include <math.h>
 
+double ldexp(double, int);
+
 /*
  * Multiply the given value by 2^expon.
  */
@@ -145,4 +141,3 @@ ldexp(double val, int expon)
                return (u.dblu_d);
        }
 }
-#endif
============================================================
--- lib/libc/compat/gen/compat_modf_ieee754.c   
f45d4f4e8547bf87b359060b3a6c73fe0c03f6ce
+++ lib/libc/compat/gen/compat_modf_ieee754.c   
cceb587f8b878bb03e4ef2cc14d97f8483de95f5
@@ -27,14 +27,12 @@
  * rights to redistribute these changes.
  */
 
-#ifdef USE_LIBM
-#include "s_modf.c"
-#else
 #include <sys/types.h>
 #include <machine/ieee.h>
 #include <errno.h>
-#include <math.h>
 
+double modf(double, double *);
+
 /*
  * double modf(double val, double *iptr)
  * returns: f and i such that |f| < 1.0, (f + i) = val, and
@@ -103,4 +101,3 @@ modf(double val, double *iptr)
        u.dblu_dbl.dbl_sign = v.dblu_dbl.dbl_sign;
        return (u.dblu_d);
 }
-#endif
============================================================
--- lib/libm/Makefile   b03c798fa9c3503616dacad15f6360f8d15e0899
+++ lib/libm/Makefile   a06ffdfe241bd53da4fd2eae67f21168259c8db5
@@ -137,12 +137,9 @@ COMMON_SRCS = e_acos.c e_acosf.c e_acosh
        w_pow.c w_powf.c w_remainder.c w_remainderf.c w_scalb.c w_scalbf.c \
        w_sinh.c w_sinhf.c w_sqrt.c w_sqrtf.c \
        lrint.c lrintf.c llrint.c llrintf.c lround.c lroundf.c llround.c \
-       llroundf.c \
+       llroundf.c s_frexp.c s_ldexp.c s_modf.c \
        s_fmax.c s_fmaxf.c s_fmaxl.c s_fmin.c s_fminf.c s_fminl.c s_fdim.c
 
-# Also in libc.
-#COMMON_SRCS += s_frexp.c s_ldexp.c s_modf.c
-
 .PATH: ${.CURDIR}/compat
 COMMON_SRCS+= compat_cabs.c compat_cabsf.c
 # XXX our compatibility cabs() is different!
============================================================
--- lib/libm/arch/i387/s_scalbn.S       d3b32c1c0bb037e19c97576f52d2ce15c329ea2f
+++ lib/libm/arch/i387/s_scalbn.S       18867d485b3bb8669f51bb526919a27af8326fd9
@@ -7,7 +7,9 @@ RCSID("$NetBSD: s_scalbn.S,v 1.8 2006/03
 
 RCSID("$NetBSD: s_scalbn.S,v 1.8 2006/03/21 11:35:21 drochner Exp $")
 
-ENTRY(scalbn)
+WEAK_ALIAS(scalbn,_scalbn)
+
+ENTRY(_scalbn)
 #ifdef __x86_64__
        movl %edi,-12(%rsp)
        fildl -12(%rsp)
============================================================
--- lib/libm/arch/i387/s_scalbnf.S      3d1622cbbb0f88e7aebc66670fcaefce1f5065f5
+++ lib/libm/arch/i387/s_scalbnf.S      4bc1b965ae52a3c2a3df90ef3f44d6edd10e0b9b
@@ -7,7 +7,9 @@ RCSID("$NetBSD: s_scalbnf.S,v 1.7 2006/0
 
 RCSID("$NetBSD: s_scalbnf.S,v 1.7 2006/03/21 11:35:21 drochner Exp $")
 
-ENTRY(scalbnf)
+WEAK_ALIAS(scalbnf,_scalbnf)
+
+ENTRY(_scalbnf)
 #ifdef __x86_64__
        movl %edi,-8(%rsp)
        fildl -8(%rsp)
============================================================
--- lib/libm/arch/mc68881/s_scalbn.S    ff256c241d062ceafdcaacd28c4828cb5c64c81b
+++ lib/libm/arch/mc68881/s_scalbn.S    6c457574b4c5d4ec229288c96810726d5cd04fca
@@ -40,9 +40,11 @@ RCSID("$NetBSD: s_scalbn.S,v 1.7 2003/08
 
 RCSID("$NetBSD: s_scalbn.S,v 1.7 2003/08/07 16:44:43 agc Exp $")
 
+WEAK_ALIAS(scalbn,_scalbn)
+
 | scalbn(x, N)
 | returns  x * (2**N), for integer values N.
-ENTRY(scalbn)
+ENTRY(_scalbn)
        fmoved  %sp@(4),%fp0
        fscalel %sp@(12),%fp0
 #ifndef __SVR4_ABI__
============================================================
--- lib/libm/src/e_pow.c        4c1971af070dd9c3b64b4483220ad2b2f6faf67c
+++ lib/libm/src/e_pow.c        0fd5b41e0fd78a031d65d8957a6ca67d0a29ffa3
@@ -60,6 +60,7 @@ __RCSID("$NetBSD: e_pow.c,v 1.15 2009/01
  * to produce the hexadecimal values shown.
  */
 
+#include "namespace.h"
 #include "math.h"
 #include "math_private.h"
 
============================================================
--- lib/libm/src/e_powf.c       570caaef530bbee572c156d4857ee7bafcf95965
+++ lib/libm/src/e_powf.c       0d7fc4c61868dc3ef5d37c0cd9d5d5168600bc0f
@@ -18,6 +18,7 @@ __RCSID("$NetBSD: e_powf.c,v 1.14 2009/0
 __RCSID("$NetBSD: e_powf.c,v 1.14 2009/01/19 05:59:06 lukem Exp $");
 #endif
 
+#include "namespace.h"
 #include "math.h"
 #include "math_private.h"
 
============================================================
--- lib/libm/src/e_scalb.c      519e6d5e19bde12b1d254074e8a9a5b646e93540
+++ lib/libm/src/e_scalb.c      f38406216d0cd9126462fc2d6ce77960805fcc39
@@ -21,6 +21,7 @@ __RCSID("$NetBSD: e_scalb.c,v 1.9 2002/0
  * should use scalbn() instead.
  */
 
+#include "namespace.h"
 #include "math.h"
 #include "math_private.h"
 
============================================================
--- lib/libm/src/e_scalbf.c     93844f2d92e55c82690c4cf934c686f661d446ea
+++ lib/libm/src/e_scalbf.c     ab4c82978285cb5a8030861baf4316794df58681
@@ -18,6 +18,7 @@ __RCSID("$NetBSD: e_scalbf.c,v 1.6 2002/
 __RCSID("$NetBSD: e_scalbf.c,v 1.6 2002/05/26 22:01:52 wiz Exp $");
 #endif
 
+#include "namespace.h"
 #include "math.h"
 #include "math_private.h"
 
============================================================
--- lib/libm/src/k_rem_pio2.c   6ad838867433e881de8a4f5f30cf1ea662bb30cf
+++ lib/libm/src/k_rem_pio2.c   7d8b4a6d949cade81ee156ae04bdd91d9e279e9b
@@ -131,6 +131,7 @@ __RCSID("$NetBSD: k_rem_pio2.c,v 1.11 20
  * to produce the hexadecimal values shown.
  */
 
+#include "namespace.h"
 #include "math.h"
 #include "math_private.h"
 
============================================================
--- lib/libm/src/k_rem_pio2f.c  15efc8a60dc509ca12b2cba6b1cd8f5bdf2fd654
+++ lib/libm/src/k_rem_pio2f.c  82acec895a0188935d9c262cf5b32008da64454d
@@ -18,6 +18,7 @@ __RCSID("$NetBSD: k_rem_pio2f.c,v 1.7 20
 __RCSID("$NetBSD: k_rem_pio2f.c,v 1.7 2002/05/26 22:01:53 wiz Exp $");
 #endif
 
+#include "namespace.h"
 #include "math.h"
 #include "math_private.h"
 
============================================================
--- lib/libm/src/namespace.h    6d920d281d600ef75eced41746b6c0f062c014e4
+++ lib/libm/src/namespace.h    2470243dc1437be1e6c214d6f4334002e46e75b1
@@ -15,6 +15,8 @@
 #define sinf _sinf
 #define cos _cos
 #define cosf _cosf
+#define finite _finite
+#define finitef _finitef
 #endif /* notyet */
 #define sinh _sinh
 #define sinhf _sinhf
@@ -27,3 +29,6 @@
 #define casinf _casinf
 #define catan _catan
 #define catanf _catanf
+
+#define scalbn _scalbn
+#define scalbnf _scalbnf
============================================================
--- lib/libm/src/s_ldexp.c      f7b48cf4145c23a838c6af97f90da961c78dc58c
+++ lib/libm/src/s_ldexp.c      1bba2b420d619cbd562d1c3997e0c26adc926f8f
@@ -15,6 +15,7 @@ __RCSID("$NetBSD: s_ldexp.c,v 1.10 2008/
 __RCSID("$NetBSD: s_ldexp.c,v 1.10 2008/04/25 22:21:53 christos Exp $");
 #endif
 
+#include "namespace.h"
 #include "math.h"
 #include "math_private.h"
 #include <errno.h>
============================================================
--- lib/libm/src/s_ldexpf.c     191e19463ffbceffd1c1e8a981e4ab17643dea78
+++ lib/libm/src/s_ldexpf.c     902a0850284a8f887a3d620e3b69767124233970
@@ -18,6 +18,7 @@ __RCSID("$NetBSD: s_ldexpf.c,v 1.7 2008/
 __RCSID("$NetBSD: s_ldexpf.c,v 1.7 2008/04/25 22:21:53 christos Exp $");
 #endif
 
+#include "namespace.h"
 #include "math.h"
 #include "math_private.h"
 #include <errno.h>
============================================================
--- lib/libm/src/s_scalbn.c     2a886893a21269289050a5e932df8bce43bf593e
+++ lib/libm/src/s_scalbn.c     39b77964faa44a089848af50b0b7f5193927bca8
@@ -22,9 +22,14 @@ __RCSID("$NetBSD: s_scalbn.c,v 1.13 2008
  * exponentiation or a multiplication.
  */
 
+#include "namespace.h"
 #include "math.h"
 #include "math_private.h"
 
+#ifdef __weak_alias
+__weak_alias(scalbn, _scalbn)
+#endif
+
 static const double
 two54   =  1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
 twom54  =  5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */
============================================================
--- lib/libm/src/s_scalbnf.c    b3bf6c8c54c55ef1ab85282053244246440eed42
+++ lib/libm/src/s_scalbnf.c    d1b0d0d9271c400a3ac01a6cd257f2ee0f38ebdf
@@ -18,9 +18,14 @@ __RCSID("$NetBSD: s_scalbnf.c,v 1.8 2002
 __RCSID("$NetBSD: s_scalbnf.c,v 1.8 2002/05/26 22:01:58 wiz Exp $");
 #endif
 
+#include "namespace.h"
 #include "math.h"
 #include "math_private.h"
 
+#ifdef __weak_alias
+__weak_alias(scalbnf, _scalbnf)
+#endif
+
 static const float
 two25   =  3.355443200e+07,    /* 0x4c000000 */
 twom25  =  2.9802322388e-08,   /* 0x33000000 */


Home | Main Index | Thread Index | Old Index