golang / sublime-build

The official Sublime Text package for Go build system integration.
BSD 3-Clause "New" or "Revised" License
344 stars 46 forks source link

Cross compile error #17

Closed pobearm closed 8 years ago

pobearm commented 8 years ago

on mac osx 10.11.1, cross compile to linux amd64, got an error:

runtime/cgo ld: unknown option: --build-id=none clang: error: linker command failed with exit code 1 (use -v to see invocation)

my gcc verstion is: Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1 Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) Target: x86_64-apple-darwin15.0.0 Thread model: posix

But i use cmd in terminal is ok: env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build

ianlancetaylor commented 8 years ago

You are using the system GCC. When cross-compiling with packages that use cgo, you need to use a cross-compiler or set CGO_ENABLED=0 to disable cgo.

I don't know if this is a sublime issue or not.

wbond commented 8 years ago

@ianlancetaylor Are there other situations related to builds where environmental variables should be set only for specific tasks?

I guess the real question I am asking here is if you think we should build special handling of this (cross-compiling with cgo) into sublime-build, or if we should build a general purpose ability for environment variables to be set per build variant?

Currently we allow users to:

Are we likely to run into a similar issue with any of those? We already currently allow flags to be set for each.

ianlancetaylor commented 8 years ago

The environment variables that matter are documented at https://golang.org/cmd/go/#hdr-Environment_variables . For normal use I think it would be fine to handle cross-compiling as a special case.

pobearm commented 8 years ago

I think , this problem is because of : env CGO_ENABLED, maybe need to be set in config file.