-
Notifications
You must be signed in to change notification settings - Fork 18k
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
Cross-compilation produces different binaries #14906
Comments
Can you please run When you says "exited saying that a file was not found" do you mean |
Btw, by default, unless you have taken explicit action, cross compiling will produce a static binary, compiling locally on linux for linux will produce a dynamically linked binary. |
Sounds like the docker container doesn't have libc and the binary is not static. |
@davecheney & @bradfitz - you're correct, it was an issue with it dynamically looking for a library. I wasn't aware that the stdlib (I think net/http) used cgo by default on Linux. I misread the error message as it saying that " After finding out that Linux code isn't actually statically linked, I found a lot of threads and projects that got bit by this same error. It would have been much easier to track down if there had been better logging, letting me know that a dependency wasn't found, rather than a generic Thanks for helping me track that down! |
For reference, #9344 |
go version
)?1.6
go env
)?darwin amd64 & linux amd64
I cross-compiled a 20MB binary on darwin for linux, which I run inside a docker scratch container. I also compiled the same program with the same dependencies on a Ubuntu 14.04 machine.
I expected the binary to be the same and execute the same inside Docker.
The binary cross-compiled on darwin worked just fine inside the scratch container, but the Ubuntu compiled binary exited saying that a file was not found. When running the "broken" binary in a docker container with a debian base image, it then ran.
I am not using cgo or anything similar. It's a fairly large $work application, so I can't easily reproduce it, but this behavior has been tested across multiple machines and environments. It seems as though something is being statically linked into the darwin binary that is not being linked in the Ubuntu compiled binary.
The text was updated successfully, but these errors were encountered: