From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 494453858D28 for ; Thu, 21 Jul 2022 08:03:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 494453858D28 Received: by mail-wr1-x435.google.com with SMTP id m17so797577wrw.7 for ; Thu, 21 Jul 2022 01:03:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=gf0HbI3ehkWKqcxk2+8gKyM3dkrUOiYyptiHVdO7EUk=; b=1EWy/Xr49fCXvevCJzDoIYsD4coERTJO3UvC20j+a7g3CF5jemB7c05SLZlnJRqL7A ca01gVH/rpg2ZAKZhccjwgpxJfoBhbS0pWdYao7Q4l+Oew3tUmT9ZWwMCUucWbzX/dzQ GjTucbdELAbsN37g5GWtY+WKH8mF7qZd9/rCMPhKHVzmwuYM8MC2VX1lUs5byxHf0Lro wRLt+GpvipLxM4edCgcoZg/LWmBLQ+YT+xiYO6RhEpuOizXJ2R3T6BVgqQ5J0x9Qy5A2 d2+SeEhzQmbDD2HnNsuxpfBtnuPfaTgBEVEeB/3SUfXTpZMgh6bzEkWj9MmF7QQXxm0C ol5w== X-Gm-Message-State: AJIora8mqpkHxKQh0PjsDpV95AZQTfkz3jBlOYNgvTARDgbPAbOsXdhr AOIZyWm0JRQZ4TT1HMbb3BE= X-Google-Smtp-Source: AGRyM1svvCb1XSFkrRCn0aXbKlfoRlMB3yQ2+ExVfta38PF7HyguqU5gtWLvDbbsEM3s4VoPWKAIDA== X-Received: by 2002:a05:6000:508:b0:21d:4105:caf9 with SMTP id a8-20020a056000050800b0021d4105caf9mr34621093wrf.699.1658390605770; Thu, 21 Jul 2022 01:03:25 -0700 (PDT) Received: from [192.168.1.95] (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.googlemail.com with ESMTPSA id h13-20020a05600016cd00b0021e4e9f6450sm1088849wrf.84.2022.07.21.01.03.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jul 2022 01:03:25 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: Use -ftls-model=local-exec for RTEMS by default? From: Iain Sandoe In-Reply-To: <808c2471-af44-605e-05e4-330f08e13206@embedded-brains.de> Date: Thu, 21 Jul 2022 09:03:24 +0100 Cc: Alexander Monakov , GCC Development Content-Transfer-Encoding: quoted-printable Message-Id: <55ED194B-0F4D-4551-97D8-A898AA771A1D@googlemail.com> References: <2592dc25-bf0-6051-a9d8-68db5c3ad6a7@ispras.ru> <808c2471-af44-605e-05e4-330f08e13206@embedded-brains.de> To: Sebastian Huber X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, 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: Thu, 21 Jul 2022 08:03:38 -0000 > On 21 Jul 2022, at 06:25, Sebastian Huber = wrote: >=20 > 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: >>>>=20 >>>>> 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: >>>=20 >>> extern _Thread_local int i; >>> _Thread_local int j; >>>=20 >>> int f(void) >>> { >>> return i + j; >>> } >>>=20 >>> 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). >=20 > 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 >=20 > MULTILIB_EXTRA_OPTS =3D ftls-model=3Dlocal-exec >=20 > to all RTEMS multilib configurations. >=20 > 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 >=20 > --=20 > 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 >=20 > Registergericht: Amtsgericht M=C3=BCnchen > Registernummer: HRB 157899 > Vertretungsberechtigte Gesch=C3=A4ftsf=C3=BChrer: Peter Rasmussen, = Thomas D=C3=B6rfler > Unsere Datenschutzerkl=C3=A4rung finden Sie hier: > https://embedded-brains.de/datenschutzerklaerung/