------- Comment #14 from ktietz at gcc dot gnu dot org 2010-05-18 15:18 ------- Hi Dave,
following patch solves the issue for me pretty well. ChangeLog * varasm.c (emutls_decl): Clone attributes for new decl. Index: gcc/gcc/varasm.c =================================================================== --- gcc.orig/gcc/varasm.c 2010-05-18 13:19:20.000000000 +0200 +++ gcc/gcc/varasm.c 2010-05-18 17:10:11.385445300 +0200 @@ -403,6 +403,8 @@ emutls_decl (tree decl) int foo() { return i; } __thread int i = 1; in which I goes from external to locally defined and initialized. */ + DECL_DLLIMPORT_P (to) = DECL_DLLIMPORT_P (decl); + DECL_ATTRIBUTES (to) = targetm.merge_decl_attributes (decl, to); TREE_STATIC (to) = TREE_STATIC (decl); TREE_USED (to) = TREE_USED (decl); -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44139