From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id 51FD83858D33 for ; Thu, 16 Nov 2023 05:33:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 51FD83858D33 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=google.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 51FD83858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::333 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700112824; cv=none; b=ddfdgb2XDJYQ0Ax06UEIkZIy/8ZV752fJ7h5hvA3FwPvMUHy4iWmIKrtt88GeB8yIHewGFUtkAbCITqRlBr7itzvD4EG/0iyOzMC7o68L1EmLVE+CbeLmKY3kwLrIWYZks/tkNBADbhjLe9qvqQ4C3ZQ1d0s5xvcbrU3Ha63Mmo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700112824; c=relaxed/simple; bh=rklAG2ERDrGqSF3d7R4jB6eBG+aFQ2ot75H5uOzjBR0=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=Yby2W8VbJL9+ZisHb031LH5tjSQxT24LTR3H2v9KfVS9BjzNZn22XeB+Wst6z5niC90SPl06RYwJXl4KaZvmSABPwsGgFSetOrVyN21KdDmaYtWmzPXwNmgwKPHjkSePD+r4JGPTRLna8HAGu40ZaQiX+tyRJ/RxTElBTqaiPZo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40a426872c6so44125e9.0 for ; Wed, 15 Nov 2023 21:33:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700112822; x=1700717622; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=66jinDour3X07WP2PgttC92J73Uivf/zi/IFoajrhTE=; b=zKjwgcSttY0FjCvJJO+Y+Q8NCFTLgH8fj7g+WRoUjaCfCZc65hfN0+JibY1o3jiVmV KX9NrCP3G1beCCpGeGzJM3ulsCAOgq4LTd7wj+A4h6ThdrXAyU5MgbwYWPjI0u/djXyb ZAMSpAbQgQ1xspn/bZjMKddU0hjZA9yMphdY4PyBqGUTQuUKs18+C03ywAvbYNXR1+Zt R+8b/1TQhOya14wAOFNguVgYCEOVJdcmSSES1eWzvjhTP2U/T1UHg9UFUoi7RY/fKqnf BA6VusrBVjRuRDX2h4Xitz9vSQCdoj7QAJjF0e4Dgn4q+FJYWpljTdtWXWEB93/H10Nt XVfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700112822; x=1700717622; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=66jinDour3X07WP2PgttC92J73Uivf/zi/IFoajrhTE=; b=rhAtO0+mNix4Ut3saK/2LTkZ3ghwSmOaR4iZRGu3sKQaQLo0o3EpPbBNRV2ek/ADXb p7P2Rurjipi7QcLhU8CDDw72U57fB335pkVj7hc9dxqb35rwB0UPQOFZWnyDRCZCKKRP 0/G5z5uEnTtvo+Jyl68zR6AyutbKgrGLESP5pWB8RFpC+E8kDOJVBV9r12zOZewkdT0k Ow6hB+KOhJO5GGs28ROKEtQwcZXYtwSWJKmRDD8awEkSeBbLaxXA8Rhrx/tn0sS3Emn+ cxw3b+5+UB21zF8CIWXqg7RIbk5UFWe9OTNLU3lltrnrkzkSig8VivxL1zss3jIItgyf UyxA== X-Gm-Message-State: AOJu0YwmLIpgnT+9sa3PnfClGD2BsqzazAmeXB7ElKsRDwFgjlFEo93c j2vl3hAswhMZE2lwSzxlHqfYqkKOg/oIUdY6z1BqNg== X-Google-Smtp-Source: AGHT+IGjCHuOw71+L/l56mlTxKFL3cD/FcrrfdBLQS3zbOl078HUIkee9WHxuNihIGXawxq8/fLLzdMBaUqiB7PjYbE= X-Received: by 2002:a05:600c:1895:b0:3f7:3e85:36a with SMTP id x21-20020a05600c189500b003f73e85036amr62368wmp.7.1700112821936; Wed, 15 Nov 2023 21:33:41 -0800 (PST) MIME-Version: 1.0 References: <20230817181308.122802-2-ishitatsuyuki@gmail.com> <20230908104923.31154-1-ishitatsuyuki@gmail.com> <54cba99d-fa53-4ecd-b850-f8f7e2c8a21a@gmail.com> <549C3D78-7D43-4D7D-B0E1-0271B1E4CBDA@gmail.com> <55ee8943-babd-4fb2-aaab-ca88e37683b7@gmail.com> In-Reply-To: <55ee8943-babd-4fb2-aaab-ca88e37683b7@gmail.com> From: Fangrui Song Date: Wed, 15 Nov 2023 21:33:29 -0800 Message-ID: Subject: Re: [PATCH v2] RISC-V: Implement TLS Descriptors. To: Tatsuyuki Ishi Cc: gcc-patches@gcc.gnu.org, Jeff Law , Rui Ueyama , ruiu@bluewhale.systems, kito.cheng@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH,KAM_INFOUSMEBIZ,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Nov 15, 2023 at 9:23=E2=80=AFPM Jeff Law wr= ote: > > > > On 11/15/23 18:51, Tatsuyuki Ishi wrote: > >> On Nov 16, 2023, at 10:07, Jeff Law wrote: > > > > > Based on what I have read in the AArch64 backend, there are two ways to > > do this: introduce a custom calling convention, or put in a RTX insn > > that covers the whole sequence. Ideally we should do the first, but the= n > > there=E2=80=99s the label issue and it=E2=80=99s quite a bit more compl= icated. So I=E2=80=99m > > sticking with this for now. > As I said, I think we're OK here. We can always revamp as we get > experience with the implementation -- I don't think any of the stuff > we're talking about is an ABI change, they're just implementation details= . > > > > > Sorry for all the delay on this. My progress has been (and still) > > blocked on supporting relaxation of TLSDESC in binutils (turns out you > > can=E2=80=99t run static binaries without relaxing it first). But that = doesn=E2=80=99t > > seem exactly easy to do either, because relaxation that involves GOT > > elimination isn=E2=80=99t something we have in the RISC-V backend. > Note that binutils is due for another release in the next month or two. > It'd certainly be helpful to have any issues there resolved in time for > that release. > > > > > I=E2=80=99ll try to send a new version of this patch and get this unblo= cked on > > GCC side first. > Sounds good. We can always guard its use behind a feature test for GAS > support. > > Jeff Agreed. Tatsuyuki, could you also add some tests? For example // end of https://maskray.me/blog/2021-02-14-all-about-thread-local-storage __thread int tls0; extern __thread int tls1; int foo() { return ++tls0 + ++tls1; } static __thread int tls2, tls3; int bar() { return ++tls2 + ++tls3; } I have used this to check rtld and linker behavior. I think we need some `scan-assembler`. To make it a runnable test, some assembler feature check may be needed. Perhaps Jeff can make some suggestion or contribute code! --=20 =E5=AE=8B=E6=96=B9=E7=9D=BF