mailing list of musl libc
 help / color / mirror / code / Atom feed
* Feasability of patching libm with OS X 10.5.8 libc for IBM double-double in PPC
@ 2017-12-06 17:23 ardi
  2017-12-06 17:33 ` Rich Felker
  2017-12-06 17:53 ` Szabolcs Nagy
  0 siblings, 2 replies; 4+ messages in thread
From: ardi @ 2017-12-06 17:23 UTC (permalink / raw)
  To: musl

Hi!!

Disclaimer: I've read previous threads about long double support in
musl, as well as web pages and I understand that musl won't support
the IBM double-double, by design choice. I respect that decision (I've
just started to use musl and I can only say I admire the quality and
the design), and I'm not writing this as my opinion about that
decision.

Said this, I need IBM double-double in PowerPC targets (using clang as
compiler), and I'd like to use musl because of its well written code.

I'd also have the option of using the libc from OS X 10.5.8, which,
AFAIK, is the latest libc from Apple with full support for PPC and
PPC64 before they dropped them. This is libc 498.1.7 from the Apple
open source site.

However, building Darwin components was never easy (build instructions
are most of the times missing, ask the PureDarwin people), so I
*believe* I can get this libc working, but who knows...

As a (perhaps) better solution, I thought that maybe I don't need to
patch too many musl source files in order to get double-double
working. If I'm understanding the situation correctly, the
double-double implementation is actually generated by clang at compile
code. The libc library should only need to provide the interface
definitions (the definitions for mantissa bits, exponent bits, max
values, etc...), and perhaps the implementation of some functions
whose code wouldn't be generated by the compiler (not sure of this, as
clang generates code for a set of functions through builtins in
compiler_rt).

Maybe there would be some issues with converting floating point to
char string, but it would depend on what code you'd use for that
conversion.

So, as a personal patch (not pushing for official support, as I said
above), do you consider it would be feasible to patch the necessary
musl source files with contents from the OS X 10.5.8 libc?

Do you believe it would be a matter of a reasonably small set of
files, or rather an overwhelming task?

And... do you know of any confidence test I could run for checking
that it's working as expected?

Thanks a lot!


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Feasability of patching libm with OS X 10.5.8 libc for IBM double-double in PPC
  2017-12-06 17:23 Feasability of patching libm with OS X 10.5.8 libc for IBM double-double in PPC ardi
@ 2017-12-06 17:33 ` Rich Felker
  2017-12-06 17:53 ` Szabolcs Nagy
  1 sibling, 0 replies; 4+ messages in thread
From: Rich Felker @ 2017-12-06 17:33 UTC (permalink / raw)
  To: musl

On Wed, Dec 06, 2017 at 06:23:33PM +0100, ardi wrote:
> Hi!!
> 
> Disclaimer: I've read previous threads about long double support in
> musl, as well as web pages and I understand that musl won't support
> the IBM double-double, by design choice. I respect that decision (I've
> just started to use musl and I can only say I admire the quality and
> the design), and I'm not writing this as my opinion about that
> decision.
> 
> Said this, I need IBM double-double in PowerPC targets (using clang as
> compiler), and I'd like to use musl because of its well written code.
> 
> I'd also have the option of using the libc from OS X 10.5.8, which,
> AFAIK, is the latest libc from Apple with full support for PPC and
> PPC64 before they dropped them. This is libc 498.1.7 from the Apple
> open source site.
> 
> However, building Darwin components was never easy (build instructions
> are most of the times missing, ask the PureDarwin people), so I
> *believe* I can get this libc working, but who knows...
> 
> As a (perhaps) better solution, I thought that maybe I don't need to
> patch too many musl source files in order to get double-double
> working. If I'm understanding the situation correctly, the
> double-double implementation is actually generated by clang at compile
> code. The libc library should only need to provide the interface
> definitions (the definitions for mantissa bits, exponent bits, max
> values, etc...), and perhaps the implementation of some functions
> whose code wouldn't be generated by the compiler (not sure of this, as
> clang generates code for a set of functions through builtins in
> compiler_rt).
> 
> Maybe there would be some issues with converting floating point to
> char string, but it would depend on what code you'd use for that
> conversion.

The musl code for printing and parsing floating point numbers depends
on long double having IEEE semantics. It's a complete toss-up whether
it will work with formats like double-double that don't give IEEE
semantics. Aside from guaranteeing reasonable semantics that you can
reason about to programs using musl, this internal dependency is a
major reason why musl does not support weird long double formats.

> So, as a personal patch (not pushing for official support, as I said
> above), do you consider it would be feasible to patch the necessary
> musl source files with contents from the OS X 10.5.8 libc?

I don't think this solves the main problem (the dependency above) at
all; at best it just gives you math.h long-double functions that work
on double-double.

You could obviously modify vfprintf.c and __floatscan.c to work with
double instead of long double, avoiding the double-double issue, but
then %Lf and strtold functionality would not work.

It's possible that you get "lucky" and they happen to work (or work
well enough for you) with double-double as-is, but I would be really
skeptical of relying on that in situations where it matters.

> Do you believe it would be a matter of a reasonably small set of
> files, or rather an overwhelming task?
> 
> And... do you know of any confidence test I could run for checking
> that it's working as expected?

The libc-test math tests and printf/scanf type tests might be
sufficient to get some confidence that you didn't break normal float
and double stuff, but I'm not sure; you'd probably need to review what
they cover. I'm not aware of any tests that would help for
double-double testing.

Rich


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Feasability of patching libm with OS X 10.5.8 libc for IBM double-double in PPC
  2017-12-06 17:23 Feasability of patching libm with OS X 10.5.8 libc for IBM double-double in PPC ardi
  2017-12-06 17:33 ` Rich Felker
@ 2017-12-06 17:53 ` Szabolcs Nagy
  2017-12-06 19:33   ` ardi
  1 sibling, 1 reply; 4+ messages in thread
From: Szabolcs Nagy @ 2017-12-06 17:53 UTC (permalink / raw)
  To: musl

* ardi <ardillasdelmonte@gmail.com> [2017-12-06 18:23:33 +0100]:
> Said this, I need IBM double-double in PowerPC targets (using clang as
> compiler), and I'd like to use musl because of its well written code.

is this because of some abi compat issue?
or some source code depends on double-double semantics?

in musl you can do various hacks to make most things work,
but complete support is non-trivial so if you can work
around the double-double requirement that may be better.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Feasability of patching libm with OS X 10.5.8 libc for IBM double-double in PPC
  2017-12-06 17:53 ` Szabolcs Nagy
@ 2017-12-06 19:33   ` ardi
  0 siblings, 0 replies; 4+ messages in thread
From: ardi @ 2017-12-06 19:33 UTC (permalink / raw)
  To: musl

On Wed, Dec 6, 2017 at 6:53 PM, Szabolcs Nagy <nsz@port70.net> wrote:
> * ardi <ardillasdelmonte@gmail.com> [2017-12-06 18:23:33 +0100]:
>> Said this, I need IBM double-double in PowerPC targets (using clang as
>> compiler), and I'd like to use musl because of its well written code.
>
> is this because of some abi compat issue?
> or some source code depends on double-double semantics?

It's because I have code that was very well tuned for double-double
precision. Of course I'd be happy to be able to work with an IEEE
128bit long double, and I'd use it from the first day if the LLVM
compiler team implements it with hardware optimizations for PPC64, but
I'd like to have the choice of using double-double if I need to check
or compare at some point.

From the comments by Rich, I think maybe it's not hard to get it
working. If I find I can get it by patching a few files (maybe
conditionally using the code for FP to/from string conversions in
Apple libc in my custom musl build), then I'll do it. OTOH, if it
requires a lot of editing, I won't doing it, because I want to have an
easy procedure for updating musl to newer versions. If I have to apply
a huge patchset whenever I update, it wouldn't be reasonable.

Thanks!


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-06 19:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-06 17:23 Feasability of patching libm with OS X 10.5.8 libc for IBM double-double in PPC ardi
2017-12-06 17:33 ` Rich Felker
2017-12-06 17:53 ` Szabolcs Nagy
2017-12-06 19:33   ` ardi

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).