On Wed, 20 Jul 2022, Sebastian Huber wrote:
> On 20/07/2022 13:41, Alexander Monakov wrote: > > On Wed, 20 Jul 2022, Sebastian Huber wrote: > > > >> How does Ada get its default TLS model? > > You shouldn't need to do anything special, GCC automatically selects > > initial-exec or local-exec for non-PIC (including PIE). > > I am not sure, for this test program: > > extern _Thread_local int i; > _Thread_local int j; > > int f(void) > { > return i + j; > } > > I get: [snip] Thanks, I missed that you are asking about promoting initial-exec to local-exec rather than x-dynamic to y-exec. There's a pending patch that implements such promotion based on visibility information: https://gcc.gnu.org/pipermail/gcc-patches/2022-July/598017.html With that patch, you'll get local-exec model for the extern variable 'i' if you inform the compiler that its definition will end up in the current module: __attribute__((visibility("hidden"))) extern _Thread_local int i; _Thread_local int j; int f(void) { return i + j; } Thus I would try to enhance the binds_local_p target hook for RTEMS to inform the compiler that there's no dynamic linking (although apart from TLS variables I cannot instantly name other places where it would enhance optimization). HTH Alexander