Hello,

With the current mainline configured for powerpc-wrs-vxworks,
compiling the source below exposes a problem with tls support
(emulated) on this target:

  /* t.c  */
  __thread int y = 2;

./cc1 t.c -o -

 t.c:1:14: error: __tls__y causes a section type conflict with y
 __thread int y = 2;
              ^
 t.c:1:14: note: ‘y’ was declared here
   .section .tls_data,"a",@progbits
   .align 2
   .type y, @object
   .size y, 4
 y:
   .long 2
   .globl __tls__y
   .align 2
   .type __tls__y, @object
   .size __tls__y, 12
 __tls__y:
   .long y
   .long 0
   .long 4

The error is unexpected and we observe that both "y"
and "__tls_y" are emitted in the .tls_data section despite

    targetm.emutls.var_section = ".tls_vars";

in vxworks_override_option.

This looks like a simple thinko in tree-emutls.c, which
this patch fixes.

I checked that the VxWorks compiler behaves as expected after the
patch (no error + __tls_y emitted in .tls_vars). Also bootstrapped
and regression tested on x86_64-linux.

OK to commit ?

Thanks in advance,

With Kind Regards,

Olivier

2012-07-03  Olivier Hainque  <hain...@adacore.com>

        * tree-emutls.c (new_emutls_decl): When a var_section is requested by
        the target, attach the new decl to that, not to the template section.

Attachment: tls.diff
Description: Binary data

Reply via email to