From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 1F6033858C2C for ; Mon, 3 Jan 2022 10:33:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1F6033858C2C Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-183-QBEFBcicPC6cxXjagOWnYQ-1; Mon, 03 Jan 2022 05:33:36 -0500 X-MC-Unique: QBEFBcicPC6cxXjagOWnYQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EE0432F24; Mon, 3 Jan 2022 10:33:34 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.2.16.169]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 665F27BE46; Mon, 3 Jan 2022 10:33:34 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 203AXVQ01326966 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 3 Jan 2022 11:33:31 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 203AXTaS1326965; Mon, 3 Jan 2022 11:33:29 +0100 Date: Mon, 3 Jan 2022 11:33:29 +0100 From: Jakub Jelinek To: Thomas Koenig Cc: Michael Meissner , Bill Schmidt , "fortran@gcc.gnu.org" , Segher Boessenkool , Peter Bergner , David Edelsohn , gcc mailing list Subject: Re: [power-iee128] How to specify linker flags Message-ID: <20220103103329.GR2646553@tucnak> Reply-To: Jakub Jelinek References: <63b5434e-f8fa-97b3-d357-e25094579b16@netcologne.de> <541fa494-ce3c-50f2-367b-f0dd492dcf45@netcologne.de> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jan 2022 10:33:55 -0000 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 * 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