diff mbox

[libitm] Check if GCC uses assembler cfi support

Message ID yddfvlp2x27.fsf@lokon.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth April 7, 2014, 11:33 a.m. UTC
The Solaris 11.2 x86 assembler is going to gain support for the cfi
directives.  To do things right this time, it will create read-only
.eh_frame sections, unlike what gas and gcc currently do.  The goal is
to let /bin/ld handle the required merging of read-only and read-write
.eh_frame sections, but that's not there yet and won't make the S11.2
release.  For the time being, gcc/configure.ac (gcc_cv_as_cfi_directive)
takes care of that and disables the support, but there's one issue left:
libitm does the cfi directive detection on its own, finds the assembler
support and uses it in config/x86/sjlj.S, which breaks linking the
32-bit libitm.so:

ld: fatal: file .libs/aatree.o; section [15].eh_frame and file .libs/sjlj.o; section [3].eh_frame have incompatibile attributes and cannot be merged into a single output section
collect2: error: ld returned 1 exit status
make[4]: *** [libitm.la] Error 1

To avoid this, libitm and gcc need to agree whether or not to use
assembler cfi support.

The following patch avoid this by checking __GCC_HAVE_DWARF2_CFI_ASM.

Alternatively, one could do away with
config/asmcfi.m4 (GCC_AS_CFI_PSEUDO_OP), and only check for
__GCC_HAVE_DWARF2_CFI_ASM under the assumption that libitm will only be
used in-tree with a matching gcc.

I've avoided changing config/asmcfi.m4 since that's also used by libffi,
which is external to the gcc tree and can be used with non-gcc
compilers.

The patch allowed i386-pc-solaris2.11 bootstraps to finish without
regressions on trunk and 4.8 branch, still need to test 4.7 branch.

Ok for trunk, 4.8 and 4.7 branches once testing completes?

	Rainer


2014-04-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* config/generic/asmcfi.h: Also check for
	__GCC_HAVE_DWARF2_CFI_ASM.

Comments

Richard Henderson April 7, 2014, 3:02 p.m. UTC | #1
On 04/07/2014 04:33 AM, Rainer Orth wrote:
> The patch allowed i386-pc-solaris2.11 bootstraps to finish without
> regressions on trunk and 4.8 branch, still need to test 4.7 branch.
> 
> Ok for trunk, 4.8 and 4.7 branches once testing completes?
> 
> 	Rainer
> 
> 
> 2014-04-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
> 
> 	* config/generic/asmcfi.h: Also check for
> 	__GCC_HAVE_DWARF2_CFI_ASM.

Looks fine.


r~
Rainer Orth April 8, 2014, 9:17 a.m. UTC | #2
Richard Henderson <rth@redhat.com> writes:

> On 04/07/2014 04:33 AM, Rainer Orth wrote:
>> The patch allowed i386-pc-solaris2.11 bootstraps to finish without
>> regressions on trunk and 4.8 branch, still need to test 4.7 branch.
>> 
>> Ok for trunk, 4.8 and 4.7 branches once testing completes?
>> 
>> 	Rainer
>> 
>> 
>> 2014-04-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>> 
>> 	* config/generic/asmcfi.h: Also check for
>> 	__GCC_HAVE_DWARF2_CFI_ASM.
>
> Looks fine.

Testing was fine on i386-pc-solaris2.11 with /bin/as on trunk, 4.8 and
4.7 branches, as well as x86_64-unknown-linux-gnu.

However, i386-pc-solaris2.11 with gas was confusing at first: for the
32-bit PIC case, no .eh_frame was generated.  It turned out this happens
because in this case config/i386/sol2.h (ASM_PREFERRED_EH_DATA_FORMAT)
is a lie: it claims datarel encoding for the 32-bit PIC case.  This way,
dwarf2out_do_cfi_asm returns false and c-family/c-cppbuiltin.c
(c_cpp_builtins) doesn't define __GCC_HAVE_DWARF2_CFI_ASM.

In fact, gas with cfi directives uses pcrel encoding, thus
__GCC_HAVE_DWARF2_CFI_ASM should be defined.

ISTM that the ASM_PREFERRED_EH_DATA_FORMAT redefinition above should be
wrapped in HAVE_AS_IX86_DIFF_SECT_DELTA, but I'm quite reluctant to make
such a change so late in the 4.9 release cycle.

I'll certainly try it post-4.9, especially given that Solaris 9 support
will be removed by then and current Solaris 10 and 11 assemblers *can*
subtract symbols in different sections.

Unless I'm missing something, I'm thus going to check in the patch as is
within a day.  I believe that losing unwind info in a single case here
is worth avoiding the bootstrap failure.

	Rainer
diff mbox

Patch

# HG changeset patch
# Parent e003a40e0bb68a5019d8492cec81e453514988b0
Check if GCC uses assembler cfi support

diff --git a/libitm/config/generic/asmcfi.h b/libitm/config/generic/asmcfi.h
--- a/libitm/config/generic/asmcfi.h
+++ b/libitm/config/generic/asmcfi.h
@@ -24,7 +24,7 @@ 
 
 #include "config.h"
 
-#ifdef HAVE_AS_CFI_PSEUDO_OP
+#if defined(HAVE_AS_CFI_PSEUDO_OP) && defined(__GCC_HAVE_DWARF2_CFI_ASM)
 
 #define cfi_startproc			.cfi_startproc
 #define cfi_endproc			.cfi_endproc
@@ -50,4 +50,4 @@ 
 #define cfi_restore(r)
 #define cfi_undefined(r)
 
-#endif /* HAVE_AS_CFI_PSEUDO_OP */
+#endif /* HAVE_AS_CFI_PSEUDO_OP && __GCC_HAVE_DWARF2_CFI_ASM */