commit:     da5884453ed61142be545b852b79b3d507c89569
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Jul  8 18:36:25 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jul  8 18:44:35 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=da588445

sys-devel/gcc: backport 2 fixes to last 16 snapshot (Qt vs PTA; Clang vs 
<algorithm>)

Backport two fixes to 16.0.0_p20250706:
* Fix Qt vs PTA (bug #956308, PR120358). Thanks to Kacper Słomiński,
  Alexander Monakov, and Holger Hoffstätte for their help on this.

* Fix <algorithm> being rejected by Clang (bug #959695 etc, PR120949).

Bug: https://bugs.gentoo.org/956308
Bug: https://gcc.gnu.org/PR120358
Bug: https://gcc.gnu.org/PR120949
Closes: https://bugs.gentoo.org/959695
Closes: https://bugs.gentoo.org/959697
Closes: https://bugs.gentoo.org/959700
Closes: https://bugs.gentoo.org/959704
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../gcc-16.0.0_p20250706-PR120358-qt-pta.patch     |  47 ++++++
 ...16.0.0_p20250706-PR120949-clang-algorithm.patch | 166 +++++++++++++++++++++
 sys-devel/gcc/gcc-16.0.0_p20250706-r1.ebuild       |  58 +++++++
 3 files changed, 271 insertions(+)

diff --git a/sys-devel/gcc/files/gcc-16.0.0_p20250706-PR120358-qt-pta.patch 
b/sys-devel/gcc/files/gcc-16.0.0_p20250706-PR120358-qt-pta.patch
new file mode 100644
index 000000000000..1a9c9747c4c5
--- /dev/null
+++ b/sys-devel/gcc/files/gcc-16.0.0_p20250706-PR120358-qt-pta.patch
@@ -0,0 +1,47 @@
+https://bugs.gentoo.org/956308
+https://gcc.gnu.org/PR120358
+https://gcc.gnu.org/cgit/gcc/commit/?id=aa5ae523e84a97bf3a582ea0fa73d959afa9b9c7
+
+From aa5ae523e84a97bf3a582ea0fa73d959afa9b9c7 Mon Sep 17 00:00:00 2001
+Message-ID: 
<aa5ae523e84a97bf3a582ea0fa73d959afa9b9c7.1751999489.git....@gentoo.org>
+From: Richard Biener <rguent...@suse.de>
+Date: Mon, 7 Jul 2025 15:13:38 +0200
+Subject: [PATCH] tree-optimization/120358 - bogus PTA with structure access
+
+When we compute the constraint for something like
+MEM[(const struct QStringView &)&tok2 + 32] we go and compute
+what (const struct QStringView &)&tok2 + 32 points to and then
+add subvariables to its dereference that possibly fall in the
+range of the access according to the original refs size.  In
+doing that we disregarded that the subvariable the starting
+address points to might not be aligned to it and thus the
+access might start at any point within that variable.  The following
+conservatively adjusts the pruning of adjacent sub-variables to
+honor this.
+
+       PR tree-optimization/120358
+       * tree-ssa-structalias.cc (get_constraint_for_1): Adjust
+       pruning of sub-variables according to the imprecise
+       known start offset.
+---
+ gcc/tree-ssa-structalias.cc | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc
+index deca44ae0bf3..0215243d5be9 100644
+--- a/gcc/tree-ssa-structalias.cc
++++ b/gcc/tree-ssa-structalias.cc
+@@ -3690,7 +3690,10 @@ get_constraint_for_1 (tree t, vec<ce_s> *results, bool 
address_p,
+                   size = -1;
+                 for (; curr; curr = vi_next (curr))
+                   {
+-                    if (curr->offset - vi->offset < size)
++                    /* The start of the access might happen anywhere
++                       within vi, so conservatively assume it was
++                       at its end.  */
++                    if (curr->offset - (vi->offset + vi->size - 1) < size)
+                       {
+                         cs.var = curr->id;
+                         results->safe_push (cs);
+-- 
+2.50.0

diff --git 
a/sys-devel/gcc/files/gcc-16.0.0_p20250706-PR120949-clang-algorithm.patch 
b/sys-devel/gcc/files/gcc-16.0.0_p20250706-PR120949-clang-algorithm.patch
new file mode 100644
index 000000000000..4d1ee50d801a
--- /dev/null
+++ b/sys-devel/gcc/files/gcc-16.0.0_p20250706-PR120949-clang-algorithm.patch
@@ -0,0 +1,166 @@
+https://gcc.gnu.org/PR120949
+https://bugs.gentoo.org/959695
+https://bugs.gentoo.org/959697
+https://bugs.gentoo.org/959700
+https://bugs.gentoo.org/959704
+
+From ed912b1ee5ad0f241f968d5fd1a54a7e9e0e20dd Mon Sep 17 00:00:00 2001
+Message-ID: 
<ed912b1ee5ad0f241f968d5fd1a54a7e9e0e20dd.1751999555.git....@gentoo.org>
+From: Jonathan Wakely <jwak...@redhat.com>
+Date: Fri, 4 Jul 2025 21:19:52 +0100
+Subject: [PATCH] libstdc++: Fix attribute order on __normal_iterator friends
+ [PR120949]
+
+In r16-1911-g6596f5ab746533 I claimed to have reordered some attributes
+for compatibility with Clang, but it looks like I got the Clang
+restriction backwards and put them all in the wrong order. Clang trunk
+accepts either order (probably since the llvm/llvm-project#133107 fix)
+but released versions still require a particular order.
+
+There were also some cases where the attributes were after the friend
+keyword, which Clang trunk still rejects.
+
+libstdc++-v3/ChangeLog:
+
+       PR libstdc++/120949
+       * include/bits/stl_iterator.h (__normal_iterator): Fix order of
+       always_inline and nodiscard attributes for Clang compatibility.
+---
+ libstdc++-v3/include/bits/stl_iterator.h | 30 +++++++++++++-----------
+ 1 file changed, 16 insertions(+), 14 deletions(-)
+
+diff --git a/libstdc++-v3/include/bits/stl_iterator.h 
b/libstdc++-v3/include/bits/stl_iterator.h
+index a7188f46f6db..75e794f6c020 100644
+--- a/libstdc++-v3/include/bits/stl_iterator.h
++++ b/libstdc++-v3/include/bits/stl_iterator.h
+@@ -1211,7 +1211,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+ #else
+        // Forward iterator requirements
+       template<typename _Iter>
+-      __attribute__((__always_inline__)) _GLIBCXX_NODISCARD
++      _GLIBCXX_NODISCARD __attribute__((__always_inline__))
+       friend
+       _GLIBCXX_CONSTEXPR
+       bool
+@@ -1220,7 +1220,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+       _GLIBCXX_NOEXCEPT
+       { return __lhs.base() == __rhs.base(); }
+ 
+-      __attribute__((__always_inline__)) _GLIBCXX_NODISCARD
++      _GLIBCXX_NODISCARD __attribute__((__always_inline__))
+       friend
+       _GLIBCXX_CONSTEXPR
+       bool
+@@ -1229,7 +1229,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+       { return __lhs.base() == __rhs.base(); }
+ 
+       template<typename _Iter>
+-      __attribute__((__always_inline__)) _GLIBCXX_NODISCARD
++      _GLIBCXX_NODISCARD __attribute__((__always_inline__))
+       friend
+       _GLIBCXX_CONSTEXPR
+       bool
+@@ -1238,7 +1238,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+       _GLIBCXX_NOEXCEPT
+       { return __lhs.base() != __rhs.base(); }
+ 
+-      __attribute__((__always_inline__)) _GLIBCXX_NODISCARD
++      _GLIBCXX_NODISCARD __attribute__((__always_inline__))
+       friend
+       _GLIBCXX_CONSTEXPR
+       bool
+@@ -1248,15 +1248,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+ 
+       // Random access iterator requirements
+       template<typename _Iter>
++      _GLIBCXX_NODISCARD __attribute__((__always_inline__))
+       friend
+-      __attribute__((__always_inline__)) _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
++      _GLIBCXX_CONSTEXPR
+       inline bool
+       operator<(const __normal_iterator& __lhs,
+                 const __normal_iterator<_Iter, _Container>& __rhs)
+       _GLIBCXX_NOEXCEPT
+       { return __lhs.base() < __rhs.base(); }
+ 
+-      __attribute__((__always_inline__)) _GLIBCXX_NODISCARD
++      _GLIBCXX_NODISCARD __attribute__((__always_inline__))
+       friend
+       _GLIBCXX20_CONSTEXPR
+       bool
+@@ -1265,15 +1266,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+       { return __lhs.base() < __rhs.base(); }
+ 
+       template<typename _Iter>
++      _GLIBCXX_NODISCARD __attribute__((__always_inline__))
+       friend
+-      __attribute__((__always_inline__)) _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
++      _GLIBCXX_CONSTEXPR
+       bool
+       operator>(const __normal_iterator& __lhs,
+                 const __normal_iterator<_Iter, _Container>& __rhs)
+       _GLIBCXX_NOEXCEPT
+       { return __lhs.base() > __rhs.base(); }
+ 
+-      __attribute__((__always_inline__)) _GLIBCXX_NODISCARD
++      _GLIBCXX_NODISCARD __attribute__((__always_inline__))
+       friend
+       _GLIBCXX_CONSTEXPR
+       bool
+@@ -1282,7 +1284,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+       { return __lhs.base() > __rhs.base(); }
+ 
+       template<typename _Iter>
+-      __attribute__((__always_inline__)) _GLIBCXX_NODISCARD
++      _GLIBCXX_NODISCARD __attribute__((__always_inline__))
+       friend
+       _GLIBCXX_CONSTEXPR
+       bool
+@@ -1291,7 +1293,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+       _GLIBCXX_NOEXCEPT
+       { return __lhs.base() <= __rhs.base(); }
+ 
+-      __attribute__((__always_inline__)) _GLIBCXX_NODISCARD
++      _GLIBCXX_NODISCARD __attribute__((__always_inline__))
+       friend
+       _GLIBCXX_CONSTEXPR
+       bool
+@@ -1300,7 +1302,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+       { return __lhs.base() <= __rhs.base(); }
+ 
+       template<typename _Iter>
+-      __attribute__((__always_inline__)) _GLIBCXX_NODISCARD
++      _GLIBCXX_NODISCARD __attribute__((__always_inline__))
+       friend
+       _GLIBCXX_CONSTEXPR
+       bool
+@@ -1309,7 +1311,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+       _GLIBCXX_NOEXCEPT
+       { return __lhs.base() >= __rhs.base(); }
+ 
+-      __attribute__((__always_inline__)) _GLIBCXX_NODISCARD
++      _GLIBCXX_NODISCARD __attribute__((__always_inline__))
+       friend
+       _GLIBCXX_CONSTEXPR
+       bool
+@@ -1341,7 +1343,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+ #endif
+       { return __lhs.base() - __rhs.base(); }
+ 
+-      __attribute__((__always_inline__)) _GLIBCXX_NODISCARD
++      _GLIBCXX_NODISCARD __attribute__((__always_inline__))
+       friend
+       _GLIBCXX_CONSTEXPR
+       difference_type
+@@ -1349,7 +1351,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+       _GLIBCXX_NOEXCEPT
+       { return __lhs.base() - __rhs.base(); }
+ 
+-      __attribute__((__always_inline__)) _GLIBCXX_NODISCARD
++      _GLIBCXX_NODISCARD __attribute__((__always_inline__))
+       friend
+       _GLIBCXX_CONSTEXPR
+       __normal_iterator
+-- 
+2.50.0
+

diff --git a/sys-devel/gcc/gcc-16.0.0_p20250706-r1.ebuild 
b/sys-devel/gcc/gcc-16.0.0_p20250706-r1.ebuild
new file mode 100644
index 000000000000..6f127147eb67
--- /dev/null
+++ b/sys-devel/gcc/gcc-16.0.0_p20250706-r1.ebuild
@@ -0,0 +1,58 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+# Maintenance notes and explanations of GCC handling are on the wiki:
+# https://wiki.gentoo.org/wiki/Project:Toolchain/sys-devel/gcc
+
+TOOLCHAIN_PATCH_DEV="sam"
+TOOLCHAIN_HAS_TESTS=1
+PATCH_GCC_VER="16.0.0"
+PATCH_VER="5"
+MUSL_VER="1"
+MUSL_GCC_VER="16.0.0"
+PYTHON_COMPAT=( python3_{10..14} )
+
+if [[ -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
+
+if tc_is_live ; then
+       # Needs to be after inherit (for now?), bug #830908
+       EGIT_BRANCH=master
+elif [[ -z ${TOOLCHAIN_USE_GIT_PATCHES} ]] ; then
+       # Don't keyword live ebuilds
+       #KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~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}"
+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}"/${P}-PR120358-qt-pta.patch
+       eapply "${FILESDIR}"/${P}-PR120949-clang-algorithm.patch
+       eapply_user
+}

Reply via email to