Hello, As discussed here, the current behavior of -ftls-model is intended: http://gcc.gnu.org/ml/gcc/2013-07/msg00248.html (in short: unlike the attribute, -ftls-model sets a "most general" model to be used, but the compiler can use a less general model than specified, making it impossible to set global-dynamic model on the command line for non-PIC code).
I'd like to add a clarification to the docs. OK for trunk? 2013-07-24 Alexander Monakov <amona...@ispras.ru> * doc/invoke.texi: Mention that -ftls-model does not force the final model. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index d99d217..4d1fbee 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -20802,6 +20802,9 @@ Not all targets provide complete support for this switch. Alter the thread-local storage model to be used (@pxref{Thread-Local}). The @var{model} argument should be one of @code{global-dynamic}, @code{local-dynamic}, @code{initial-exec} or @code{local-exec}. +Note that the choice is subject to optimization: the compiler may use +a more efficient model for symbols not visible outside of the translation +unit, or if @option{-fpic} is not given on the command line. The default without @option{-fpic} is @code{initial-exec}; with @option{-fpic} the default is @code{global-dynamic}.