From owner-dev-commits-src-all@freebsd.org Thu Feb 18 21:07:38 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 618DC54EE47 for ; Thu, 18 Feb 2021 21:07:38 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DhS2y2544z3mZ6 for ; Thu, 18 Feb 2021 21:07:38 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wm1-f51.google.com with SMTP id a207so5167443wmd.1 for ; Thu, 18 Feb 2021 13:07:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=/cQpwSFRES7pw4ocCiU8c2XxEb7+U4c7MExltcMsJPM=; b=SWjpZ0JgJ5z1Pa26udSQwJkNjpt+srzL76aJSXzDLkjU8YxfTySJci6k3QDIj/Fxon MXxVhdMO2EsJktRAPg8xZi0vwYJnGL9STzfExqod4WQC+lO8DxbyYIQf93urnUlTSZKT hbGfubzVAzA34iPG87SJ9OXoAKqrym2Jldt4j+gDwrHC4MVEhEhRbaxHT/4f7oJog0eB UO6m7O17uzhH+h6tut97jnmj+NdHkbvYU0dq5yV+KDbyOtmbVlUftkBZbR7spaSmZIYM adIH4YMIkx/iJt2yQOeEISVF+SXIWS3OMQIBawI+oL0lRWQexV4lCNMSVr+Cg/qBUX3H q0aQ== X-Gm-Message-State: AOAM532M/HM3zQVDlx31nN1upFhunJDCFGWSrG6nNEcuhlJSchO/19uM C9InnpL2Q9RTFaDTZs8LtQoaTQ== X-Google-Smtp-Source: ABdhPJybkW8l/6SA/De/yt9aqZ7JDnPORvphPOetQVjzb6Qn9JcrPgVJOUWp+N9zUREzTqG7p2d4dQ== X-Received: by 2002:a05:600c:430a:: with SMTP id p10mr5187991wme.142.1613682456611; Thu, 18 Feb 2021 13:07:36 -0800 (PST) Received: from [192.168.149.251] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id y15sm10598778wrm.93.2021.02.18.13.07.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Feb 2021 13:07:36 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: git: 24fd63e0970f - main - mips: Don't set __NO_TLS to disable some uses of TLS. From: Jessica Clarke In-Reply-To: Date: Thu, 18 Feb 2021 21:07:34 +0000 Cc: John Baldwin , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <202102180035.11I0ZnL3070354@gitrepo.freebsd.org> <9687575c-dd7c-1496-850b-2018f4bca3da@FreeBSD.org> To: Konstantin Belousov X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4DhS2y2544z3mZ6 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Feb 2021 21:07:38 -0000 On 18 Feb 2021, at 20:52, Konstantin Belousov = wrote: > On Wed, Feb 17, 2021 at 04:48:22PM -0800, John Baldwin wrote: >> On 2/17/21 4:35 PM, John Baldwin wrote: >>> The branch main has been updated by jhb: >>>=20 >>> URL: = https://cgit.FreeBSD.org/src/commit/?id=3D24fd63e0970f91189dd2acde987bd2e4= c8c04a50 >>>=20 >>> commit 24fd63e0970f91189dd2acde987bd2e4c8c04a50 >>> Author: John Baldwin >>> AuthorDate: 2021-02-18 00:34:23 +0000 >>> Commit: John Baldwin >>> CommitDate: 2021-02-18 00:34:23 +0000 >>>=20 >>> mips: Don't set __NO_TLS to disable some uses of TLS. >>> __NO_TLS was originally added to disable use of _Thread in the = locale >>> code in libc in 82dd5016bd749d1d9e1531bd1703aebeecceab34. At = the time >>> libc did not support TLS on MIPS (I believe), but TLS support = was >>> added to libc (at least _set_tp.c) for MIPS about a month after >>> __NO_TLS was added, but __NO_TLS was still left around. >>> Reviewed by: imp >>> Sponsored by: DARPA >>> Differential Revision: https://reviews.freebsd.org/D28713 >>> --- >>> sys/sys/cdefs.h | 3 +-- >>> 1 file changed, 1 insertion(+), 2 deletions(-) >>>=20 >>> diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h >>> index 64f26480a2f5..ff18911f6acf 100644 >>> --- a/sys/sys/cdefs.h >>> +++ b/sys/sys/cdefs.h >>> @@ -768,8 +768,7 @@ >>> #endif >>> #endif /* __STDC_WANT_LIB_EXT1__ */ >>> -#if defined(__mips) || \ >>> - (defined(__powerpc64__) && (!defined(_CALL_ELF) || _CALL_ELF =3D=3D= 1)) >>> +#if defined(__powerpc64__) && (!defined(_CALL_ELF) || _CALL_ELF =3D=3D= 1) >>> #define __NO_TLS 1 >>> #endif >>=20 >> It would be really nice to kill __NO_TLS entirely. There is at least = one >> unconditional use of _Thread_local (sorry, should have used that = instead >> of _Thread above) in libc in stdlib/cxa_thread_atexit_impl.c, so it = seems >> highly unlikely that TLS is actually broken on any of our platforms = as the >> libc build would have been broken instead. >=20 > There is a difference between compile and runtime. The mentioned libc > use in cxa_thread_atexit_impl.c is to support some (I believe) rarely > used C++ feature of thread-local storage with destructors, so it might > be simply not observed often. OTOH, locale functions infect almost > everything string-related in libc, so the breakage would be quite > visible. It's also used in jemalloc for tsd_initialized which is a rather key variable, so if TLS is broken you won't get very far in userspace (source: I had to debug implementing it for CHERI-MIPS), well before you even think about getting to locale functions. > But, I wonder, what does CALL_ELF mean? Is it for old 64bit PowerPC = ABI, > that was abandoned with the switch to ELFv2? Yes, _CALL_ELF =3D=3D 2 for ELFv2. I highly doubt the defines were = needed for the ELFv1 ABI, but they're especially redundant now. Presumably David's original fixed commit[1] added powerpc64 to that list because TLS wasn't yet supported in LLVM; that happened later in 2012 and our wiki changed it to being implemented in December 2012[2]. So I suspect it should have been deleted 8 years ago. Jess [1] b0968176b3a821598a31de6698e01931d1417584 [2] = https://wiki.freebsd.org/action/diff/BuildingFreeBSDWithClang?action=3Ddif= f&rev1=3D340&rev2=3D341