https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99466
--- Comment #2 from Iain Buclaw <ibuclaw at gdcproject dot org> --- (In reply to Martin Liška from comment #1) > What compiler options do you use? No compiler options are necessary to reproduce the ICE. The symbol it fails on is ___emutls_t.tlsvar. Having a look at where this variable is created, it looks like TREE_PUBLIC is copied for DECL_ONE_ONLY symbols, but not DECL_WEAK. --- a/gcc/tree-emutls.c +++ b/gcc/tree-emutls.c @@ -242,16 +242,18 @@ get_emutls_init_templ_addr (tree decl) DECL_PRESERVE_P (to) = DECL_PRESERVE_P (decl); DECL_WEAK (to) = DECL_WEAK (decl); - if (DECL_ONE_ONLY (decl)) + if (DECL_ONE_ONLY (decl) || DECL_WEAK (decl)) { TREE_STATIC (to) = TREE_STATIC (decl); TREE_PUBLIC (to) = TREE_PUBLIC (decl); DECL_VISIBILITY (to) = DECL_VISIBILITY (decl); - make_decl_one_only (to, DECL_ASSEMBLER_NAME (to)); } else TREE_STATIC (to) = 1; + if (DECL_ONE_ONLY (decl)) + make_decl_one_only (to, DECL_ASSEMBLER_NAME (to)); + DECL_VISIBILITY_SPECIFIED (to) = DECL_VISIBILITY_SPECIFIED (decl); DECL_INITIAL (to) = DECL_INITIAL (decl); DECL_INITIAL (decl) = NULL;