From 42a9b8323d61b2eed93f248f2158fbb2ced4f91d Mon Sep 17 00:00:00 2001 From: Matti Viljanen Date: Tue, 15 Oct 2024 15:42:39 +0300 Subject: [PATCH] compiler: correct condition for calling memclrHasPointers Without this patch it's impossible to use `gccgo` in bootstrapping Go. --- cross-aarch64-gcc.spec | 2 + cross-armv7hl-gcc.spec | 2 + cross-i486-gcc.spec | 2 + cross-x86_64-gcc.spec | 2 + gcc.spec | 2 + ...-condition-for-calling-memclrHasPoin.patch | 41 +++++++++++++++++++ 6 files changed, 51 insertions(+) create mode 100644 gcc10-compiler-correct-condition-for-calling-memclrHasPoin.patch diff --git a/cross-aarch64-gcc.spec b/cross-aarch64-gcc.spec index 0d26d31..3def5b1 100644 --- a/cross-aarch64-gcc.spec +++ b/cross-aarch64-gcc.spec @@ -190,6 +190,7 @@ Patch14: gcc10-pr96939-2.patch Patch15: gcc10-pr96939-3.patch Patch16: gcc10-reproducible-builds.patch Patch17: gcc10-reproducible-builds-buildid-for-checksum.patch +Patch18: gcc10-compiler-correct-condition-for-calling-memclrHasPoin.patch BuildRequires: binutils >= 2.31 BuildRequires: glibc-static @@ -569,6 +570,7 @@ not stable, so plugins must be rebuilt any time GCC is updated. %patch15 -p0 -b .pr96939-3~ %patch16 -p0 -b .reproducible-builds~ %patch17 -p1 -b .reproducible-builds-buildid-for-checksum~ +%patch18 -p1 -b .correct-condition-for-calling-memclrHasPointers~ echo 'Sailfish OS gcc %{version}-%{gcc_release}' > gcc/DEV-PHASE diff --git a/cross-armv7hl-gcc.spec b/cross-armv7hl-gcc.spec index 796d316..07ad091 100644 --- a/cross-armv7hl-gcc.spec +++ b/cross-armv7hl-gcc.spec @@ -190,6 +190,7 @@ Patch14: gcc10-pr96939-2.patch Patch15: gcc10-pr96939-3.patch Patch16: gcc10-reproducible-builds.patch Patch17: gcc10-reproducible-builds-buildid-for-checksum.patch +Patch18: gcc10-compiler-correct-condition-for-calling-memclrHasPoin.patch BuildRequires: binutils >= 2.31 BuildRequires: glibc-static @@ -569,6 +570,7 @@ not stable, so plugins must be rebuilt any time GCC is updated. %patch15 -p0 -b .pr96939-3~ %patch16 -p0 -b .reproducible-builds~ %patch17 -p1 -b .reproducible-builds-buildid-for-checksum~ +%patch18 -p1 -b .correct-condition-for-calling-memclrHasPointers~ echo 'Sailfish OS gcc %{version}-%{gcc_release}' > gcc/DEV-PHASE diff --git a/cross-i486-gcc.spec b/cross-i486-gcc.spec index 621ac25..5979387 100644 --- a/cross-i486-gcc.spec +++ b/cross-i486-gcc.spec @@ -190,6 +190,7 @@ Patch14: gcc10-pr96939-2.patch Patch15: gcc10-pr96939-3.patch Patch16: gcc10-reproducible-builds.patch Patch17: gcc10-reproducible-builds-buildid-for-checksum.patch +Patch18: gcc10-compiler-correct-condition-for-calling-memclrHasPoin.patch BuildRequires: binutils >= 2.31 BuildRequires: glibc-static @@ -569,6 +570,7 @@ not stable, so plugins must be rebuilt any time GCC is updated. %patch15 -p0 -b .pr96939-3~ %patch16 -p0 -b .reproducible-builds~ %patch17 -p1 -b .reproducible-builds-buildid-for-checksum~ +%patch18 -p1 -b .correct-condition-for-calling-memclrHasPointers~ echo 'Sailfish OS gcc %{version}-%{gcc_release}' > gcc/DEV-PHASE diff --git a/cross-x86_64-gcc.spec b/cross-x86_64-gcc.spec index cce8bd7..d72b108 100644 --- a/cross-x86_64-gcc.spec +++ b/cross-x86_64-gcc.spec @@ -190,6 +190,7 @@ Patch14: gcc10-pr96939-2.patch Patch15: gcc10-pr96939-3.patch Patch16: gcc10-reproducible-builds.patch Patch17: gcc10-reproducible-builds-buildid-for-checksum.patch +Patch18: gcc10-compiler-correct-condition-for-calling-memclrHasPoin.patch BuildRequires: binutils >= 2.31 BuildRequires: glibc-static @@ -569,6 +570,7 @@ not stable, so plugins must be rebuilt any time GCC is updated. %patch15 -p0 -b .pr96939-3~ %patch16 -p0 -b .reproducible-builds~ %patch17 -p1 -b .reproducible-builds-buildid-for-checksum~ +%patch18 -p1 -b .correct-condition-for-calling-memclrHasPointers~ echo 'Sailfish OS gcc %{version}-%{gcc_release}' > gcc/DEV-PHASE diff --git a/gcc.spec b/gcc.spec index 3f5f4f8..187bcb5 100644 --- a/gcc.spec +++ b/gcc.spec @@ -189,6 +189,7 @@ Patch14: gcc10-pr96939-2.patch Patch15: gcc10-pr96939-3.patch Patch16: gcc10-reproducible-builds.patch Patch17: gcc10-reproducible-builds-buildid-for-checksum.patch +Patch18: gcc10-compiler-correct-condition-for-calling-memclrHasPoin.patch BuildRequires: binutils >= 2.31 BuildRequires: glibc-static @@ -568,6 +569,7 @@ not stable, so plugins must be rebuilt any time GCC is updated. %patch15 -p0 -b .pr96939-3~ %patch16 -p0 -b .reproducible-builds~ %patch17 -p1 -b .reproducible-builds-buildid-for-checksum~ +%patch18 -p1 -b .correct-condition-for-calling-memclrHasPointers~ echo 'Sailfish OS gcc %{version}-%{gcc_release}' > gcc/DEV-PHASE diff --git a/gcc10-compiler-correct-condition-for-calling-memclrHasPoin.patch b/gcc10-compiler-correct-condition-for-calling-memclrHasPoin.patch new file mode 100644 index 0000000..d4d4ff4 --- /dev/null +++ b/gcc10-compiler-correct-condition-for-calling-memclrHasPoin.patch @@ -0,0 +1,41 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Sat, 21 Aug 2021 12:42:19 -0700 +Subject: [PATCH] compiler: correct condition for calling memclrHasPointers + +When compiling append(s, make([]typ, ln)...), where typ has a pointer, +and the append fits within the existing capacity of s, the condition +used to clear out the new elements was reversed. + +Fixes golang/go#47771 + +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/344189 + +--- + gcc/go/gofrontend/MERGE | 2 +- + gcc/go/gofrontend/expressions.cc | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE +index e425f15..ff41af7 100644 +--- a/gcc/go/gofrontend/MERGE ++++ b/gcc/go/gofrontend/MERGE +@@ -1,4 +1,4 @@ +-823c91088bc6ac606362fc34b2880ce0de1624ad ++21b30eddc59d92a07264c3b21eb032d6c303d16f + + The first line of this file holds the git revision number of the last + merge done from the gofrontend repository. +diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc +index 8f59b18..f27375d 100644 +--- a/gcc/go/gofrontend/expressions.cc ++++ b/gcc/go/gofrontend/expressions.cc +@@ -9075,7 +9075,7 @@ Builtin_call_expression::flatten_append(Gogo* gogo, Named_object* function, + ref2 = Expression::make_cast(uint_type, ref2, loc); + cond = Expression::make_binary(OPERATOR_GT, ref, ref2, loc); + zero = Expression::make_integer_ul(0, int_type, loc); +- call = Expression::make_conditional(cond, call, zero, loc); ++ call = Expression::make_conditional(cond, zero, call, loc); + } + } + else