Skip to content

Commit

Permalink
compiler: correct condition for calling memclrHasPointers
Browse files Browse the repository at this point in the history
Without this patch it's impossible to use `gccgo` in bootstrapping Go.
  • Loading branch information
direc85 committed Oct 15, 2024
1 parent e8f83b9 commit 42a9b83
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cross-aarch64-gcc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cross-armv7hl-gcc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cross-i486-gcc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cross-x86_64-gcc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions gcc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
41 changes: 41 additions & 0 deletions gcc10-compiler-correct-condition-for-calling-memclrHasPoin.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor <[email protected]>
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

0 comments on commit 42a9b83

Please sign in to comment.