Skip to content

Commit

Permalink
Fix Android build with Go 1.23.0 or later (#1166)
Browse files Browse the repository at this point in the history
The `github.com/wlynxg/anet` library depends on the `//go:linkname`
linker feature [1]. However, since Go 1.23.0, the usage of
`//go:linkname` has been restricted [2]. And now it's necessary to
explicitly specify `-checklinkname=0` linker flag to use it.

[1]
https://github.com/wlynxg/anet/blob/main/README.md#how-to-build-with-go-1230-or-later
[2] https://tip.golang.org/doc/go1.23#linker

Resolves: #1165
  • Loading branch information
bobrofon authored Sep 29, 2024
1 parent 98a6fdb commit d6fd305
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions contrib/mobile/build
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set -ef
PKGSRC=${PKGSRC:-github.com/yggdrasil-network/yggdrasil-go/src/version}
PKGNAME=${PKGNAME:-$(sh contrib/semver/name.sh)}
PKGVER=${PKGVER:-$(sh contrib/semver/version.sh --bare)}
GOVER=$(go version | { read _ _ version _; echo ${version#go}; })

LDFLAGS="-X $PKGSRC.buildName=$PKGNAME -X $PKGSRC.buildVersion=$PKGVER"
ARGS="-v"
Expand All @@ -33,6 +34,15 @@ if [ ! $IOS ] && [ ! $ANDROID ]; then
exit 1
fi

ver_le() {
printf "$1\n$2\n" | sort -VC
}

if [ $ANDROID ] && ver_le 1.23.0 $GOVER ; then
# github.com/wlynxg/anet library relies on //go:linkname
LDFLAGS="$LDFLAGS -checklinkname=0"
fi

if [ $IOS ]; then
echo "Building framework for iOS"
go get golang.org/x/mobile/bind
Expand Down

0 comments on commit d6fd305

Please sign in to comment.