gcc12: 12.2.0 -> 12.3.0

Added an ICE backport for `ccache` build failure.
This commit is contained in:
Sergei Trofimovich 2023-05-15 08:43:38 +01:00
parent 8d908a2ed4
commit c78434b2cd
2 changed files with 89 additions and 8 deletions

View File

@ -55,7 +55,7 @@ with lib;
with builtins;
let majorVersion = "12";
version = "${majorVersion}.2.0";
version = "${majorVersion}.3.0";
disableBootstrap = !stdenv.hostPlatform.isDarwin && !profiledCompiler;
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
@ -69,15 +69,19 @@ let majorVersion = "12";
../gcc-12-gfortran-driving.patch
../ppc-musl.patch
../install-info-files-serially.patch
# backport ICE fix on ccache code
./lambda-ICE-PR109241.patch
]
# We only apply this patch when building a native toolchain for aarch64-darwin, as it breaks building
# a foreign one: https://github.com/iains/gcc-12-branch/issues/18
++ optional (stdenv.isDarwin && stdenv.isAarch64 && buildPlatform == hostPlatform && hostPlatform == targetPlatform) (fetchpatch {
name = "gcc-12-darwin-aarch64-support.patch";
url = "https://github.com/Homebrew/formula-patches/raw/1d184289/gcc/gcc-12.2.0-arm.diff";
sha256 = "sha256-omclLslGi/2yCV4pNBMaIpPDMW3tcz/RXdupbNbeOHA=";
})
++ optional langD ../libphobos.patch
++ optionals (stdenv.isDarwin && stdenv.isAarch64 && buildPlatform == hostPlatform && hostPlatform == targetPlatform) [
(fetchurl {
name = "gcc-12-darwin-aarch64-support.patch";
url = "https://raw.githubusercontent.com/Homebrew/formula-patches/f1188b90d610e2ed170b22512ff7435ba5c891e2/gcc/gcc-12.3.0.diff";
sha256 = "sha256-naL5ZNiurqfDBiPSU8PTbTmLqj25B+vjjiqc4fAFgYs=";
})
] ++ optional langD ../libphobos.patch
# backport fixes to build gccgo with musl libc
++ optionals (langGo && stdenv.hostPlatform.isMusl) [
@ -206,7 +210,7 @@ lib.pipe (stdenv.mkDerivation ({
src = fetchurl {
url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "sha256-5UnPnPNZSgDie2WJ1DItcOByDN0hPzm+tBgeBpJiMP8=";
sha256 = "sha256-lJpdT5nnhkIak7Uysi/6tVeN5zITaZdbka7Jet/ajDs=";
};
inherit patches;

View File

@ -0,0 +1,77 @@
https://gcc.gnu.org/PR109241
Fix ICE on ccache.
From 396a4e76afec30d2461638f569cae18955eb4ad2 Mon Sep 17 00:00:00 2001
From: Jason Merrill <jason@redhat.com>
Date: Wed, 22 Mar 2023 16:11:47 -0400
Subject: [PATCH] c++: local class in nested generic lambda [PR109241]
In this testcase, the tree walk to look for bare parameter packs was
confused by finding a type with no TREE_BINFO. But it should be fine that
it's unset; we already checked for unexpanded packs at parse time.
I also tried doing the partial instantiation of the local class, which is
probably the long-term direction we want to go, but for stage 4 let's go
with this safer change.
PR c++/109241
gcc/cp/ChangeLog:
* pt.cc (find_parameter_packs_r): Handle null TREE_BINFO.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/lambda-generic-local-class2.C: New test.
---
gcc/cp/pt.cc | 12 ++++++++----
.../g++.dg/cpp1y/lambda-generic-local-class2.C | 13 +++++++++++++
2 files changed, 21 insertions(+), 4 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/cpp1y/lambda-generic-local-class2.C
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index c7f4a95a723..79bc9c014c8 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -4106,10 +4106,14 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data)
case TAG_DEFN:
t = TREE_TYPE (t);
if (CLASS_TYPE_P (t))
- /* Local class, need to look through the whole definition. */
- for (tree bb : BINFO_BASE_BINFOS (TYPE_BINFO (t)))
- cp_walk_tree (&BINFO_TYPE (bb), &find_parameter_packs_r,
- ppd, ppd->visited);
+ {
+ /* Local class, need to look through the whole definition.
+ TYPE_BINFO might be unset for a partial instantiation. */
+ if (TYPE_BINFO (t))
+ for (tree bb : BINFO_BASE_BINFOS (TYPE_BINFO (t)))
+ cp_walk_tree (&BINFO_TYPE (bb), &find_parameter_packs_r,
+ ppd, ppd->visited);
+ }
else
/* Enum, look at the values. */
for (tree l = TYPE_VALUES (t); l; l = TREE_CHAIN (l))
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-local-class2.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-local-class2.C
new file mode 100644
index 00000000000..83856de1f41
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-local-class2.C
@@ -0,0 +1,13 @@
+// PR c++/109241
+// { dg-do compile { target c++14 } }
+// { dg-options "" } no pedantic
+
+void g() {
+ [](auto) {
+ [](auto) {
+ ({
+ struct A {};
+ });
+ };
+ }(1);
+}
--
2.40.1