[build, v3] Enable COMDAT group support on Solaris 10
Rainer Orth
ro@CeBiTec.Uni-Bielefeld.DE
Tue Feb 6 18:48:00 GMT 2018
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:
> While investigating PR bootstrap/84017, it turned out that it *is*
> possible to enable COMDAT group support on Solaris 10 with Solaris ld in
> some circumstances. I'm posting my findings and the resulting patch
> here for reference only; this is certainly not GCC 8 material.
>
> Besides, there's a abi_check failure in libstdc++ which makes it unclear
> if this desirable at all.
>
> So here's the deal: I remembered that Solaris ld has a -z relaxreloc
> option, documented as
>
> -z relaxreloc
>
> ld normally issues a fatal error upon encountering a
> relocation using a symbol that references an eliminated
> COMDAT section. If -z relaxreloc is enabled, ld instead
> redirects such relocations to the equivalent symbol in
> the COMDAT section that was kept. -z relaxreloc is a
> specialized option, mainly of interest to compiler
> authors, and is not intended for general use.
>
> It was only introduced in Solaris 10 Update 10, so won't help on earlier
> versions.
>
> When ld supports that option, I always pass it when linking and enable
> comdat_group (and hidden_linkonce) in configure.ac.
>
> Test results are astonishingly good:
>
> * On Solaris 10/x86, I get three tests where ld SEGVs with -flto
> (skipped/xfailed in the present patch).
>
> * On both Solaris 10/SPARC and x86, libstdc++-abi/abi_check FAILs:
>
> # of added symbols: 2
> # of missing symbols: 0
> # of undesignated symbols: 0
> # of incompatible symbols: 2
>
> 2 added symbols
> 0
> _ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEED2Ev
> std::__cxx11::basic_stringbuf<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::~basic_stringbuf()
> version status: incompatible
> GLIBCXX_3.4.21
> type: function
> status: added
>
> 1
> _ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEED2Ev
> std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::~basic_stringbuf()
> version status: incompatible
> GLIBCXX_3.4.21
> type: function
> status: added
>
>
> 2 incompatible symbols
> 0
> _ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEED2Ev
> std::__cxx11::basic_stringbuf<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::~basic_stringbuf()
> version status: incompatible
> GLIBCXX_3.4.21
> type: function
> status: added
>
>
> 1
> _ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEED2Ev
> std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::~basic_stringbuf()
> version status: incompatible
> GLIBCXX_3.4.21
> type: function
> status: added
>
> Those symbols are present in the Solaris 11 baselines (where COMDAT
> group always works), which is also used with Solaris 10 and GNU ld.
>
> I'm not yet sure how to deal with this: we'd have to introduce 3
> baselines:
>
> * Solaris 10 without COMDAT group support
> * Solaris 10 with COMDAT group support
> * Solaris 11
>
> Seems like a lot of trouble to me actually. I've not done anything
> about this yet, so as is the patch shows the abi_check failures.
I've now revised the patch a bit, especially for the abi_check failure:
* Since Solaris 10 with gld (which already did support COMDAT group)
already used the *-solaris2.11 baselines, I've extended that to any
Solaris 10 configuration with COMDAT group support. This needed a
configure test in libstdc++-v3/acinclude.m4 matching what the
comdat_group effective-target keyword does. However, I couldn't use
a simple AC_TRY_COMPILE with -S added to CXXFLAGS: that will always
fail since the macro checks for the existence of conftest.o as first
indication of success, which of course doesn't exist with -S.
* I've also tried to enable USE_HIDDEN_LINKONCE on Solaris 10/x86 with
COMDAT group, but that leads to four more testcases where ld SEGVs, so
I've left it disabled.
Otherwise, nothing remarkable: bootstrapped without regressions on
i386-pc-solaris2.10 and sparc-sun-solaris2.10 (both as/ld and gas/ld)
without and with --disable-comdat; also bootstrapped on some
*-*-solaris2.11 configurations, no regressions.
I'm just posting this for comment here; I may or may not commit this in
the GCC 9 timeframe.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
2018-01-28 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
libstdc++-v3:
* acinclude.m4 (GLIBCXX_CONFIGURE): Check for COMDAT group
support.
* configure: Regenerate.
* configure.host (*-*-solaris2.1[0-9])): Check $comdat_group to
select baselines.
gcc/testsuite:
* g++.dg/lto/pr65475c_0.C: Skip on Solaris 10/x86 with ld/comdat.
* g++.dg/lto/pr68057_0.C: Likewise.
* gcc.dg/debug/pr41893-1.c: Xfail on Solaris 10/x86 with ld/comdat
for -gdwarf-2 -g3.
gcc:
* configure.ac (gcc_cv_ld_relaxreloc): New test.
(comdat_group): Enable on Solaris 10 if ld -z relaxreloc is present.
* configure: Regenerate.
* config.in: Regenerate.
* config/sol2.h (LINK_RELAXRELOC_SPEC): Define.
(LINK_SPEC): Use it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sol10-comdat.patch
Type: text/x-patch
Size: 6264 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20180206/1122566b/attachment.bin>
More information about the Libstdc++
mailing list