public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* gfortran and -mlong-double-128
@ 2006-02-16 11:09 François-Xavier Coudert
  2006-02-16 12:50 ` Richard Guenther
  2006-02-16 15:04 ` Paul Brook
  0 siblings, 2 replies; 12+ messages in thread
From: François-Xavier Coudert @ 2006-02-16 11:09 UTC (permalink / raw)
  To: gfortran, GCC Development

Hi all,

I'm sending this mail because I'm a bit confused about the
-mlong-double-128 option on (for example) ppc64-linux, and its impact
on gfortran/libgfortran.

When I simply bootstrap a compiler with "configure
--with-cpu=default32", I get a gfortran that does only have kind=4 and
kind=8 reals (corresponding to C types float and double) by default.
When I use this gfortran with the -mlong-double-128 option, the
real(kind=16) floating point type is accepted at compile-time, but the
I/O library in libgfortran doesn't know how to deal with it (since,
when libgfortran was compiled, it did not detect that real(kind=16)
was available), and the code fails at runtime.

What should we do about that? I see a few options:
  1. refuse -mlong-double-128 for Fortran code; easiest, but not
exactly satisfying
  2. build multiple instances of the library, as is currently done for
the -m32/-m64 options
  3. build only one instance of the library, but build it with
-mlong-double-128 enabled, since as far as libgfortran is concerned,
it only adds a new floating-point type.

I may be confused about how all this is supposed to be handled, so any
pointer to further reading is welcome, as well as opinion on the
problem and options above.

Thanks,
FX

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

* Re: gfortran and -mlong-double-128
  2006-02-16 11:09 gfortran and -mlong-double-128 François-Xavier Coudert
@ 2006-02-16 12:50 ` Richard Guenther
  2006-02-16 12:57   ` François-Xavier Coudert
  2006-02-16 15:04 ` Paul Brook
  1 sibling, 1 reply; 12+ messages in thread
From: Richard Guenther @ 2006-02-16 12:50 UTC (permalink / raw)
  To: François-Xavier Coudert; +Cc: gfortran, GCC Development

On 2/16/06, François-Xavier Coudert <fxcoudert@gmail.com> wrote:
> Hi all,
>
> I'm sending this mail because I'm a bit confused about the
> -mlong-double-128 option on (for example) ppc64-linux, and its impact
> on gfortran/libgfortran.
>
> When I simply bootstrap a compiler with "configure
> --with-cpu=default32", I get a gfortran that does only have kind=4 and
> kind=8 reals (corresponding to C types float and double) by default.
> When I use this gfortran with the -mlong-double-128 option, the
> real(kind=16) floating point type is accepted at compile-time, but the
> I/O library in libgfortran doesn't know how to deal with it (since,
> when libgfortran was compiled, it did not detect that real(kind=16)
> was available), and the code fails at runtime.
>
> What should we do about that? I see a few options:
>   1. refuse -mlong-double-128 for Fortran code; easiest, but not
> exactly satisfying
>   2. build multiple instances of the library, as is currently done for
> the -m32/-m64 options
>   3. build only one instance of the library, but build it with
> -mlong-double-128 enabled, since as far as libgfortran is concerned,
> it only adds a new floating-point type.

I guess libgfortran has configury to figure out if kind=16 is available?  If
so then libgfortran should be built with -mlong-double-128, as this
should only add extra symbols that do not conflict with kind=4 and kind=8
ones.  Am I correct that for gfortran there is no such thing as long double
== double for -mlong-double-64?  If so, then this is really the way to go.

Richard.

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

* Re: gfortran and -mlong-double-128
  2006-02-16 12:50 ` Richard Guenther
@ 2006-02-16 12:57   ` François-Xavier Coudert
  2006-02-16 14:11     ` Jakub Jelinek
  0 siblings, 1 reply; 12+ messages in thread
From: François-Xavier Coudert @ 2006-02-16 12:57 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gfortran, GCC Development

> I guess libgfortran has configury to figure out if kind=16 is available?

Yes.

> If so then libgfortran should be built with -mlong-double-128, as this
> should only add extra symbols that do not conflict with kind=4 and kind=8
> ones.

Hum, that has to be done early in the configury (before all
autodetection). Do you think it's better suited at the beginning of
libgfortran/configure.ac (a special test, to see if -mlong-double-128
is available, and if it is add it to CFLAGS), or should it be done in
an upper level (and here is the limit of my understanding of the build
mechanism)?

> Am I correct that for gfortran there is no such thing as long double
> == double for -mlong-double-64?

This is right. Fortran has a list of available floating-point modes,
and they are chosen by a unique numbering scheme (the number is called
a "kind").

FX

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

* Re: gfortran and -mlong-double-128
  2006-02-16 12:57   ` François-Xavier Coudert
@ 2006-02-16 14:11     ` Jakub Jelinek
  2006-02-16 15:17       ` Richard Guenther
  0 siblings, 1 reply; 12+ messages in thread
From: Jakub Jelinek @ 2006-02-16 14:11 UTC (permalink / raw)
  To: Francois-Xavier Coudert; +Cc: Richard Guenther, gfortran, GCC Development

On Thu, Feb 16, 2006 at 01:57:39PM +0100, Fran?ois-Xavier Coudert wrote:
> > I guess libgfortran has configury to figure out if kind=16 is available?
> 
> Yes.
> 
> > If so then libgfortran should be built with -mlong-double-128, as this
> > should only add extra symbols that do not conflict with kind=4 and kind=8
> > ones.
> 
> Hum, that has to be done early in the configury (before all
> autodetection). Do you think it's better suited at the beginning of
> libgfortran/configure.ac (a special test, to see if -mlong-double-128
> is available, and if it is add it to CFLAGS), or should it be done in
> an upper level (and here is the limit of my understanding of the build
> mechanism)?

That will not work.  It is not enough if GCC supports -mlong-double-128
switch, you also need runtime library support for that.
So the check needs to be something like
http://gcc.gnu.org/ml/gcc-patches/2006-02/msg01075.html
(still not reviewed :( ).  If you configure gcc with --with-long-double-128
(what I'm using e.g. on redhat/gcc-4_1-branch now for
{ppc*,s390*,sparc,alpha}-*-linux*), then libgfortran is automatically built
with -mlong-double-128 and can cope with both -mlong-double-128 and
-mlong-double-64 code.  libstdc++.so will only support both
-mlong-double-{64,128} if it is built with -mlong-double-128, so it is in
the same boat as libgfortran.
Not sure if it makes any sense to detect the presence of glibc 2.4+ and
build libstdc++-v3/libgfortran with -mlong-double-128 even if configured
with --without-long-double-128.

	Jakub

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

* Re: gfortran and -mlong-double-128
  2006-02-16 11:09 gfortran and -mlong-double-128 François-Xavier Coudert
  2006-02-16 12:50 ` Richard Guenther
@ 2006-02-16 15:04 ` Paul Brook
  2006-02-16 15:14   ` François-Xavier Coudert
  2006-02-16 15:19   ` Richard Guenther
  1 sibling, 2 replies; 12+ messages in thread
From: Paul Brook @ 2006-02-16 15:04 UTC (permalink / raw)
  To: gcc; +Cc: François-Xavier Coudert, gfortran

On Thursday 16 February 2006 11:09, François-Xavier Coudert wrote:
> Hi all,
>
> I'm sending this mail because I'm a bit confused about the
> -mlong-double-128 option on (for example) ppc64-linux, and its impact
> on gfortran/libgfortran.
>
> When I simply bootstrap a compiler with "configure
> --with-cpu=default32", I get a gfortran that does only have kind=4 and
> kind=8 reals (corresponding to C types float and double) by default.
> When I use this gfortran with the -mlong-double-128 option, the
> real(kind=16) floating point type is accepted at compile-time, but the
> I/O library in libgfortran doesn't know how to deal with it (since,
> when libgfortran was compiled, it did not detect that real(kind=16)
> was available), and the code fails at runtime.
>
> What should we do about that? I see a few options:
>   1. refuse -mlong-double-128 for Fortran code; easiest, but not
> exactly satisfying
>   2. build multiple instances of the library, as is currently done for
> the -m32/-m64 options
>   3. build only one instance of the library, but build it with
> -mlong-double-128 enabled, since as far as libgfortran is concerned,
> it only adds a new floating-point type.

IMHO libgfortran shouldn't have to know or care about this option at all.
If you want a long-double-128 toolchain, then toplevel configure should be 
passing that option when configuring target libraries.

Having gfortran magically know about certain ABI breaking options, and doing 
funny things on certain targets seems a very bad precedent to me.

Paul

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

* Re: gfortran and -mlong-double-128
  2006-02-16 15:04 ` Paul Brook
@ 2006-02-16 15:14   ` François-Xavier Coudert
  2006-02-16 15:17     ` Paul Brook
  2006-02-16 15:19   ` Richard Guenther
  1 sibling, 1 reply; 12+ messages in thread
From: François-Xavier Coudert @ 2006-02-16 15:14 UTC (permalink / raw)
  To: Paul Brook; +Cc: gcc, gfortran

> Having gfortran magically know about certain ABI breaking options, and doing
> funny things on certain targets seems a very bad precedent to me.

Then, I think we should have the front-end refuse the option. It's
annoying to have a compiler accept code, and only tell you at runtime
(at the end of your simulation!) that it can't work.

FX

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

* Re: gfortran and -mlong-double-128
  2006-02-16 15:14   ` François-Xavier Coudert
@ 2006-02-16 15:17     ` Paul Brook
  0 siblings, 0 replies; 12+ messages in thread
From: Paul Brook @ 2006-02-16 15:17 UTC (permalink / raw)
  To: François-Xavier Coudert; +Cc: gcc, gfortran

On Thursday 16 February 2006 15:14, François-Xavier Coudert wrote:
> > Having gfortran magically know about certain ABI breaking options, and
> > doing funny things on certain targets seems a very bad precedent to me.
>
> Then, I think we should have the front-end refuse the option. It's
> annoying to have a compiler accept code, and only tell you at runtime
> (at the end of your simulation!) that it can't work.

The only thing that can do that is the driver (probably via spec strings). The 
compiler itself doesn't know what multilibs you have available.

Paul

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

* Re: gfortran and -mlong-double-128
  2006-02-16 14:11     ` Jakub Jelinek
@ 2006-02-16 15:17       ` Richard Guenther
  0 siblings, 0 replies; 12+ messages in thread
From: Richard Guenther @ 2006-02-16 15:17 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Francois-Xavier Coudert, gfortran, GCC Development

On 2/16/06, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Feb 16, 2006 at 01:57:39PM +0100, Fran?ois-Xavier Coudert wrote:
> > > I guess libgfortran has configury to figure out if kind=16 is available?
> >
> > Yes.
> >
> > > If so then libgfortran should be built with -mlong-double-128, as this
> > > should only add extra symbols that do not conflict with kind=4 and kind=8
> > > ones.
> >
> > Hum, that has to be done early in the configury (before all
> > autodetection). Do you think it's better suited at the beginning of
> > libgfortran/configure.ac (a special test, to see if -mlong-double-128
> > is available, and if it is add it to CFLAGS), or should it be done in
> > an upper level (and here is the limit of my understanding of the build
> > mechanism)?
>
> That will not work.  It is not enough if GCC supports -mlong-double-128
> switch, you also need runtime library support for that.
> So the check needs to be something like
> http://gcc.gnu.org/ml/gcc-patches/2006-02/msg01075.html
> (still not reviewed :( ).  If you configure gcc with --with-long-double-128
> (what I'm using e.g. on redhat/gcc-4_1-branch now for
> {ppc*,s390*,sparc,alpha}-*-linux*), then libgfortran is automatically built
> with -mlong-double-128 and can cope with both -mlong-double-128 and
> -mlong-double-64 code.  libstdc++.so will only support both
> -mlong-double-{64,128} if it is built with -mlong-double-128, so it is in
> the same boat as libgfortran.
> Not sure if it makes any sense to detect the presence of glibc 2.4+ and
> build libstdc++-v3/libgfortran with -mlong-double-128 even if configured
> with --without-long-double-128.

Well, fortran is special here compared to libstdc++-v3, because we do not
change its ABI by -mlong-double-128 but only add kind=16 intrinsics support.
So it makes sense to build libgfortran with support for kind=16 if glibc support
is there, regardless of the default setting for long-double.

Richard.

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

* Re: gfortran and -mlong-double-128
  2006-02-16 15:04 ` Paul Brook
  2006-02-16 15:14   ` François-Xavier Coudert
@ 2006-02-16 15:19   ` Richard Guenther
  2006-02-16 15:24     ` Andrew Pinski
  2006-02-16 15:28     ` Paul Brook
  1 sibling, 2 replies; 12+ messages in thread
From: Richard Guenther @ 2006-02-16 15:19 UTC (permalink / raw)
  To: Paul Brook; +Cc: gcc, François-Xavier Coudert, gfortran

On 2/16/06, Paul Brook <paul@codesourcery.com> wrote:
> On Thursday 16 February 2006 11:09, François-Xavier Coudert wrote:
> > Hi all,
> >
> > I'm sending this mail because I'm a bit confused about the
> > -mlong-double-128 option on (for example) ppc64-linux, and its impact
> > on gfortran/libgfortran.
> Having gfortran magically know about certain ABI breaking options, and doing
> funny things on certain targets seems a very bad precedent to me.

The point is that from a gfortran perspective -mlong-double-128 doesn't change
the ABI, it merely adds to it (which is sort of a change, but less invasive than
changing long double from 8bytes to 16bytes).  So we can easily cope with the
user request for -mlong-double-128 by always providing the kind=16 intrinsics.

Richard.

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

* Re: gfortran and -mlong-double-128
  2006-02-16 15:19   ` Richard Guenther
@ 2006-02-16 15:24     ` Andrew Pinski
  2006-02-16 15:28     ` Paul Brook
  1 sibling, 0 replies; 12+ messages in thread
From: Andrew Pinski @ 2006-02-16 15:24 UTC (permalink / raw)
  To: Richard Guenther; +Cc: Paul Brook, gcc, François-Xavier Coudert, gfortran

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=US-ASCII, Size: 1209 bytes --]

> 
> On 2/16/06, Paul Brook <paul@codesourcery.com> wrote:
> > On Thursday 16 February 2006 11:09, François-Xavier Coudert wrote:
> > > Hi all,
> > >
> > > I'm sending this mail because I'm a bit confused about the
> > > -mlong-double-128 option on (for example) ppc64-linux, and its impact
> > > on gfortran/libgfortran.
> > Having gfortran magically know about certain ABI breaking options, and doing
> > funny things on certain targets seems a very bad precedent to me.
> 
> The point is that from a gfortran perspective -mlong-double-128 doesn't change
> the ABI, it merely adds to it (which is sort of a change, but less invasive than
> changing long double from 8bytes to 16bytes).  So we can easily cope with the
> user request for -mlong-double-128 by always providing the kind=16 intrinsics.

So what, who cares.  This option does change other parts of the ABI that you might
not know well.  The 16bytes version in libgfortran will be calling the wrong function
and not working anyways.

But this is not really the issue here anyways.  The orginal problem was a failural
with targets that default to having 128bits floats like powerpc-darwin and sparc-solaris
and a couple other targets.

-- Pinski

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

* Re: gfortran and -mlong-double-128
  2006-02-16 15:19   ` Richard Guenther
  2006-02-16 15:24     ` Andrew Pinski
@ 2006-02-16 15:28     ` Paul Brook
  2006-02-16 15:48       ` Jakub Jelinek
  1 sibling, 1 reply; 12+ messages in thread
From: Paul Brook @ 2006-02-16 15:28 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc, François-Xavier Coudert, gfortran

On Thursday 16 February 2006 15:18, Richard Guenther wrote:
> On 2/16/06, Paul Brook <paul@codesourcery.com> wrote:
> > On Thursday 16 February 2006 11:09, François-Xavier Coudert wrote:
> > > Hi all,
> > >
> > > I'm sending this mail because I'm a bit confused about the
> > > -mlong-double-128 option on (for example) ppc64-linux, and its impact
> > > on gfortran/libgfortran.
> >
> > Having gfortran magically know about certain ABI breaking options, and
> > doing funny things on certain targets seems a very bad precedent to me.
>
> The point is that from a gfortran perspective -mlong-double-128 doesn't
> change the ABI, it merely adds to it (which is sort of a change, but less
> invasive than changing long double from 8bytes to 16bytes).  So we can
> easily cope with the user request for -mlong-double-128 by always providing
> the kind=16 intrinsics.

Except it [potentially] also changes the ABI that libgfortran uses to talk to 
glibc. ie. a -mlong-double-128 libgfortran probably won't work with a 
-mlong-double-64 glibc.

Paul

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

* Re: gfortran and -mlong-double-128
  2006-02-16 15:28     ` Paul Brook
@ 2006-02-16 15:48       ` Jakub Jelinek
  0 siblings, 0 replies; 12+ messages in thread
From: Jakub Jelinek @ 2006-02-16 15:48 UTC (permalink / raw)
  To: Paul Brook; +Cc: Richard Guenther, gcc

On Thu, Feb 16, 2006 at 03:28:46PM +0000, Paul Brook wrote:
> > The point is that from a gfortran perspective -mlong-double-128 doesn't
> > change the ABI, it merely adds to it (which is sort of a change, but less
> > invasive than changing long double from 8bytes to 16bytes).  So we can
> > easily cope with the user request for -mlong-double-128 by always providing
> > the kind=16 intrinsics.
> 
> Except it [potentially] also changes the ABI that libgfortran uses to talk to 
> glibc. ie. a -mlong-double-128 libgfortran probably won't work with a 
> -mlong-double-64 glibc.

That is not a big deal.  On the platforms we talk about (ppc{32,64},
s390{,x}, sparc32, alpha) glibc 2.4 and forward has 128-bit long double
support, glibc 2.3.x and earlier doesn't, this isn't an optional glibc
configure decision, it is part of glibc 2.4+ ABI on those arches.
So, yes, you can't use -mlong-double-128 libgfortran against
-mlong-double-64 glibc (read as, glibc 2.3.x or earlier), but that would
mean you compiled/linked against glibc 2.4+ and are trying to run
against glibc 2.3.x or earlier.  That generally doesn't work for any
glibc versions, glibc is only backwards compatible, not forward compatible.
And you get a clear error when trying to load program's shared libraries
(or e.g. various package managers like rpm will not even allow you to
install that unless forced).

	Jakub

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

end of thread, other threads:[~2006-02-16 15:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-16 11:09 gfortran and -mlong-double-128 François-Xavier Coudert
2006-02-16 12:50 ` Richard Guenther
2006-02-16 12:57   ` François-Xavier Coudert
2006-02-16 14:11     ` Jakub Jelinek
2006-02-16 15:17       ` Richard Guenther
2006-02-16 15:04 ` Paul Brook
2006-02-16 15:14   ` François-Xavier Coudert
2006-02-16 15:17     ` Paul Brook
2006-02-16 15:19   ` Richard Guenther
2006-02-16 15:24     ` Andrew Pinski
2006-02-16 15:28     ` Paul Brook
2006-02-16 15:48       ` Jakub Jelinek

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 read-only IMAP folder(s) and NNTP newsgroup(s).