Page MenuHomeFreeBSD

msun: add ld80/ld128 powl, cpow, cpowf, cpowl from openbsd
ClosedPublic

Authored by jmd on Jun 20 2018, 2:31 AM.

Details

Summary

This corresponds to the latest status (hasn't changed in 9+ years) from openbsd of ld80/ld128 powl, and source cpowf, cpow, cpowl (the complex power functions for float complex, double complex, and long double complex) which are required for C99 compliance and were missing from FreeBSD. Also required for some numerical codes using complex numbered Hamiltonians.

Test Plan

make universe completes for targets i386, amd64, arm64, risc (except sf), and powerpc . Solves link issue and works for a complex numbered tight binding Hamiltonian (compared to using opensolaris libm from ports) on amd64.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jmd retitled this revision from msun: add cpow, cpowf, cpowl from openbsd to [WIP] msun: add cpow, cpowf, cpowl from openbsd.Jun 20 2018, 4:41 AM

Correct file locations and alphabetic ordering.

jmd retitled this revision from [WIP] msun: add cpow, cpowf, cpowl from openbsd to msun: add cpow, cpowf, cpowl from openbsd.
jmd edited the test plan for this revision. (Show Details)

Add patch to complex.h that was missing.

jmd retitled this revision from msun: add cpow, cpowf, cpowl from openbsd to msun: add ld80/ld128 powl, cpow, cpowf, cpowl from openbsd.
jmd edited the summary of this revision. (Show Details)
jmd edited the test plan for this revision. (Show Details)

universe on riscv reveals that we generally didn't have a powl but instead re-used regular pow. Only gcc on risvc complains about this though. Hence, import powl for ld80 and ld128 from openbsd (and some helper routines) and restrict the workaround to mantissa 53 architectures (power). with this, universe passes on amd64, i386, riscv (except sf but that seems to be expected), arm64, and powerpc.

jhb added inline comments.
lib/msun/Symbol.map
279 ↗(On Diff #44278)

I would keep the comment as it appears to still be relevant for tgammal?

It's not clear if powl() is now always precise. If it is I would perhaps move it into sorted order above the comment.

lib/msun/src/imprecise.c
53 ↗(On Diff #44278)

I don't understand why we are keeping imprecise_powl() for platforms where double == long double? Shouldn't we instead remove powl from here entirely and add a conditional __weak_reference() from powl to pow in src/e_pow.c instead the same as is done at the bottom of src/e_log.c for logl aliased to log?

Thanks for the comments!

lib/msun/Symbol.map
279 ↗(On Diff #44278)

Thanks, good point, I'll move it up - in line with logl which also is mostly precise.

lib/msun/src/imprecise.c
53 ↗(On Diff #44278)

I indeed tried that at first and it wouldn't add the weak reference. I hence decided to do the minimally intrusive change and just ifdef it here for such platforms. I can try to sort out the weak reference again.

Sorted cpowl into the list and re-instantiated the tgammal comment.

Results for using weak_reference as opposed to imprecise.c

lib/msun/src/imprecise.c
53 ↗(On Diff #44278)

Again attempted that, it fails with

ld: error: can't create dynamic relocation R_PPC_LOCAL24PC against symbol: _GLOBAL_OFFSET_TABLE_ in readonly segment; recompile object files with -fPIC
>>> defined in <internal>
>>> referenced by crtstuff.c
>>>               /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o:(.text+0x8)

ld: error: can't create dynamic relocation R_PPC_GOT16 against symbol: .LANCHOR0 in readonly segment; recompile object files with -fPIC
>>> defined in /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o
>>> referenced by crtstuff.c
>>>               /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o:(.text+0x1E)

ld: error: can't create dynamic relocation R_PPC_GOT16 against symbol: __cxa_finalize in readonly segment; recompile object files with -fPIC
>>> defined in atexit.pico
>>> referenced by crtstuff.c
>>>               /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o:(.text+0x3A)

--- lib/libc_nonshared__L ---
--- lib/libc__L ---
ld: error: can't create dynamic relocation R_PPC_GOT16 against symbol: __dso_handle in readonly segment; recompile object files with -fPIC
>>> defined in /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o
>>> referenced by crtstuff.c
>>>               /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o:(.text+0x46)

ld: error: can't create dynamic relocation R_PPC_GOT16 against symbol: .LANCHOR1 in readonly segment; recompile object files with -fPIC
>>> defined in /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o
>>> referenced by crtstuff.c
>>>               /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o:(.text+0x52)

ld: error: can't create dynamic relocation R_PPC_LOCAL24PC against symbol: _GLOBAL_OFFSET_TABLE_ in readonly segment; recompile object files with -fPIC
>>> defined in <internal>
>>> referenced by crtstuff.c
>>>               /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o:(.text+0xE4)

ld: error: can't create dynamic relocation R_PPC_GOT16 against symbol: .LANCHOR2 in readonly segment; recompile object files with -fPIC
>>> defined in /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o
>>> referenced by crtstuff.c
>>>               /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o:(.text+0xFE)

ld: error: can't create dynamic relocation R_PPC_GOT16 against symbol: _Jv_RegisterClasses in readonly segment; recompile object files with -fPIC
>>> defined in /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o
>>> referenced by crtstuff.c
>>>               /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o:(.text+0x10E)

ld: error: can't create dynamic relocation R_PPC_LOCAL24PC against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o
>>> referenced by crtstuff.c
>>>               /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o:(.fini+0x0)

ld: error: can't create dynamic relocation R_PPC_LOCAL24PC against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o
>>> referenced by crtstuff.c
>>>               /usr/obj/usr/src/powerpc.powerpc/tmp/usr/lib/crtbeginS.o:(.init+0x0)

ld: error: can't create dynamic relocation R_PPC_LOCAL24PC against symbol: _GLOBAL_OFFSET_TABLE_ in readonly segment; recompile object files with -fPIC
>>> defined in <internal>
>>> referenced by wcsxfrm.c:46 (/usr/src/lib/libc/string/wcsxfrm.c:46)

on all powerpc targets when linking libc.

jmd edited subscribers, added: dim; removed: imp.Jul 5 2018, 2:20 AM
lib/msun/src/imprecise.c
53 ↗(On Diff #44278)

None of these errors are for libm, but for libc which is compiled earlier in world. Can you update the diff with the version that doesn't use imprecise.c?

Version using weak_reference instead of imprecise. Does not build world on power* platforms.

lib/msun/src/imprecise.c
53 ↗(On Diff #44278)

@jhb @dim I'd like to do this "right" with a weak reference. Nonetheless, I think it's ok to fix it in post to prevent this from being dragged out indefinitely.

lib/msun/src/e_pow.c
59 ↗(On Diff #45003)

Still waiting for a universe with my suggested fix to finish, but you need to add

#include <float.h>

here just as it is in e_log.c so that LDBL_MANT_DIG is defined. This added the missing 'powl' symbol to e_pow.o and e_pow.pico object files for me on the mips.mips build of libm.

This revision was not accepted when it landed; it landed in state Needs Review.Jul 15 2018, 12:23 AM
This revision was automatically updated to reflect the committed changes.