Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ jobs:
git clone https://go.googlesource.com/go goroot
cd goroot
git checkout go1.25.3
cp ../wallet-sdk/cmd/wallet-sdk-gomobile/gopatches/* ./
git revert 3560cf0afb3c29300a6c88ccd98256949ca7a6f6
git apply ../wallet-sdk/cmd/wallet-sdk-gomobile/gopatches/01-cgo-alignment-fix-go1.25.3.patch
cd src && ./make.bash
- name: Derive the new version
run: |
Expand Down Expand Up @@ -99,8 +98,7 @@ jobs:
git clone https://go.googlesource.com/go goroot
cd goroot
git checkout go1.25.3
cp ../wallet-sdk/cmd/wallet-sdk-gomobile/gopatches/* ./
git revert 3560cf0afb3c29300a6c88ccd98256949ca7a6f6
git apply ../wallet-sdk/cmd/wallet-sdk-gomobile/gopatches/01-cgo-alignment-fix-go1.25.3.patch
cd src && ./make.bash
- name: Derive the new version
run: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Subject: [PATCH] cmd/cgo: fix unaligned arguments typedmemmove crash on iOS (go1.25.3)

---
src/cmd/cgo/out.go | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go
index 10870b7c85..3027217b3f 100644
--- a/src/cmd/cgo/out.go
+++ b/src/cmd/cgo/out.go
@@ -949,6 +949,8 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) {
fmt.Fprintf(gotype, "struct {\n")
off := int64(0)
npad := 0
+ // the align is at least 1 (for char)
+ maxAlign := int64(1)
argField := func(typ ast.Expr, namePat string, args ...interface{}) {
name := fmt.Sprintf(namePat, args...)
t := p.cgoType(typ)
@@ -963,6 +965,11 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) {
noSourceConf.Fprint(gotype, fset, typ)
fmt.Fprintf(gotype, "\n")
off += t.Size
+ // keep track of the maximum alignment among all fields
+ // so that we can align the struct correctly
+ if t.Align > maxAlign {
+ maxAlign = t.Align
+ }
}
if fn.Recv != nil {
argField(fn.Recv.List[0].Type, "recv")
@@ -1051,7 +1058,7 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) {
// string.h for memset, and is also robust to C++
// types with constructors. Both GCC and LLVM optimize
// this into just zeroing _cgo_a.
- fmt.Fprintf(fgcc, "\ttypedef %s %v _cgo_argtype;\n", ctype.String(), p.packedAttribute())
+ fmt.Fprintf(fgcc, "\ttypedef %s %v __attribute__((aligned(%d))) _cgo_argtype;\n", ctype.String(), p.packedAttribute(), maxAlign)
fmt.Fprintf(fgcc, "\tstatic _cgo_argtype _cgo_zero;\n")
fmt.Fprintf(fgcc, "\t_cgo_argtype _cgo_a = _cgo_zero;\n")
if gccResult != "void" && (len(fntype.Results.List) > 1 || len(fntype.Results.List[0].Names) > 1) {
--
2.39.0

This file was deleted.