[Patch, toplevel/config] fix tls.m4 configure race condition (bootstrap/PR43170)

Ralf Wildenhues Ralf.Wildenhues@gmx.de
Tue Jun 8 17:09:00 GMT 2010


Hello,

* Paolo Bonzini wrote on Tue, Jun 08, 2010 at 06:31:52PM CEST:
> >>On 06/06/2010 02:58 PM, IainS wrote:
> >>>(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43170).

> I guess it depends on when __emutls_get_address is lowered.  But
> then the compiler could be smart and "localize" the variable with
> -fwhole-program, so your change is only safe for current compilers.
> I think the best solution is to make "a" volatile, like
> 
>  		__thread volatile int a;
> -		static int volatile *volatile a_in_other_thread;
> 
> ...
> 
>  		int volatile *volatile a_in_main_thread;
>  		a_in_main_thread = &a;
>                 *a_in_main_thread;
> 
> This is more future-proof, I guess. Can you try this?

I asked about volatile in the above PR (comment #39), and was called
down (comment #59).  I've read <http://www.airs.com/blog/archives/154>.

Can somebody untie the logical knot up my brain?  Is any of the volatile
really needed here?  And if yes, can somebody provide an explanation
that doesn't sound like "let's try if this works"?

Is volatile required here because we want to peek behind implementation
details that are not supposed to be observable, and observable features
of threads don't need them?

Thank you, (and yes, I don't mind moving to gcc-help)
Ralf



More information about the Gcc-patches mailing list