GreenRaccoon23
GreenRaccoon23

Reputation: 3833

Errors setting up Go for cross-compiling

I'm using Linux 64-bit and I'm trying to set up Go for cross-compiling (for Windows, specifically). There's an awesome guide for this here. But when I try to run the second command below:

cd /usr/lib/go/src
sudo GOOS=windows GOARCH=386 CGO_ENABLED=0 ./make.bash --no-clean

I get errors when it tries to build the cmd package. It says use of internal package not allowed. Is this a bug in Go's main source code? I'll paste the full list of errors.

# Building packages and commands for host, linux/amd64.
package cmd/cmd/pprof
    imports cmd/pprof/internal/driver: use of internal package not allowed
package cmd/cmd/pprof
    imports cmd/pprof/internal/fetch: use of internal package not allowed
package cmd/cmd/pprof
    imports cmd/pprof/internal/symbolizer: use of internal package not allowed
package cmd/cmd/pprof
    imports cmd/pprof/internal/symbolz: use of internal package not allowed
package cmd/cmd/pprof/internal/commands
    imports cmd/pprof/internal/report: use of internal package not allowed
package cmd/cmd/pprof/internal/commands
    imports cmd/pprof/internal/svg: use of internal package not allowed
package cmd/cmd/pprof/internal/commands
    imports cmd/pprof/internal/tempfile: use of internal package not allowed
package cmd/cmd/pprof/internal/driver
    imports cmd/pprof/internal/commands: use of internal package not allowed
package cmd/cmd/pprof/internal/driver
    imports cmd/pprof/internal/report: use of internal package not allowed
package cmd/cmd/pprof/internal/driver
    imports cmd/pprof/internal/tempfile: use of internal package not allowed
package cmd/cmd/pprof/internal/fetch
    imports cmd/pprof/internal/plugin: use of internal package not allowed
package cmd/cmd/pprof/internal/fetch
    imports cmd/pprof/internal/profile: use of internal package not allowed
package cmd/cmd/pprof/internal/plugin
    imports cmd/pprof/internal/profile: use of internal package not allowed
package cmd/cmd/pprof/internal/report
    imports cmd/pprof/internal/plugin: use of internal package not allowed
package cmd/cmd/pprof/internal/report
    imports cmd/pprof/internal/profile: use of internal package not allowed
package cmd/cmd/pprof/internal/symbolizer
    imports cmd/pprof/internal/plugin: use of internal package not allowed
package cmd/cmd/pprof/internal/symbolizer
    imports cmd/pprof/internal/profile: use of internal package not allowed
package cmd/cmd/pprof/internal/symbolz
    imports cmd/pprof/internal/profile: use of internal package not allowed

I can't find anything like this on Google, so that probably means I'm doing something wrong. I'm using Arch Linux, by the way, and I installed Go with pacman, not from source.

Upvotes: 2

Views: 749

Answers (1)

VonC
VonC

Reputation: 1324537

This error comes from cmd/go/pkg.go#L358, and a look at the blame view show this has been introduced by commit 1338f32 for go 1.4

So the guide might work only with go 1.3-, not go 1.4, because of the Go 1.4 "Internal" Package proposition.

For Go 1.4, we will implement the rule first for $GOROOT, but not $GOPATH. We will use the compiler conversion and some minor uses in the standard library to gain experience with the rule.

Due to an irregularity in the main repo, as a special case, the “/pkg/” element in $GOROOT/src/pkg/… paths is considered not to exist.
This means that $GOROOT/src/pkg/internal can be imported by $GOROOT/src/cmd/… in addition to $GOROOT/src/pkg/….
This special case will be removed when we move the standard library up to $GOROOT/src/.

Upvotes: 2

Related Questions