mirror of
https://github.com/golang/go
synced 2024-11-02 09:03:03 +00:00
3 commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
Russ Cox
|
a987aaf5f7 |
cmd/compile: require -p flag
The -p flag specifies the import path of the package being compiled. This CL makes it required when invoking the compiler and adjusts tests that invoke the compiler directly to conform to this new requirement. The go command already passes the flag, so it is unmodified in this CL. It is expected that any other Go build systems also already pass -p, or else they will need to arrange to do so before updating to Go 1.19. Of particular note, Bazel already does for rules with an importpath= attribute, which includes all Gazelle-generated rules. There is more cleanup possible now in cmd/compile, cmd/link, and other consumers of Go object files, but that is left to future CLs. Additional historical background follows but can be ignored. Long ago, before the go command, or modules, or any kind of versioning, symbols in Go archive files were named using just the package name, so that for example func F in math/rand and func F in crypto/rand would both be the object file symbol 'rand.F'. This led to collisions even in small source trees, which made certain packages unusable in the presence of other packages and generally was a problem for Go's goal of scaling to very large source trees. Fixing this problem required changing from package names to import paths in symbol names, which was mostly straightforward. One wrinkle, though, is that the compiler did not know the import path of the package being compiled; it only knew the package name. At the time, there was no go command, just Makefiles that people had invoking 6g (now “go tool compile”) and then copying the resulting object file to an importable location. That is, everyone had a custom build setup for Go, because there was no standard one. So it was not particularly attractive to change how the compiler was invoked, since that would break approximately every Go user at the time. Instead, we arranged for the compiler to emit, and other tools reading object files to recognize, a special import path (the empty string, it turned out) denoting “the import path of this object file”. This worked well enough at the time and maintained complete command-line compatibility with existing Go usage. The changes implementing this transition can be found by searching the Git history for “package global name space”, which is what they eliminated. In particular, CL 190076 ( |
||
Robert Griesemer
|
e861c3e003 |
cmd/compile: simplified test case (cleanup)
Follow-up on https://golang.org/cl/124595; no semantic changes. Updates #26411. Change-Id: Ic1c4622dbf79529ff61530f9c25ec742c2abe5ca Reviewed-on: https://go-review.googlesource.com/c/142720 Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> |
||
Emmanuel T Odeke
|
0b63086f64 |
cmd/compile: fix label redefinition error column numbers
Ensure that label redefinition error column numbers print the actual start of the label instead of the position of the label's delimiting token ":". For example, given this program: package main func main() { foo: foo: foo: foo : } * Before: main.go:5:13: label foo defined and not used main.go:6:7: label foo already defined at main.go:5:13 main.go:7:4: label foo already defined at main.go:5:13 main.go:8:16: label foo already defined at main.go:5:13 * After: main.go:5:13: label foo defined and not used main.go:6:4: label foo already defined at main.go:5:13 main.go:7:1: label foo already defined at main.go:5:13 main.go:8:1: label foo already defined at main.go:5:13 Fixes #26411 Change-Id: I8eb874b97fdc8862547176d57ac2fa0f075f2367 Reviewed-on: https://go-review.googlesource.com/c/124595 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> |