Optimizes out TLS variable called in a child function

Michael Cronenworth mike@cchtml.com
Mon Mar 9 00:28:00 GMT 2015


During my adventures in wine and gcc5 I've had to compile updated wine-gecko and 
wine-mono binaries as they get updated at various periods alongside wine. I 
encountered an issue with gcc5 not compiling a TLS routine in wine-mono. I created a 
simple test case and can see the same failure result with the test case in gcc 4.8 
and 4.9 as well as 5. My test case may be doing something wrong, and if it is I may 
be able to fix wine-mono, but the test case fails in a suspiciously single way that 
looks like a gcc bug.

The attached test case is getting the offset location of a TLS variable. When 
compiled with -O0 the test case compiles. When compiled with -O1 the test case will 
not compile with an error for an undefined reference to the TLS variable. If you 
move the THREAD_VAR_OFFSET macro call to main() gcc will compile without error. Any 
suggestions?

Thanks,
Michael

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.c
Type: text/x-csrc
Size: 346 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20150309/75e867d2/attachment.bin>


More information about the Gcc-help mailing list