From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by sourceware.org (Postfix) with ESMTPS id A86463858D37 for ; Wed, 20 Jul 2022 13:01:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A86463858D37 Received: from [10.10.3.121] (unknown [10.10.3.121]) by mail.ispras.ru (Postfix) with ESMTPS id B8DA540737CC; Wed, 20 Jul 2022 13:01:30 +0000 (UTC) Date: Wed, 20 Jul 2022 16:01:30 +0300 (MSK) From: Alexander Monakov To: Sebastian Huber cc: GCC Development Subject: Re: Use -ftls-model=local-exec for RTEMS by default? In-Reply-To: Message-ID: <2592dc25-bf0-6051-a9d8-68db5c3ad6a7@ispras.ru> References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2022 13:01:36 -0000 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