Skip to content

Commit d6fd305

Browse files
authored
Fix Android build with Go 1.23.0 or later (#1166)
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
1 parent 98a6fdb commit d6fd305

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

contrib/mobile/build

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set -ef
77
PKGSRC=${PKGSRC:-github.com/yggdrasil-network/yggdrasil-go/src/version}
88
PKGNAME=${PKGNAME:-$(sh contrib/semver/name.sh)}
99
PKGVER=${PKGVER:-$(sh contrib/semver/version.sh --bare)}
10+
GOVER=$(go version | { read _ _ version _; echo ${version#go}; })
1011

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

37+
ver_le() {
38+
printf "$1\n$2\n" | sort -VC
39+
}
40+
41+
if [ $ANDROID ] && ver_le 1.23.0 $GOVER ; then
42+
# github.com/wlynxg/anet library relies on //go:linkname
43+
LDFLAGS="$LDFLAGS -checklinkname=0"
44+
fi
45+
3646
if [ $IOS ]; then
3747
echo "Building framework for iOS"
3848
go get golang.org/x/mobile/bind

0 commit comments

Comments
 (0)