Message ID | 20160928011338.GG3336@bubble.grove.modra.org |
---|---|
State | New |
Headers | show |
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).
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.
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
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 --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.