This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR c++/85400
- From: Jason Merrill <jason at redhat dot com>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 26 Apr 2018 14:49:41 -0400
- Subject: Re: [PATCH] Fix PR c++/85400
- References: <32444455.vUGMIimiic@polaris>
On Thu, Apr 26, 2018 at 9:42 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> for the attached testcase compiled/linked with -shared -fPIC -O, the Solaris
> linker chokes on SPARC because the generated code uses the local-dynamic TLS
> model for a global symbol:
>
> ld: fatal: relocation error: R_SPARC_TLS_LDM_HI22: file /var/tmp//ccKG6GQC.o:
> symbol Test::blah(int)::mything: bound to: /var/tmp//ccKG6GQC.o: relocation
> illegal when not bound to object being created
>
> The symbol is a local TLS symbol defined in an inline method of a class so it
> is first local so decl_default_tls_model chooses TLS_MODEL_LOCAL_DYNAMIC. But
> then it is "commonized" by the C++ front-end:
>
> /* If a local static variable is declared in an inline function, or if
> we have a weak definition, we must endeavor to create only one
> instance of the variable at link-time. */
>
> which calls comdat_linkage, which in turn calls make_decl_one_only, which
> makes it weak and public, so unsuitable for the local-dynamic TLS model.
>
> The proposed fix is to reset the TLS model after the commonization, but of
> course only if no tls_model attribute was set on the variable, hence the fix
> for handle_tls_model_attribute. Tested on x86-64/Linux, OK for mainline?
>
>
> 2018-04-26 Eric Botcazou <ebotcazou@adacore.com>
>
> cp/
> PR c++/85400
> * decl.c (cp_finish_decl): Recompute the TLS model after commonizing
> a TLS-local variable, unless it has got an explicit TLS model.
It seems like we're likely to need the same thing when we get to
make_decl_one_only by other paths; perhaps we should put this
recalculation in a cxx_make_decl_one_only.
Jason