diff mbox

[2/2] Disable .gnu_attribute tags in compatibility-ldbl.o

Message ID 20160928011338.GG3336@bubble.grove.modra.org
State New
Headers show

Commit Message

Alan Modra Sept. 28, 2016, 1:13 a.m. UTC
compatibility-ldbl.o is compiled with -mlong-double-64.  When
long double .gnu_attribute tags are checked by the linker, it
complains about the mismatch between this file and others in
libstdc++.

Bootstrapped and regression tested powerpc64le-linux and
powerpc64-linux biarch.  OK to apply?

	* configure.ac (LONG_DOUBLE_COMPAT_FLAGS): New ACSUBST.
	* src/Makefile.am (compatibility-ldbl.o, compatibility-ldbl.lo):
	Use LONG_DOUBLE_COMPAT_FLAGS.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* doc/Makefile.in: Regenerate.
	* include/Makefile.in: Regenerate.
	* libsupc++/Makefile.in: Regenerate.
	* po/Makefile.in: Regenerate.
	* python/Makefile.in: Regenerate.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.

Comments

Joseph Myers Sept. 28, 2016, 1:26 a.m. UTC | #1
On Wed, 28 Sep 2016, Alan Modra wrote:

> compatibility-ldbl.o is compiled with -mlong-double-64.  When
> long double .gnu_attribute tags are checked by the linker, it
> complains about the mismatch between this file and others in
> libstdc++.

Is that the only file in libstdc++ that involves long double in its 
interface at all, and so that gets such attributes?

I'd expect libraries such as libstdc++ and libgcc (generally, all compiler 
and libc libraries) to be set up in such a way that they will work with 
all long double choices in user code (via mangling and headers mapping 
access to long double library functions to the right versions for the 
chosen type) - and so need to be compiled without these attribute tags to 
avoid the linker complaining when someone links them with user code built 
with a non-default choice of long double.  Certainly for glibc I'd think 
using the option globally to build everything is the right choice (well, 
except for libnldbl.a, where -mlong-double-64 attributes are logically 
correct).
Alan Modra Sept. 28, 2016, 2:49 a.m. UTC | #2
On Wed, Sep 28, 2016 at 01:26:12AM +0000, Joseph Myers wrote:
> On Wed, 28 Sep 2016, Alan Modra wrote:
> 
> > compatibility-ldbl.o is compiled with -mlong-double-64.  When
> > long double .gnu_attribute tags are checked by the linker, it
> > complains about the mismatch between this file and others in
> > libstdc++.
> 
> Is that the only file in libstdc++ that involves long double in its 
> interface at all, and so that gets such attributes?

No, some 12 object files do, all marked with 128-bit IBM long double.
eg. c++locale.o, complex_io.o, hash_tr1.o.

> I'd expect libraries such as libstdc++ and libgcc (generally, all compiler 
> and libc libraries) to be set up in such a way that they will work with 
> all long double choices in user code (via mangling and headers mapping 
> access to long double library functions to the right versions for the 
> chosen type) - and so need to be compiled without these attribute tags to 
> avoid the linker complaining when someone links them with user code built 
> with a non-default choice of long double.  Certainly for glibc I'd think 
> using the option globally to build everything is the right choice (well, 
> except for libnldbl.a, where -mlong-double-64 attributes are logically 
> correct).

Yes, and this is why the linker only warns rather than errors on
mismatching .gnu.attributes tags.
Segher Boessenkool Sept. 28, 2016, 8:40 a.m. UTC | #3
On Wed, Sep 28, 2016 at 10:43:38AM +0930, Alan Modra wrote:
> compatibility-ldbl.o is compiled with -mlong-double-64.  When
> long double .gnu_attribute tags are checked by the linker, it
> complains about the mismatch between this file and others in
> libstdc++.
> 
> Bootstrapped and regression tested powerpc64le-linux and
> powerpc64-linux biarch.  OK to apply?

Okay with the option name fixed.  Thanks,


Segher
Joseph Myers Sept. 28, 2016, 5:19 p.m. UTC | #4
On Wed, 28 Sep 2016, Alan Modra wrote:

> > I'd expect libraries such as libstdc++ and libgcc (generally, all compiler 
> > and libc libraries) to be set up in such a way that they will work with 
> > all long double choices in user code (via mangling and headers mapping 
> > access to long double library functions to the right versions for the 
> > chosen type) - and so need to be compiled without these attribute tags to 
> > avoid the linker complaining when someone links them with user code built 
> > with a non-default choice of long double.  Certainly for glibc I'd think 
> > using the option globally to build everything is the right choice (well, 
> > except for libnldbl.a, where -mlong-double-64 attributes are logically 
> > correct).
> 
> Yes, and this is why the linker only warns rather than errors on
> mismatching .gnu.attributes tags.

But for a library that is aware of long double variants, it shouldn't even 
warn.  And given that we don't build multiple copies of GCC's libraries, 
they should be aware of the variants (via mangling them differently, 
ensuring versions of the relevant functions for each long double type are 
present, etc.) and so using them should not result in warnings.
diff mbox

Patch

diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index baf605c..4a5de8c 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -375,6 +375,7 @@  GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI([yes])
 GLIBCXX_DEFAULT_ABI
 
 ac_ldbl_compat=no
+LONG_DOUBLE_COMPAT_FLAGS="-mlong-double-64"
 case "$target" in
   powerpc*-*-linux* | \
   sparc*-*-linux* | \
@@ -389,8 +390,13 @@  case "$target" in
     AC_DEFINE([_GLIBCXX_LONG_DOUBLE_COMPAT],1,
 	      [Define if compatibility should be provided for -mlong-double-64.])
     port_specific_symbol_files="\$(top_srcdir)/config/os/gnu-linux/ldbl-extra.ver"
+    case "$target" in
+      powerpc*-*-linux*)
+	LONG_DOUBLE_COMPAT_FLAGS="$LONG_DOUBLE_COMPAT_FLAGS -mno-gnu-attr" ;;
+    esac
   fi
 esac
+AC_SUBST(LONG_DOUBLE_COMPAT_FLAGS)
 GLIBCXX_CONDITIONAL(GLIBCXX_LDBL_COMPAT, test $ac_ldbl_compat = yes)
 
 # Check if assembler supports disabling hardware capability support.
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index 00a6168..d9830c2 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -109,9 +109,9 @@  libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS)
 # pass -mlong-double-64.
 if GLIBCXX_LDBL_COMPAT
 compatibility-ldbl.lo: compatibility-ldbl.cc
-	$(LTCXXCOMPILE) -mlong-double-64 -c $<
+	$(LTCXXCOMPILE) $(LONG_DOUBLE_COMPAT_FLAGS) -c $<
 compatibility-ldbl.o: compatibility-ldbl.cc
-	$(CXXCOMPILE) -mlong-double-64 -c $<
+	$(CXXCOMPILE) $(LONG_DOUBLE_COMPAT_FLAGS) -c $<
 endif
 
 # Use special rules for C++11 files/objects.