From ce656189865ac13055c7cfdbfd886f66339eb9b3 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 1 Jul 2021 18:24:24 +0000 Subject: [PATCH] gcc: backport patch from GCC 11.2 This fixes a compiler bug which causes Firefox builds to fail. --- core/gcc/build | 2 + core/gcc/checksums | 1 + core/gcc/patches/firefox-fix.patch | 71 ++++++++++++++++++++++++++++++ core/gcc/sources | 1 + core/gcc/version | 2 +- 5 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 core/gcc/patches/firefox-fix.patch diff --git a/core/gcc/build b/core/gcc/build index cf50ef7d..8b249d24 100755 --- a/core/gcc/build +++ b/core/gcc/build @@ -1,5 +1,7 @@ #!/bin/sh -e +patch -p1 < firefox-fix.patch + # Make sure gmp is built with generic options. cp gcc/gmp/configfsf.guess gcc/gmp/config.guess cp gcc/gmp/configfsf.sub gcc/gmp/config.sub diff --git a/core/gcc/checksums b/core/gcc/checksums index d4cf3bb1..5f003f52 100644 --- a/core/gcc/checksums +++ b/core/gcc/checksums @@ -3,3 +3,4 @@ 1d3be708604eae0e42d578ba93b390c2a145f17743a744d8f3f8c2ad5855a38a 6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e 765614b3396d70bca3fa0ae4a813632486c6dca320e2bd13c8c39dca52be4a4c +5a8faae7044e1e22de9b422ecdc7a286602258bad5f14edee9999a82180207e2 diff --git a/core/gcc/patches/firefox-fix.patch b/core/gcc/patches/firefox-fix.patch new file mode 100644 index 00000000..afeb9679 --- /dev/null +++ b/core/gcc/patches/firefox-fix.patch @@ -0,0 +1,71 @@ +From 6384e940a6db379b0524465cf6cbbd0996b48485 Mon Sep 17 00:00:00 2001 +From: Jason Merrill +Date: Tue, 18 May 2021 12:06:36 -0400 +Subject: [PATCH] c++: "perfect" implicitly deleted move [PR100644] + +Here we were ignoring the template constructor because the implicit move +constructor had all perfect conversions. But CWG1402 says that an +implicitly deleted move constructor is ignored by overload resolution; we +implement that instead by preferring any other candidate in joust, to get +better diagnostics, but that means we need to handle that case here as well. + +gcc/cp/ChangeLog: + + PR c++/100644 + * call.c (perfect_candidate_p): An implicitly deleted move + is not perfect. + +gcc/testsuite/ChangeLog: + + * g++.dg/cpp0x/implicit-delete1.C: New test. +--- + gcc/cp/call.c | 5 +++++ + gcc/testsuite/g++.dg/cpp0x/implicit-delete1.C | 20 +++++++++++++++++++ + 2 files changed, 25 insertions(+) + create mode 100644 gcc/testsuite/g++.dg/cpp0x/implicit-delete1.C + +diff --git a/gcc/cp/call.c b/gcc/cp/call.c +index 678e120a165..d0d55fcbb0b 100644 +--- a/gcc/gcc/cp/call.c ++++ b/gcc/gcc/cp/call.c +@@ -5892,6 +5892,11 @@ perfect_candidate_p (z_candidate *cand) + { + if (cand->viable < 1) + return false; ++ /* CWG1402 makes an implicitly deleted move op worse than other ++ candidates. */ ++ if (DECL_DELETED_FN (cand->fn) && DECL_DEFAULTED_FN (cand->fn) ++ && move_fn_p (cand->fn)) ++ return false; + int len = cand->num_convs; + for (int i = 0; i < len; ++i) + if (!perfect_conversion_p (cand->convs[i])) +diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit-delete1.C b/gcc/testsuite/g++.dg/cpp0x/implicit-delete1.C +new file mode 100644 +index 00000000000..6dcced4fb2d +--- /dev/null ++++ b/gcc/gcc/testsuite/g++.dg/cpp0x/implicit-delete1.C +@@ -0,0 +1,20 @@ ++// PR c++/100644 ++// { dg-do compile { target c++11 } } ++ ++struct NonMovable { ++ NonMovable(NonMovable&&) = delete; ++}; ++ ++template ++struct Maybe { ++ NonMovable mMember; ++ ++ template ++ Maybe(Maybe&&); ++}; ++ ++void foo(Maybe); ++ ++void unlucky(Maybe&& x) { ++ Maybe var{(Maybe&&)x}; ++} +-- +2.27.0 + diff --git a/core/gcc/sources b/core/gcc/sources index 2a087c8a..9b2d054f 100644 --- a/core/gcc/sources +++ b/core/gcc/sources @@ -3,3 +3,4 @@ https://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz gcc/gmp https://ftp.gnu.org/gnu/mpfr/mpfr-4.0.2.tar.xz gcc/mpfr https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz gcc/mpc files/c99 +patches/firefox-fix.patch diff --git a/core/gcc/version b/core/gcc/version index ec1ee9a6..f065194e 100644 --- a/core/gcc/version +++ b/core/gcc/version @@ -1 +1 @@ -11.1.0 1 +11.1.0 2