Skip to content

cross compiling issue #66642

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

Closed
Goplush opened this issue Apr 2, 2024 · 2 comments
Closed

cross compiling issue #66642

Goplush opened this issue Apr 2, 2024 · 2 comments

Comments

@Goplush
Copy link

Goplush commented Apr 2, 2024

Go version

go version go1.22.1 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/root/.gvm/pkgsets/go1.22.1/global/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/root/.gvm/pkgsets/go1.22.1/global'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/root/.gvm/gos/go1.22.1'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/root/.gvm/gos/go1.22.1/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.1'
GCCGO='gccgo'
AR='ar'
CC='/opt/x-tools/arm-linux-musleabi-cross/bin/arm-linux-musleabi-cc'
CXX='/opt/x-tools/arm-linux-musleabi-cross/bin/arm-linux-musleabi-cpp'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4118037362=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I tried to build a project, but cgo code kept failing

code demo:

package main

import(
	"fmt"
	"gopkg.in/olebedev/go-duktape.v3"
)

func main()  {
	
	ctx := duktape.New()
	ctx.PushGlobalGoFunction("log", func(c *duktape.Context) int {
	  fmt.Println(c.SafeToString(-1))
	  return 0
	})
	ctx.PevalString(`log('Go lang Go!')`)
	
}

What did you see happen?

In command line:
go build -o main2 main.go
# runtime/cgo
In file included from _cgo_export.c:4:
cgo-gcc-export-header-prolog:31:14: error: size of array ‘_check_for_64_bit_pointer_matching_GoInt’ is negative

What did you expect to see?

compile fine when GOARCH is set to host arch, but fail when cross compile to arm64

what can I do to fix this inconsistent behavior?

@Goplush
Copy link
Author

Goplush commented Apr 2, 2024

Similar to this issue, but I believe I set the cross compiler correctly
#38693

@seankhliao
Copy link
Member

that's an arm32 toolchain.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants