make.go: fix building on FreeBSD

running gopherjs would fail on FreeBSD with errors such as:
../../go1/src/vendor/golang_org/x/net/route/address.go:31:35: undeclared
name: sysAF_LINK

This happens because in $GOROOT/src/vendor/golang_org/x/net/route the
needed constants are defined in zsys_freebsd_$ARCH.go files, where $ARCH
only exists for "386", "amd64", and "arm". So as gopherjs runs for the
"js" arch, all of the zsys_freebsd* files are ignored and the constants
are not defined.

This bug was reported in https://github.com/gopherjs/gopherjs/issues/511
and the "solution" eventually recommended in
https://github.com/gopherjs/gopherjs/pull/513 is to run with GOOS=linux
regardless of the host OS. Using GOOS=linux side-steps the problem since
linux does not need the problematic constants, and the GOOS value is not
supposed to matter for the generated javascript.

fixes #928

Change-Id: I20757a211ea4c671438e94e57552a0cee7a25e81
This commit is contained in:
mpl 2017-05-18 01:18:24 +02:00
parent 174d678928
commit 749d51281d
1 changed files with 6 additions and 0 deletions

View File

@ -481,6 +481,9 @@ func genPublisherJS(gopherjsBin string) error {
cmd.Env = append(cleanGoEnv(),
"GOPATH="+buildGoPath,
)
// Pretend we're on linux regardless of the actual host, because recommended
// hack to work around https://github.com/gopherjs/gopherjs/issues/511
cmd.Env = setEnv(cmd.Env, "GOOS", "linux")
if gopherjsGoroot != "" {
cmd.Env = setEnv(cmd.Env, "GOROOT", gopherjsGoroot)
}
@ -558,6 +561,9 @@ func genWebUIJS(gopherjsBin string) error {
cmd.Env = append(cleanGoEnv(),
"GOPATH="+buildGoPath,
)
// Pretend we're on linux regardless of the actual host, because recommended
// hack to work around https://github.com/gopherjs/gopherjs/issues/511
cmd.Env = setEnv(cmd.Env, "GOOS", "linux")
if out, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("gopherjs for web UI error: %v, %v", err, string(out))
}