Skip to content

cmd/go: do not modify environment for 'go run' #11709

Closed
@calmh

Description

@calmh

For example compiling for dragonfly/amd64 on darwin/amd64:

(Via a build script, but what happens is just a setting of GOPATH for vendoring and some ldflags for version tagging being added)

jb@syno:~/src/github.com/syncthing/syncthing (go15) $ go run build.go -goos dragonfly
*** Unknown Go version "go version devel +b6ead9f Tue Jul 7 21:53:11 2015 +0000 darwin/amd64".
*** This isn't known to work, proceed on your own risk.
GOPATH=/Users/jb/src/github.com/syncthing/syncthing/Godeps/_workspace:/Users/jb
go install -v -ldflags -w -X main.Version=v0.11.15+6-gff03813 -X main.BuildStamp=1436877241 -X main.BuildUser=jb -X main.BuildHost=syno -X main.BuildEnv=default ./cmd/...
runtime/cgo
# runtime/cgo
/usr/local/go-exp/src/runtime/cgo/gcc_dragonfly_amd64.c:37:2: error: implicit declaration of function 'SIGFILLSET' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
/usr/local/go-exp/src/runtime/cgo/gcc_dragonfly_amd64.c:37:13: error: variable 'ign' is uninitialized when used here [-Werror,-Wuninitialized]
/usr/local/go-exp/src/runtime/cgo/gcc_dragonfly_amd64.c:32:14: note: initialize the variable 'ign' to silence this warning
exit status 2
exit status 1

I'm not sure what it's trying to do, but the error sounds like it's trying to compile stuff for dragonfly using the system compiler, which is obviously quite different from what would exist on actual dragonfly. Disabling cgo makes it work:

jb@syno:~/src/github.com/syncthing/syncthing (go15) $ CGO_ENABLED=0 go run build.go -goos dragonfly
*** Unknown Go version "go version devel +b6ead9f Tue Jul 7 21:53:11 2015 +0000 darwin/amd64".
*** This isn't known to work, proceed on your own risk.
GOPATH=/Users/jb/src/github.com/syncthing/syncthing/Godeps/_workspace:/Users/jb
go install -v -ldflags -w -X main.Version=v0.11.15+6-gff03813 -X main.BuildStamp=1436877241 -X main.BuildUser=unknown-user -X main.BuildHost=syno -X main.BuildEnv=default ./cmd/...

Is this expected? (cgo not working is obviously expected, what surprises me is that it seems to try to enable it by default.)

(I see similar but different errors on linux/amd64 -> dragonfly/amd64 so this one at least is not darwin specific)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions