Skip to content

Commit

Permalink
feat(sdk): patched GO to fix iOS missaligment bug. (#765)
Browse files Browse the repository at this point in the history
feat(sdk): patched GO to fix iOS missaligment bug

Signed-off-by: Volodymyr Kubiv <[email protected]>
  • Loading branch information
vkubiv authored Apr 18, 2024
1 parent b65287e commit 6b849dd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ jobs:
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Build Custom GO
run: |
cd ..
git clone https://go.googlesource.com/go goroot
cd goroot
git checkout go1.22.2
cp ../wallet-sdk/cmd/wallet-sdk-gomobile/gopatches/* ./
git apply cmd_cgo__fix_unaligned_arguments_typedmemmove_crash_on_iOS.patch
cd src && ./all.bash
- name: Derive the new version
run: |
echo "new version"
Expand All @@ -94,14 +103,15 @@ jobs:
echo ${{ github.workspace }}
echo ${GOPATH}
echo ${GOROOT}
export PATH=$PATH:$GOPATH/bin
export PATH=$GOPATH/bin:$PATH
echo $PATH
which go
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
NEW_VERSION=$NEW_VER GIT_REV=$(git rev-parse HEAD) BUILD_TIME=$(date) make generate-ios-bindings
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOPATH: /Users/runner/work/wallet-sdk/go
GOPATH: /Users/runner/work/wallet-sdk/goroot
- name: Upload iOS bindings to GitHub Actions Artifacts
uses: actions/upload-artifact@v3
if: always()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Subject: [PATCH] cmd/cgo: fix unaligned arguments typedmemmove crash on iOS
---
Index: src/cmd/cgo/out.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go
--- a/src/cmd/cgo/out.go (revision dddf0ae40fa0c1223aba191d73a44425a08e1035)
+++ b/src/cmd/cgo/out.go (date 1712322519672)
@@ -1029,7 +1029,7 @@
// 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, p.packedAttribute())
+ fmt.Fprintf(fgcc, "\ttypedef %s %v __attribute__((aligned(%d))) _cgo_argtype;\n", ctype, p.packedAttribute(), p.PtrSize)
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) {

0 comments on commit 6b849dd

Please sign in to comment.