From 59d1f202c03db9597af4a795560b8f6215a65b4b Mon Sep 17 00:00:00 2001 From: Sam James Date: Tue, 26 Mar 2024 20:08:39 +0000 Subject: sys-devel/gcc: backport fix for building e.g. dev-libs/icu Closes: https://bugs.gentoo.org/927657 Closes: https://bugs.gentoo.org/927814 Closes: https://bugs.gentoo.org/927815 Closes: https://bugs.gentoo.org/927853 Signed-off-by: Sam James --- .../files/gcc-14.0.1_pre20240324-PR114439.patch | 112 +++++++++++++++++++++ sys-devel/gcc/gcc-14.0.1_pre20240324-r1.ebuild | 67 ++++++++++++ sys-devel/gcc/gcc-14.0.1_pre20240324.ebuild | 66 ------------ 3 files changed, 179 insertions(+), 66 deletions(-) create mode 100644 sys-devel/gcc/files/gcc-14.0.1_pre20240324-PR114439.patch create mode 100644 sys-devel/gcc/gcc-14.0.1_pre20240324-r1.ebuild delete mode 100644 sys-devel/gcc/gcc-14.0.1_pre20240324.ebuild diff --git a/sys-devel/gcc/files/gcc-14.0.1_pre20240324-PR114439.patch b/sys-devel/gcc/files/gcc-14.0.1_pre20240324-PR114439.patch new file mode 100644 index 000000000000..2f92ab10cebf --- /dev/null +++ b/sys-devel/gcc/files/gcc-14.0.1_pre20240324-PR114439.patch @@ -0,0 +1,112 @@ +https://bugs.gentoo.org/927657 +https://gcc.gnu.org/PR114439 +https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=de0886d48032332d10e4acb5d15c8789b281b6fe + +From de0886d48032332d10e4acb5d15c8789b281b6fe Mon Sep 17 00:00:00 2001 +From: Marek Polacek +Date: Mon, 25 Mar 2024 15:32:20 -0400 +Subject: [PATCH] c++: broken direct-init with trailing array member [PR114439] + +can_init_array_with_p is wrongly saying that the init for 's' here: + + struct S { + int *list = arr; + int arr[]; + }; + + struct A { + A() {} + S s[2]{}; + }; + +is invalid. But as process_init_constructor_array says, for "non-constant +initialization of trailing elements with no explicit initializers" we use +a VEC_INIT_EXPR wrapped in a TARGET_EXPR, built in process_init_constructor. + +Unfortunately we didn't have a test for this scenario so I didn't +realize can_init_array_with_p must handle it. + + PR c++/114439 + +gcc/cp/ChangeLog: + + * init.cc (can_init_array_with_p): Return true for a VEC_INIT_EXPR + wrapped in a TARGET_EXPR. + +gcc/testsuite/ChangeLog: + + * g++.dg/init/array65.C: New test. +--- + gcc/cp/init.cc | 6 ++++- + gcc/testsuite/g++.dg/init/array65.C | 38 +++++++++++++++++++++++++++++ + 2 files changed, 43 insertions(+), 1 deletion(-) + create mode 100644 gcc/testsuite/g++.dg/init/array65.C + +diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc +index dbd37d47cbf..a93ce00800c 100644 +--- a/gcc/cp/init.cc ++++ b/gcc/cp/init.cc +@@ -950,12 +950,16 @@ can_init_array_with_p (tree type, tree init) + mem-initializers of a constructor. */ + if (DECL_DEFAULTED_FN (current_function_decl)) + return true; +- /* As an extension, we allow copying from a compound literal. */ + if (TREE_CODE (init) == TARGET_EXPR) + { + init = TARGET_EXPR_INITIAL (init); ++ /* As an extension, we allow copying from a compound literal. */ + if (TREE_CODE (init) == CONSTRUCTOR) + return CONSTRUCTOR_C99_COMPOUND_LITERAL (init); ++ /* VEC_INIT_EXPR is used for non-constant initialization of trailing ++ elements with no explicit initializers. */ ++ else if (TREE_CODE (init) == VEC_INIT_EXPR) ++ return true; + } + + return false; +diff --git a/gcc/testsuite/g++.dg/init/array65.C b/gcc/testsuite/g++.dg/init/array65.C +new file mode 100644 +index 00000000000..0b144f45a9d +--- /dev/null ++++ b/gcc/testsuite/g++.dg/init/array65.C +@@ -0,0 +1,38 @@ ++// PR c++/114439 ++// { dg-do compile { target c++11 } } ++ ++struct S { ++ int *list = arr; ++ __extension__ int arr[]; ++}; ++ ++struct R { ++ int *list = arr; ++ int arr[2]; ++}; ++ ++struct A { ++ A() {} ++ S s[2]{}; ++}; ++ ++struct A2 { ++ A2() {} ++ S s[2]{ {}, {} }; ++}; ++ ++struct B { ++ B() {} ++ R r[2]{}; ++}; ++ ++struct B2 { ++ B2() {} ++ R r[2]{ {}, {} }; ++}; ++ ++struct S1 { S1(); }; ++struct S2 { ++ S2() {} ++ S1 a[1] {}; ++}; +-- +2.39.3 diff --git a/sys-devel/gcc/gcc-14.0.1_pre20240324-r1.ebuild b/sys-devel/gcc/gcc-14.0.1_pre20240324-r1.ebuild new file mode 100644 index 000000000000..41416832f8b5 --- /dev/null +++ b/sys-devel/gcc/gcc-14.0.1_pre20240324-r1.ebuild @@ -0,0 +1,67 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +TOOLCHAIN_PATCH_DEV="sam" +PATCH_GCC_VER="14.0.0" +PATCH_VER="25" +MUSL_VER="1" +MUSL_GCC_VER="14.0.0" +PYTHON_COMPAT=( python3_{10..11} ) + +if [[ ${PV} == *.9999 ]] ; then + MY_PV_2=$(ver_cut 2) + MY_PV_3=1 + if [[ ${MY_PV_2} == 0 ]] ; then + MY_PV_2=0 + MY_PV_3=0 + else + MY_PV_2=$((${MY_PV_2} - 1)) + fi + + # e.g. 12.2.9999 -> 12.1.1 + TOOLCHAIN_GCC_PV=$(ver_cut 1).${MY_PV_2}.${MY_PV_3} +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 + +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 ~ia64 ~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="amd64? ( >=${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}"/${P}-PR114439.patch + eapply_user +} diff --git a/sys-devel/gcc/gcc-14.0.1_pre20240324.ebuild b/sys-devel/gcc/gcc-14.0.1_pre20240324.ebuild deleted file mode 100644 index e809e40f6564..000000000000 --- a/sys-devel/gcc/gcc-14.0.1_pre20240324.ebuild +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -TOOLCHAIN_PATCH_DEV="sam" -PATCH_GCC_VER="14.0.0" -PATCH_VER="25" -MUSL_VER="1" -MUSL_GCC_VER="14.0.0" -PYTHON_COMPAT=( python3_{10..11} ) - -if [[ ${PV} == *.9999 ]] ; then - MY_PV_2=$(ver_cut 2) - MY_PV_3=1 - if [[ ${MY_PV_2} == 0 ]] ; then - MY_PV_2=0 - MY_PV_3=0 - else - MY_PV_2=$((${MY_PV_2} - 1)) - fi - - # e.g. 12.2.9999 -> 12.1.1 - TOOLCHAIN_GCC_PV=$(ver_cut 1).${MY_PV_2}.${MY_PV_3} -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 - -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 ~ia64 ~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="amd64? ( >=${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_user -} -- cgit v1.2.3-65-gdbad