On Fri, Jul 19, 2013 at 08:08:26PM +0400, Alexander Monakov wrote: > On Fri, 19 Jul 2013, Jakub Jelinek wrote: > > The change of memory models based on flag_shlib is completely intentional, > > it is similar to the linker TLS optimizations but at the compiler level, > > so if you want to ad some comment to documentation, that is fine, but > > I don't see anything to fix. > > The problem is that -ftls-model flag allows forcing local-exec TLS in > shared objects, but does not allow forcing global-dynamic TLS. I don't see > the rationale for providing one but not the other. It seems inconsistent.
If user code has __attribute__((tls_model ("global-dynamic"))) and the compiler determines that it is not going to be used in a shared library, then it of course optimizes it to a better code, and if we did that only at the ld time, the generated code would be worse. That is the common case, the case where people compile incorrectly objects that they want to link into shared libraries is simply a user error that we shouldn't in any way promote or support. Jakub