https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121318
Alexander Monakov <amonakov at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amonakov at gcc dot gnu.org --- Comment #3 from Alexander Monakov <amonakov at gcc dot gnu.org> --- When necessary to upgrade global-dynamic to initial-exec (in libraries) without downgrading local-exec to initial-exec (in executables), the code can attach the attribute conditionally: #if defined(__pic__) && !defined(__pie__) __attribute__ ((tls_model ("initial-exec"))) #endif __thread const int *pfoo = afoo; LLVM performs the requested optimization. Refusing to do this optimization without a justification would be weird.