Skip to content

Commit

Permalink
go: explicitly disable modules to avoid unwanted network fetch
Browse files Browse the repository at this point in the history
Go "modules" refers to the dependency fetching, verification (hashing), and
version control system built into Go as of 1.11.

It is not desirable to have Go modules enabled in Buildroot in the normal case,
as Buildroot manages downloading the sources, and third party dependency
managers are typically not used.

In the absence of the GO111MODULE environment variable, the Go compiler will
correctly compile using the "vendor" version of dependencies downloaded by
Buildroot during the compilation process for Go-based packages.

However, if the user sets the GO111MODULE=yes environment variable, the Go
compiler will download the Go dependencies for Buildroot packages, using the
modules system. This is potentially unintended behavior from user environment
variables.

This commit sets the GO111MODULE=off variable in the Go target and host
compilation environments, disabling Go modules support for Buildroot mainline
packages.

Signed-off-by: Christian Stewart <[email protected]>
  • Loading branch information
paralin committed Jan 26, 2019
1 parent 30fbb32 commit ab8fc4c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package/go/go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ HOST_GO_ROOT = $(HOST_DIR)/lib/go
# For the convienience of target packages.
HOST_GO_TOOLDIR = $(HOST_GO_ROOT)/pkg/tool/linux_$(GO_GOARCH)
HOST_GO_TARGET_ENV = \
GO111MODULE=off \
GOARCH=$(GO_GOARCH) \
GOROOT="$(HOST_GO_ROOT)" \
CC="$(TARGET_CC)" \
Expand All @@ -61,6 +62,7 @@ endif
# The go build system is not compatible with ccache, so use
# HOSTCC_NOCCACHE. See https://github.com/golang/go/issues/11685.
HOST_GO_MAKE_ENV = \
GO111MODULE=off \
GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_ROOT) \
GOROOT_FINAL=$(HOST_GO_ROOT) \
GOROOT="$(@D)" \
Expand Down

0 comments on commit ab8fc4c

Please sign in to comment.