public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* [power-iee128] How to specify linker flags
       [not found]   ` <YYA2FMfDR0yehJLA@toto.the-meissners.org>
@ 2022-01-02 22:58     ` Thomas Koenig
  2022-01-03 10:19       ` Thomas Koenig
  2022-01-05 21:20       ` Michael Meissner
  0 siblings, 2 replies; 5+ messages in thread
From: Thomas Koenig @ 2022-01-02 22:58 UTC (permalink / raw)
  To: Michael Meissner, Bill Schmidt, fortran, Jakub Jelinek,
	Segher Boessenkool, Peter Bergner, David Edelsohn,
	gcc mailing list

Hi Michael,

> If you are building libraries that contain modules with multiple long double
> types, you must use the '-mno-gnu-attribute'.  We also use the '-Wno-psabi'
> option, which silences the warning that you are switching long double types (if
> glibc is not 2.34 or newer).  We may need to tweak -Wno-psabi for use with
> Fortran.

I am now at the point where the object files are also compiled correctly
for the gfortran specifics:

0000000000000000 <_gfortran_specific__abs_r17>:
    0:   09 00 43 f4     lxv     vs34,0(r3)
    4:   48 16 40 fc     xsabsqp v2,v2
    8:   20 00 80 4e     blr

However, the linker complains, as you said it would, about the different
formats:

/opt/at15.0/bin/ld: .libs/maxloc0_4_r16.o uses IBM long double, 
.libs/_abs_r17.o uses IEEE long double
/opt/at15.0/bin/ld: failed to merge target specific data of file 
.libs/_abs_r17.o

I know next to nothing about libtool, so I do not know how to
add the flags so the linker can find them.

Any pointers?

(I have not yet committed the changes because I do not want to
commit something that does not compile.  If anybody wants to
take a look, it's on the ieee128 virtual machine under
/home/tkoenig/ieee ).

Regards

	Thomas

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

* Re: [power-iee128] How to specify linker flags
  2022-01-02 22:58     ` [power-iee128] How to specify linker flags Thomas Koenig
@ 2022-01-03 10:19       ` Thomas Koenig
  2022-01-03 10:33         ` Jakub Jelinek
  2022-01-03 10:34         ` Segher Boessenkool
  2022-01-05 21:20       ` Michael Meissner
  1 sibling, 2 replies; 5+ messages in thread
From: Thomas Koenig @ 2022-01-03 10:19 UTC (permalink / raw)
  To: Michael Meissner, Bill Schmidt, fortran, Jakub Jelinek,
	Segher Boessenkool, Peter Bergner, David Edelsohn,
	gcc mailing list


On 02.01.22 23:58, Thomas Koenig wrote:
> Hi Michael,
> 
>> If you are building libraries that contain modules with multiple long 
>> double
>> types, you must use the '-mno-gnu-attribute'.  We also use the 
>> '-Wno-psabi'
>> option, which silences the warning that you are switching long double 
>> types (if
>> glibc is not 2.34 or newer).  We may need to tweak -Wno-psabi for use 
>> with
>> Fortran.
> 
> I am now at the point where the object files are also compiled correctly
> for the gfortran specifics:
> 
> 0000000000000000 <_gfortran_specific__abs_r17>:
>     0:   09 00 43 f4     lxv     vs34,0(r3)
>     4:   48 16 40 fc     xsabsqp v2,v2
>     8:   20 00 80 4e     blr
> 
> However, the linker complains, as you said it would, about the different
> formats:
> 
> /opt/at15.0/bin/ld: .libs/maxloc0_4_r16.o uses IBM long double, 
> .libs/_abs_r17.o uses IEEE long double
> /opt/at15.0/bin/ld: failed to merge target specific data of file 
> .libs/_abs_r17.o
> 
> I know next to nothing about libtool, so I do not know how to
> add the flags so the linker can find them.
> 
> Any pointers?

One additional point.  The linker does not understand
-mno-gnu-attribute:

$ /opt/at15.0/bin/ld -mno-gnu-attribute
/opt/at15.0/bin/ld: unrecognised emulation mode: no-gnu-attribute
Supported emulations: elf64lppc elf32lppc elf32lppclinux elf32lppcsim 
elf64ppc elf32ppc elf32ppclinux elf32ppcsim

So, waiting for info to proceed.

Best regards

	Thomas

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

* Re: [power-iee128] How to specify linker flags
  2022-01-03 10:19       ` Thomas Koenig
@ 2022-01-03 10:33         ` Jakub Jelinek
  2022-01-03 10:34         ` Segher Boessenkool
  1 sibling, 0 replies; 5+ messages in thread
From: Jakub Jelinek @ 2022-01-03 10:33 UTC (permalink / raw)
  To: Thomas Koenig
  Cc: Michael Meissner, Bill Schmidt, fortran, Segher Boessenkool,
	Peter Bergner, David Edelsohn, gcc mailing list

On Mon, Jan 03, 2022 at 11:19:21AM +0100, Thomas Koenig wrote:
> > > If you are building libraries that contain modules with multiple
> > > long double
> > > types, you must use the '-mno-gnu-attribute'.  We also use the
> > > '-Wno-psabi'
> > > option, which silences the warning that you are switching long
> > > double types (if
> > > glibc is not 2.34 or newer).  We may need to tweak -Wno-psabi for
> > > use with
> > > Fortran.
> > 
> > I am now at the point where the object files are also compiled correctly
> > for the gfortran specifics:
> > 
> > 0000000000000000 <_gfortran_specific__abs_r17>:
> >     0:   09 00 43 f4     lxv     vs34,0(r3)
> >     4:   48 16 40 fc     xsabsqp v2,v2
> >     8:   20 00 80 4e     blr
> > 
> > However, the linker complains, as you said it would, about the different
> > formats:
> > 
> > /opt/at15.0/bin/ld: .libs/maxloc0_4_r16.o uses IBM long double,
> > .libs/_abs_r17.o uses IEEE long double
> > /opt/at15.0/bin/ld: failed to merge target specific data of file
> > .libs/_abs_r17.o
> > 
> > I know next to nothing about libtool, so I do not know how to
> > add the flags so the linker can find them.
> > 
> > Any pointers?
> 
> One additional point.  The linker does not understand
> -mno-gnu-attribute:
> 
> $ /opt/at15.0/bin/ld -mno-gnu-attribute
> /opt/at15.0/bin/ld: unrecognised emulation mode: no-gnu-attribute
> Supported emulations: elf64lppc elf32lppc elf32lppclinux elf32lppcsim
> elf64ppc elf32ppc elf32ppclinux elf32ppcsim
> 
> So, waiting for info to proceed.

-mno-gnu-attribute isn't a linker flag, but a compiler flag.
And e.g. libstdc++ configure uses it while compiling itself on
powerpc*linux:
        LONG_DOUBLE_COMPAT_FLAGS="$LONG_DOUBLE_COMPAT_FLAGS -mno-gnu-attribute"
        # Check for IEEE128 support in libm:
        AC_CHECK_LIB(m, __frexpieee128,
                     [ac_ldbl_ieee128_in_libc=yes],
                     [ac_ldbl_ieee128_in_libc=no])
        if test $ac_ldbl_ieee128_in_libc = yes; then
          # Determine which long double format is the compiler's default:
          AC_TRY_COMPILE(, [
            #ifndef __LONG_DOUBLE_IEEE128__
            #error compiler defaults to ibm128
            #endif
          ], [ac_ldbl_ieee128_default=yes], [ac_ldbl_ieee128_default=no])
          # Library objects should use default long double format.
          if test "$ac_ldbl_ieee128_default" = yes; then
            LONG_DOUBLE_128_FLAGS="-mno-gnu-attribute"
            # Except for the ones that explicitly use these flags:
            LONG_DOUBLE_ALT128_COMPAT_FLAGS="-mabi=ibmlongdouble -mno-gnu-attribute -Wno-psabi"
          else
            LONG_DOUBLE_128_FLAGS="-mno-gnu-attribute"
            LONG_DOUBLE_ALT128_COMPAT_FLAGS="-mabi=ieeelongdouble -mno-gnu-attribute -Wno-psabi"
          fi
          AC_DEFINE([_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT],1,
                [Define if compatibility should be provided for alternative 128-bit long double formats.])
          port_specific_symbol_files="$port_specific_symbol_files \$(top_srcdir)/config/os/gnu-linux/ldbl-ieee128-extra.ver"
          ac_ldbl_alt128_compat=yes
        else
          ac_ldbl_alt128_compat=no
        fi
        ;;
The idea behind this is that libstdc++ is written such that it can handle
both IBM extended and IEEE quad long double, so its object files are
compatible with both.

So I think we want:
2022-01-03  Jakub Jelinek  <jakub@redhat.com>

	* configure.ac (Use -mno-gnu-attribute together with
	-mabi=ibmlongdouble or -mabi=ieeelongdouble.

--- libgfortran/configure.ac	2021-12-31 11:08:19.032835533 +0000
+++ libgfortran/configure.ac	2022-01-03 10:32:16.927834682 +0000
@@ -163,9 +163,9 @@ if test "x$GCC" = "xyes"; then
 			   #error long double is double
 			   #endif]],
                          [[(void) 0;]])],
-        [AM_FCFLAGS="$AM_FCFLAGS -mabi=ibmlongdouble";
-	 AM_CFLAGS="$AM_CFLAGS -mabi=ibmlongdouble";
-	 CFLAGS="$CFLAGS -mabi=ibmlongdouble";
+        [AM_FCFLAGS="$AM_FCFLAGS -mabi=ibmlongdouble -mno-gnu-attribute";
+	 AM_CFLAGS="$AM_CFLAGS -mabi=ibmlongdouble -mno-gnu-attribute";
+	 CFLAGS="$CFLAGS -mabi=ibmlongdouble -mno-gnu-attribute";
 	 have_real_17=yes])
       ;;
     *)


	Jakub


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

* Re: [power-iee128] How to specify linker flags
  2022-01-03 10:19       ` Thomas Koenig
  2022-01-03 10:33         ` Jakub Jelinek
@ 2022-01-03 10:34         ` Segher Boessenkool
  1 sibling, 0 replies; 5+ messages in thread
From: Segher Boessenkool @ 2022-01-03 10:34 UTC (permalink / raw)
  To: Thomas Koenig
  Cc: Michael Meissner, Bill Schmidt, fortran, Jakub Jelinek,
	Peter Bergner, David Edelsohn, gcc mailing list

Hi!

On Mon, Jan 03, 2022 at 11:19:21AM +0100, Thomas Koenig wrote:
> One additional point.  The linker does not understand
> -mno-gnu-attribute:

That is a GCC option, not an ld one.  If you use it to compile some
file there will be no .gnu.attributes section generated for that
translation unit.


Segher

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

* Re: [power-iee128] How to specify linker flags
  2022-01-02 22:58     ` [power-iee128] How to specify linker flags Thomas Koenig
  2022-01-03 10:19       ` Thomas Koenig
@ 2022-01-05 21:20       ` Michael Meissner
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Meissner @ 2022-01-05 21:20 UTC (permalink / raw)
  To: Thomas Koenig
  Cc: Michael Meissner, Bill Schmidt, fortran, Jakub Jelinek,
	Segher Boessenkool, Peter Bergner, David Edelsohn,
	gcc mailing list

On Sun, Jan 02, 2022 at 11:58:29PM +0100, Thomas Koenig wrote:
> Hi Michael,
> 
> > If you are building libraries that contain modules with multiple long double
> > types, you must use the '-mno-gnu-attribute'.  We also use the '-Wno-psabi'
> > option, which silences the warning that you are switching long double types (if
> > glibc is not 2.34 or newer).  We may need to tweak -Wno-psabi for use with
> > Fortran.
> 
> I am now at the point where the object files are also compiled correctly
> for the gfortran specifics:
> 
> 0000000000000000 <_gfortran_specific__abs_r17>:
>    0:   09 00 43 f4     lxv     vs34,0(r3)
>    4:   48 16 40 fc     xsabsqp v2,v2
>    8:   20 00 80 4e     blr
> 
> However, the linker complains, as you said it would, about the different
> formats:
> 
> /opt/at15.0/bin/ld: .libs/maxloc0_4_r16.o uses IBM long double,
> .libs/_abs_r17.o uses IEEE long double
> /opt/at15.0/bin/ld: failed to merge target specific data of file
> .libs/_abs_r17.o
> 
> I know next to nothing about libtool, so I do not know how to
> add the flags so the linker can find them.
> 
> Any pointers?
> 
> (I have not yet committed the changes because I do not want to
> commit something that does not compile.  If anybody wants to
> take a look, it's on the ieee128 virtual machine under
> /home/tkoenig/ieee ).

I'm just getting back into things after being off-line for the winter holidays.
As others have said, you need to use the GCC option -mno-gnu-attributes on any
module that handles one of the long double types if you are building libraries
that can handle both.

Note, for C/C++ languages, you should add -Wno-psabi to the options as well as
-mabi={ieee,ibm}longdouble.  This suppresses the warning that says you are
changing the long double type.  If you have configred GCC against GLIBC 2.32 or
newer, then you don't need the -Wno-psabi option.  Unfortunately, you can't use
-Wno-psabi on languages like Fortran.

-- 
Michael Meissner, IBM
PO Box 98, Ayer, Massachusetts, USA, 01432
email: meissner@linux.ibm.com

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

end of thread, other threads:[~2022-01-05 21:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <63b5434e-f8fa-97b3-d357-e25094579b16@netcologne.de>
     [not found] ` <bdc02706-a5ae-1389-906d-50c502b87d5f@linux.ibm.com>
     [not found]   ` <YYA2FMfDR0yehJLA@toto.the-meissners.org>
2022-01-02 22:58     ` [power-iee128] How to specify linker flags Thomas Koenig
2022-01-03 10:19       ` Thomas Koenig
2022-01-03 10:33         ` Jakub Jelinek
2022-01-03 10:34         ` Segher Boessenkool
2022-01-05 21:20       ` Michael Meissner

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).