public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Iain Sandoe <idsandoe@googlemail.com>
To: Sebastian Huber <sebastian.huber@embedded-brains.de>
Cc: Alexander Monakov <amonakov@ispras.ru>,
	GCC Development <gcc@gcc.gnu.org>
Subject: Re: Use -ftls-model=local-exec for RTEMS by default?
Date: Thu, 21 Jul 2022 09:03:24 +0100	[thread overview]
Message-ID: <55ED194B-0F4D-4551-97D8-A898AA771A1D@googlemail.com> (raw)
In-Reply-To: <808c2471-af44-605e-05e4-330f08e13206@embedded-brains.de>



> On 21 Jul 2022, at 06:25, Sebastian Huber <sebastian.huber@embedded-brains.de> wrote:
> 
> On 20.07.22 15:01, Alexander Monakov wrote:
>> 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).
> 
> This sounds like an interesting approach in the long run, however, I need a short term solution which I can back port to GCC 10, 11, and 12. I guess I will add a
> 
> MULTILIB_EXTRA_OPTS = ftls-model=local-exec
> 
> to all RTEMS multilib configurations.
> 
> In general I think the target hooks are hard to customize for operating systems.

(IMO) It can be not too tricky -  Darwin customises several - you just have to override the default definition in your target-specific header and provide the replacement e.g ( override in config/darwin.h, replacement in config/darwin.cc):

#undef TARGET_ENCODE_SECTION_INFO
#define TARGET_ENCODE_SECTION_INFO  darwin_encode_section_info

0.02GBP only, as always ;)
Iain

> 
> -- 
> embedded brains GmbH
> Herr Sebastian HUBER
> Dornierstr. 4
> 82178 Puchheim
> Germany
> email: sebastian.huber@embedded-brains.de
> phone: +49-89-18 94 741 - 16
> fax:   +49-89-18 94 741 - 08
> 
> Registergericht: Amtsgericht München
> Registernummer: HRB 157899
> Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
> Unsere Datenschutzerklärung finden Sie hier:
> https://embedded-brains.de/datenschutzerklaerung/


  reply	other threads:[~2022-07-21  8:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-20  8:43 Sebastian Huber
2022-07-20  9:28 ` Sebastian Huber
2022-07-20 11:41   ` Alexander Monakov
2022-07-20 11:48     ` Sebastian Huber
2022-07-20 13:01       ` Alexander Monakov
2022-07-21  5:25         ` Sebastian Huber
2022-07-21  8:03           ` Iain Sandoe [this message]
2022-07-22 11:19             ` Sebastian Huber
2022-07-22 11:35               ` Iain Sandoe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55ED194B-0F4D-4551-97D8-A898AA771A1D@googlemail.com \
    --to=idsandoe@googlemail.com \
    --cc=amonakov@ispras.ru \
    --cc=gcc@gcc.gnu.org \
    --cc=sebastian.huber@embedded-brains.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).