From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 6155A15ACFC for ; Wed, 3 May 2023 12:32:15 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9C856E1078; Wed, 3 May 2023 12:32:14 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 6399CE1078 for ; Wed, 3 May 2023 12:32:14 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 53AD3341838 for ; Wed, 3 May 2023 12:32:13 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 9C080990 for ; Wed, 3 May 2023 12:32:11 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1683117064.1e10614cf5b563340143230bae47c10c45300196.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/gcc/, sys-devel/gcc/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: sys-devel/gcc/files/gcc-13-PR109703-unreachable.patch sys-devel/gcc/gcc-13.1.1_p20230429-r1.ebuild X-VCS-Directories: sys-devel/gcc/files/ sys-devel/gcc/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 1e10614cf5b563340143230bae47c10c45300196 X-VCS-Branch: master Date: Wed, 3 May 2023 12:32:11 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 360d704b-0e06-4416-81bd-1f439d14099d X-Archives-Hash: a27471cde6e5a5fb6226d35de046beb4 commit: 1e10614cf5b563340143230bae47c10c45300196 Author: Sam James gentoo org> AuthorDate: Wed May 3 12:31:04 2023 +0000 Commit: Sam James gentoo org> CommitDate: Wed May 3 12:31:04 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1e10614c sys-devel/gcc: backport libstdc++ UB fix for 13 May keyword this version later or may wait until next snapshot in a few days, we'll see. Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109703 Signed-off-by: Sam James gentoo.org> .../gcc/files/gcc-13-PR109703-unreachable.patch | 54 +++++++++++++++++++ sys-devel/gcc/gcc-13.1.1_p20230429-r1.ebuild | 63 ++++++++++++++++++++++ 2 files changed, 117 insertions(+) diff --git a/sys-devel/gcc/files/gcc-13-PR109703-unreachable.patch b/sys-devel/gcc/files/gcc-13-PR109703-unreachable.patch new file mode 100644 index 000000000000..f7c7c9f60a70 --- /dev/null +++ b/sys-devel/gcc/files/gcc-13-PR109703-unreachable.patch @@ -0,0 +1,54 @@ +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109703 + +From d50f2599d7b23bdba05a9102645d082ed9bcb05f Mon Sep 17 00:00:00 2001 +From: Kefu Chai +Date: Mon, 1 May 2023 21:24:26 +0100 +Subject: [PATCH] libstdc++: Set _M_string_length before calling _M_dispose() + [PR109703] + +This always sets _M_string_length in the constructor for ranges of input +iterators, such as stream iterators. + +We copy from the source range to the local buffer, and then repeatedly +reallocate a larger one if necessary. When disposing the old buffer, +_M_is_local() is used to tell if the buffer is the local one or not (and +so must be deallocated). In addition to comparing the buffer address +with the local buffer, _M_is_local() has an optimization hint so that +the compiler knows that for a string using the local buffer, there is an +invariant that _M_string_length <= _S_local_capacity (added for PR109299 +via r13-6915-gbf78b43873b0b7). But we failed to set _M_string_length in +the constructor taking a pair of iterators, so the invariant might not +hold, and __builtin_unreachable() is reached. This causes UBsan errors, +and potentially misoptimization. + +To ensure the invariant holds, _M_string_length is initialized to zero +before doing anything else, so that _M_is_local() doesn't see an +uninitialized value. + +This issue only surfaces when constructing a string with a range of +input iterator, and the uninitialized _M_string_length happens to be +greater than _S_local_capacity, i.e., 15 for the std::string +specialization. + +libstdc++-v3/ChangeLog: + + PR libstdc++/109703 + * include/bits/basic_string.h (basic_string(Iter, Iter, Alloc)): + Initialize _M_string_length. + +Signed-off-by: Kefu Chai +Co-authored-by: Jonathan Wakely +(cherry picked from commit cbf6c7a1d16490a1e63e9a5ce00e9a5c44c4c2f2) +--- a/libstdc++-v3/include/bits/basic_string.h ++++ b/libstdc++-v3/include/bits/basic_string.h +@@ -760,7 +760,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 + _GLIBCXX20_CONSTEXPR + basic_string(_InputIterator __beg, _InputIterator __end, + const _Alloc& __a = _Alloc()) +- : _M_dataplus(_M_local_data(), __a) ++ : _M_dataplus(_M_local_data(), __a), _M_string_length(0) + { + #if __cplusplus >= 201103L + _M_construct(__beg, __end, std::__iterator_category(__beg)); +-- +2.31.1 diff --git a/sys-devel/gcc/gcc-13.1.1_p20230429-r1.ebuild b/sys-devel/gcc/gcc-13.1.1_p20230429-r1.ebuild new file mode 100644 index 000000000000..9aa2b8645de1 --- /dev/null +++ b/sys-devel/gcc/gcc-13.1.1_p20230429-r1.ebuild @@ -0,0 +1,63 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +TOOLCHAIN_PATCH_DEV="sam" +PATCH_VER="2" +PATCH_GCC_VER="13.2.0" +MUSL_VER="1" +MUSL_GCC_VER="13.2.0" + +if [[ $(ver_cut 3) == 9999 ]] ; then + MY_PV_2=$(ver_cut 2) + if [[ ${MY_PV_2} == 0 ]] ; then + MY_PV_2=0 + else + MY_PV_2=$(($(ver_cut 2) - 1)) + fi + + # e.g. 12.2.9999 -> 12.1.1 + TOOLCHAIN_GCC_PV=$(ver_cut 1).${MY_PV_2}.$(($(ver_cut 3) - 9998)) +elif [[ -n ${TOOLCHAIN_GCC_RC} ]] ; then + # Cheesy hack for RCs + MY_PV=$(ver_cut 1).$((($(ver_cut 2) + 1))).$((($(ver_cut 3) - 1)))-RC-$(ver_cut 5) + MY_P=${PN}-${MY_PV} + GCC_TARBALL_SRC_URI="mirror://gcc/snapshots/${MY_PV}/${MY_P}.tar.xz" + TOOLCHAIN_SET_S=no + S="${WORKDIR}"/${MY_P} +fi + +inherit toolchain + +# Needs to be after inherit (for now?), bug #830908 +EGIT_BRANCH=releases/gcc-$(ver_cut 1) + +# Don't keyword live ebuilds +#if ! tc_is_live && [[ -z ${TOOLCHAIN_USE_GIT_PATCHES} ]] ; then +# KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" +#fi + +if [[ ${CATEGORY} != cross-* ]] ; then + # Technically only if USE=hardened *too* right now, but no point in complicating it further. + # If GCC is enabling CET by default, we need glibc to be built with support for it. + # bug #830454 + RDEPEND="elibc_glibc? ( sys-libs/glibc[cet(-)?] )" + DEPEND="${RDEPEND}" + BDEPEND=">=${CATEGORY}/binutils-2.30[cet(-)?]" +fi + +src_prepare() { + local p upstreamed_patches=( + # add them here + ) + for p in "${upstreamed_patches[@]}"; do + rm -v "${WORKDIR}/patch/${p}" || die + done + + toolchain_src_prepare + + eapply "${FILESDIR}"/${PN}-13-fix-cross-fixincludes.patch + eapply "${FILESDIR}"/${PN}-13-PR109703-unreachable.patch + eapply_user +}