Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go: cross-compiling a darwin plugin fails to link #36018
What version of Go are you using (
OK... Where can I get information about this? https://github.com/golang/go/wiki/WindowsCrossCompiling says that I just set GOOS and GOARCH and everything will work.
What do I put in CC? What counts as a Darwin cross-compiler? Why does invoking the system linker change things? Why does it spit out an error that makes it look like go itself has a bug rather than an informative message?
That page needs an overhaul. I added a few words.
Cross compiling a pure Go program works as described on that page. But cross-compiling a program that uses cgo, or that uses the build modes c-shared, c-archive, shared, or plugin, requires a C cross-compiler. A cross-compiler is a compiler that runs on your host system (in your case, GNU/Linux) and can compile a C program into a compiler that runs on your target system (in your case, macOS).
Invoking the system linker changes things because you need to use a linker that can produce an executable that runs on the target system.
I agree that the error message could likely be improved. That is #16395.