]> Cypherpunks repositories - gostls13.git/commit
cmd/go: do not pass a local prefix to the compiler in module mode
authorBryan C. Mills <bcmills@google.com>
Tue, 28 Sep 2021 15:52:45 +0000 (11:52 -0400)
committerBryan C. Mills <bcmills@google.com>
Wed, 6 Oct 2021 16:46:09 +0000 (16:46 +0000)
commit316057142cc6055952621ccbaccc53d58d88be3f
tree478bb93d8ee0e46a38e48fa0e9cf68016811fee6
parent7109323af5a8c7e076fa2af7185caa6185df97cd
cmd/go: do not pass a local prefix to the compiler in module mode

In GOPATH mode, source files may import other packages using relative
(“local”) paths. In module mode, relative imports are never allowed:
import paths must always be fully specified.

When local imports are allowed, we pass a local-import prefix to the
compiler using the '-D' flag. That could theoretically change the
compiler's output, so it must be included in the cache key even when
-trimpath is set. (TODO: when -trimpath is set, the local-import
prefix ought to be trimmed anyway, so it still shouldn't matter.)

However, when local imports are disallowed, we should not pass the
local-import prefix and it should not affect cmd/go's cache key or the
final build ID of any artifact.

For #48557

Change-Id: I2d627d67d13e5da2cac6d411cd4e2d87e510876c
Reviewed-on: https://go-review.googlesource.com/c/go/+/352810
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/internal/load/pkg.go
src/cmd/go/internal/work/gc.go
src/cmd/go/testdata/script/mod_build_trimpath_issue48557.txt [new file with mode: 0644]