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
runtime/cgo: Cannot compile w. GOOS=freebsd on macOS #18189
Comments
You need to disable cgo by setting $CGO_ENABLED=0 for
cross compilation unless you have a FreeBSD cross compile
toolchain on macOS.
|
This should happen by default, CGO_ENABLED should defualt to zero when the
target GOOS/GOARCH does not match the host. Did this change recently?
…On Sun, 4 Dec 2016, 08:54 Minux Ma ***@***.***> wrote:
You need to disable cgo by setting $CGO_ENABLED=0 for
cross compilation unless you have a FreeBSD cross compile
toolchain on macOS.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#18189 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAcA9tDbZbKhDpgz6Ot4BPRkE5Y4aYjks5rEgEugaJpZM4LDbd8>
.
|
I can confirm that |
Can you please include the full output of invoking go build -x for your
project.
…On Sun, Dec 4, 2016 at 9:17 AM, Morten Siebuhr ***@***.***> wrote:
I can confirm that CGO_ENABLED=0 GOOS=freebsd go build . works (built,
copied to FreeBSD and executes)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#18189 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAcA2FIfh11lDitEgbgj9B2PIe3-yPtks5rEgaFgaJpZM4LDbd8>
.
|
Output from
|
I cannot reproduce this failure on my machine (running tip, which is pretty close to 1.8beta1). Can you please run this command and paste the output
|
Yup:
|
Something is forcing |
Just tried on similar macOS machine, where it fails in the same way (and I get the same |
Works with a checkout from tip!
The output from |
Yeah, Homebrew is known to build non-working Go in the past.
It must have forced CGO_ENABLED=1 during build (the Go
make.bash can detect the correct setting for it automatically.)
|
@minux (An aside: When CGO_ENABLED=0 when building the toolchain, is it merely changing the default for the compiler or is it built without CGO capabilities?) |
You don't need to set this value, it always defaults to the correct value. I think what is going on is brew are setting it, and that is messed you up. I think this bug should be assigned to the maintainer of the homebrew formular for Go. |
That was my thought as well - I just wanted to be sure of the details. |
It produces builds that behave in non-standard ways (i.e. produces non-obvious errors when cross-compiling). See golang/go#18189 (comment) Closes #7556. Signed-off-by: ilovezfs <ilovezfs@icloud.com>
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.8beta1 darwin/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/msiebuhr/Source/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.8beta1/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.8beta1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/q9/dlbnnhk937qgk6hpg04z2yv80000gn/T/go-build972782835=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
What did you do?
On macOS (X), cross-compile a Go program to FreeBSD (I used https://github.com/msiebuhr/prometheus-mdns-sd, but it seems any will do):
What did you expect to see?
A freebsd binary being built
(1.7.4 builds a working freebsd binary without any complaints.)
What did you see instead?
The text was updated successfully, but these errors were encountered: