Hi Nathan,

> This patch addresses a compiler incompatibility with non-capturing lambdas.
> Specifically, when a lambda's functions are comdat, we place the static
> _FUN function in the same comdat group as the operator() function.
>
> This breaks link compatibility with clang, where the static function is
> named __invoker and not placed in the same group.  The case we hit was a
> link failure when the clang-generated comdat group was chosen and the _FUN
> symbol dropped.
>
> I'm not sure of the rationale of placing them in the same group.  The
> inliner would still be correct to inline the operator() it can see into the
> _FUN body, as all comdat groups are supposed to be equivalent, so even if a
> clang-generated operator() ends up in the executable, that's fine to
> interoperate with a gcc-generated _FUN.  (we did initially think this was
> an LTO bug when it applied identical code folding to the two functions, as
> they are indeed identical)
>
> inter-compiler interoperation of capturing lambdas is a different issue --
> not sure if the ABI mandates layout.  But that's not relevant in this case
> as the lambda is an empty object, and that's the only case we can generate
> a static _FUN executor.
>
> Jason, any objections for trunk?

the new test FAILs on Solaris when the native assembler is in use, which
uses a different comdat group syntax:

+FAIL: g++.dg/abi/lambda-static-1.C  -std=c++14  scan-assembler .section[\\t 
]*.text._ZZ5lambyvENKUlvE_clEv,[^\\n\\r]*,_ZZ5lambyvENKUlvE_clEv,comdat
+FAIL: g++.dg/abi/lambda-static-1.C  -std=c++14  scan-assembler .section[\\t 
]*.text._ZZ5lambyvENUlvE_4_FUNEv,[^\\n\\r]*,_ZZ5lambyvENUlvE_4_FUNEv,comdat
+FAIL: g++.dg/abi/lambda-static-1.C  -std=c++17  scan-assembler .section[\\t 
]*.text._ZZ5lambyvENKUlvE_clEv,[^\\n\\r]*,_ZZ5lambyvENKUlvE_clEv,comdat
+FAIL: g++.dg/abi/lambda-static-1.C  -std=c++17  scan-assembler .section[\\t 
]*.text._ZZ5lambyvENUlvE_4_FUNEv,[^\\n\\r]*,_ZZ5lambyvENUlvE_4_FUNEv,comdat

While on i386 with gas I have

        .section        
.text._ZZ5lambyvENKUlvE_clEv,"axG",@progbits,_ZZ5lambyvENKUlvE_clEv,comdat

i386 with as emits

        .section        
.text._ZZ5lambyvENKUlvE_clEv%_ZZ5lambyvENKUlvE_clEv,"ax",@progbits
        .group  
_ZZ5lambyvENKUlvE_clEv,.text._ZZ5lambyvENKUlvE_clEv%_ZZ5lambyvENKUlvE_clEv,#comdat

and sparc with as is again slightly different:

        .section        
".text._ZZ5lambyvENKUlvE_clEv%_ZZ5lambyvENKUlvE_clEv",#alloc,#execinstr,#progbits
        .group  
_ZZ5lambyvENKUlvE_clEv,".text._ZZ5lambyvENKUlvE_clEv%_ZZ5lambyvENKUlvE_clEv",#comdat

The following patch allows for all three variants, only looking at the
.group line with as since that's enough to check for different group
names.

Tested on i386-pc-solaris2.11 with gas and as and
sparc-sun-solaris2.11.  Ok for mainline?

        Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2019-03-26  Rainer Orth  <r...@cebitec.uni-bielefeld.de>

        * g++.dg/abi/lambda-static-1.C: Handle Solaris as comdat group
        syntax.

# HG changeset patch
# Parent  ddd55451e9cb2406fe2855aef46c6695b2c7b542
Fix g++.dg/abi/lambda-static-1.C with Solaris as

diff --git a/gcc/testsuite/g++.dg/abi/lambda-static-1.C b/gcc/testsuite/g++.dg/abi/lambda-static-1.C
--- a/gcc/testsuite/g++.dg/abi/lambda-static-1.C
+++ b/gcc/testsuite/g++.dg/abi/lambda-static-1.C
@@ -21,5 +21,7 @@ void indirect ()
 // The call operator and the static invoker should be comdat, but not
 // the same group.  (that would be a compiler incompatibility)
 
-// { dg-final { scan-assembler ".section\[\t ]*.text._ZZ5lambyvENKUlvE_clEv,\[^\n\r]*,_ZZ5lambyvENKUlvE_clEv,comdat" } }
-// { dg-final { scan-assembler ".section\[\t ]*.text._ZZ5lambyvENUlvE_4_FUNEv,\[^\n\r]*,_ZZ5lambyvENUlvE_4_FUNEv,comdat" } }
+// { dg-final { scan-assembler ".section\[\t ]*.text._ZZ5lambyvENKUlvE_clEv,\[^\n\r]*,_ZZ5lambyvENKUlvE_clEv,comdat" { target { { ! *-*-solaris2.* } || { gas } } } } }
+// { dg-final { scan-assembler ".section\[\t ]*.text._ZZ5lambyvENUlvE_4_FUNEv,\[^\n\r]*,_ZZ5lambyvENUlvE_4_FUNEv,comdat" { target { { ! *-*-solaris2.* } || { gas } } } } }
+// { dg-final { scan-assembler ".group\[\t \]*_ZZ5lambyvENKUlvE_clEv,\[^\n\r\]*,#comdat" { target { *-*-solaris2.* && { ! gas } } } } }
+// { dg-final { scan-assembler ".group\[\t \]*_ZZ5lambyvENUlvE_4_FUNEv,\[^\n\r\]*,#comdat" { target { *-*-solaris2.* && { ! gas } } } } }

Reply via email to