You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried different CC/CXX options (clang, gcc, amd64-gcc) - they all behave the same.
What did you see happen?
Here's what I get:
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC="gcc13" CXX="g++13" go build -ldflags "-extldflags -static" -o app
# net
/usr/local/go122/src/net/cgo_resnew.go:20:76: cannot use _Ctype_socklen_t(len(b)) (value of type _Ctype_uint) as _Ctype_ulong value in argument to (_C2func_getnameinfo)
There was a similar discussion about this in #33101 and the solution was to set CGO_ENABLED=0. The problem is that my project has some c++ code that needs to be built, so I can't disable cgo.
If I manually modify the flags in cgo_resnew.go and cgo_resold.go so the latter is used for Linux, the compiling progresses, but it then fails on linking with:
/usr/local/go122/pkg/tool/freebsd_amd64/link: running g++13 failed: exit status 1
/usr/local/bin/ld: cannot find -lresolv: No such file or directory
collect2: error: ld returned 1 exit status
I am not sure if modifying the resnew/old was the right thing, so decided to not dig any deeper and create the report instead.
What did you expect to see?
I expect to be able to do cross-compile builds that use the net module with CGO_ENABLED=1. I can do this on Mac with musl, I can do normal builds on FreeBSD. I expect the cross-builds work on FreeBSD, as well.
Thank you.
The text was updated successfully, but these errors were encountered:
Cross compilation C toolchains typically have the target name as part of their executable names. I don't see that here, so it looks like you're trying to use the host 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.
Go version
go version go1.22.1 freebsd/amd64
Output of
go env
in your module/workspace:What did you do?
I'm trying to cross-compile a project for Linux on a FreeBSD host:
I tried different
CC/CXX
options (clang, gcc, amd64-gcc) - they all behave the same.What did you see happen?
Here's what I get:
There was a similar discussion about this in #33101 and the solution was to set
CGO_ENABLED=0
. The problem is that my project has some c++ code that needs to be built, so I can't disable cgo.If I manually modify the flags in
cgo_resnew.go
andcgo_resold.go
so the latter is used for Linux, the compiling progresses, but it then fails on linking with:I am not sure if modifying the resnew/old was the right thing, so decided to not dig any deeper and create the report instead.
What did you expect to see?
I expect to be able to do cross-compile builds that use the
net
module withCGO_ENABLED=1
. I can do this on Mac with musl, I can do normal builds on FreeBSD. I expect the cross-builds work on FreeBSD, as well.Thank you.
The text was updated successfully, but these errors were encountered: