Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mobile/cmd/gomobile: bind command fails with "direct call too far" with 100 MB executable file #39143

Open
Shagrat2 opened this issue May 19, 2020 · 7 comments

Comments

@Shagrat2
Copy link

@Shagrat2 Shagrat2 commented May 19, 2020

What version of Go are you using (go version)?

$ go version
go version go1.13.11 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/ivan/Library/Caches/go-build"
GOENV="/Users/ivan/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/ivan/workspace/golang"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/3q/lnsctb9j41qc0f06wj7g0tjw0000gn/T/go-build885895559=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

gomobile bind -v -a -target=ios \
    -ldflags "-s -w \
    -X 'qxxx/Sxxl/SRVData.IOS=YES' \
    -X 'qxxx/sxxc/qkernel.CLibVer=$NOW' \
    -X 'qxxx/sxxc/qkernel.CLibTitle=$NOWTITLE' \
    -X 'qxxx/sxxc/qkernel.CLoadURL=$LOADURL'" \
    -tags "note full"

What did you see instead?

runtime/cgo
golang.org/x/mobile/internal/mobileinit
net
# github.com/mattn/go-sqlite3
sqlite3-binding.c:33220:8: warning: "gethostuuid() is disabled." [-W#warnings]
github.com/mattn/go-sqlite3
qxxx/Sxxl/SRVData
qxxx/Sxxl/SDLibrary
gobind
# gobind
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388635
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388639
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388645
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388651
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388657
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388718
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388726
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388732
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388763
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388768
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388772
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388775
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388779
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388783
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388785
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388789
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388672
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388803
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388808
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388814
qxxx/sxxs/v.z/vz.(*TEcu).Espsnsclbr90: direct call too far -8388820
/usr/local/go/pkg/tool/darwin_amd64/link: too many errors
gomobile: darwin-arm: go build -tags qnote RELEASE ios -v -gcflags -trimpath=/Users/xx/workspace/golang/src/qxxx -ldflags -s -w     -X 'qxxx/SDLocal/SRVData.IOS=YES'     -X 'qxxx/sxxc/qkernel.CLibVer=1909192208'     -X 'qxxx/sxxc/qkernel.CLibTitle=2019.09.19 22:08 Release'     -X 'qxxx/sxxc/qkernel.CLoadURL=https://sxxc.online' -buildmode=c-archive -o /var/folders/3q/lnsctb9j41qc0f06wj7g0tjw0000gn/T/gomobile-work-818468499/sdlibrary-arm.a ./gobind failed: exit status 2

@cagedmantis cagedmantis changed the title gomobile iOS - 100 mb executable file - direct call too far x/mobile/cmd/gomobile: bind command fails with "direct call too far" with 100 MB executable file May 19, 2020
@gopherbot gopherbot added this to the Unreleased milestone May 19, 2020
@cagedmantis
Copy link
Contributor

@cagedmantis cagedmantis commented May 19, 2020

/cc @hyangah

@hyangah
Copy link
Contributor

@hyangah hyangah commented May 19, 2020

@cherrymui Can you please help with this linker error?

@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented May 19, 2020

This is 32-bit darwin/arm right?

The linker inserts trampolines for far calls, but it is possible that we missed some cases. It would be good to know what the call target is, in particular, whether it is a regular Go function, or a C function, or something like a PLT stub (which I think there may be some problem)?

32-bit darwin/arm port is removed in Go 1.15, though.

@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented May 19, 2020

(A quick workaround for this could be changing the calls to function pointer calls, like, instead of pkg.F(), do fn := pkg.F; fn()).

@Shagrat2
Copy link
Author

@Shagrat2 Shagrat2 commented May 19, 2020

This is 32-bit darwin/arm right?

The linker inserts trampolines for far calls, but it is possible that we missed some cases. It would be good to know what the call target is, in particular, whether it is a regular Go function, or a C function, or something like a PLT stub (which I think there may be some problem)?

32-bit darwin/arm port is removed in Go 1.15, though.

Why 32 bit?
https://en.wikipedia.org/wiki/Apple-designed_processors
Compile for A7 and newer, is a 64bit arm

(*TEcu).Espsnsclbr90 - is GO struct function in my code.
But the function is taken randomly

@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented May 19, 2020

@Shagrat2 I don't know, I'm just asking.

Based on the error message, gomobile: darwin-arm, it looks like 32-bit ARM to me. We use the name arm64 for 64-bit ARM.

@Shagrat2
Copy link
Author

@Shagrat2 Shagrat2 commented Jun 24, 2020

(A quick workaround for this could be changing the calls to function pointer calls, like, instead of pkg.F(), do fn := pkg.F; fn()).

This workaround failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants