diff --git a/builder/env.go b/builder/env.go index 0d1d0dfe..40775a7c 100644 --- a/builder/env.go +++ b/builder/env.go @@ -54,11 +54,20 @@ func (b *Builder) envv() []string { if *buildTool == "go" { e = []string{ "GOOS=" + b.goos, - "GOHOSTOS=" + b.goos, "GOARCH=" + b.goarch, - "GOHOSTARCH=" + b.goarch, "GOROOT_FINAL=/usr/local/go", } + if b.goos != "nacl" { + // If we are building, for example, linux/386 on a linux/amd64 machine we want to + // make sure that the whole build is done as a if this were compiled on a real + // linux/386 machine. In other words, we want to not do a cross compilation build. + // To do this we set GOHOSTOS and GOHOSTARCH to override the detection in make.bash. + // + // The exception to this rule is when we are doing nacl builds. These are by definition + // always cross compilation, and we have support built into cmd/go to be able to handle + // this case. + e = append(e, "GOHOSTOS="+b.goos, "GOHOSTARCH="+b.goarch) + } } for _, k := range extraEnv {