Skip to content

cmd/compile: incorrect position information when -iexport=false #26085

@alandonovan

Description

@alandonovan

If you patch the -iexport flag to default to false (cmd/compile/internal/gc/main.go:248) and run make.bash, it builds the standard library using old bexport format. The files it produces contain incorrect position information for indirectly referenced packages: every object appears to be defined at the point at which it is imported.

You can observe this using the gcexportdata tool, though you'll need its -package flag (https://go-review.googlesource.com/c/tools/+/121195).

$ go build -o gcexportdata golang.org/x/tools/go/gcexportdata/main.go

First, the expected result:
$ ./gcexportdata ~/goroot/pkg/linux_amd64/go/token.a | grep FileSet.*Iterate
$GOROOT/src/go/token/position.go:392:1: method (*FileSet) Iterate(f func(*File) bool)

But when obtaining go/token.FileSet from the go/ast.a file, the position differs:
$ ./gcexportdata -package go/token ~/goroot/pkg/linux_amd64/go/ast.a | grep FileSet.*Iterate
$GOROOT/src/go/ast/ast.go:11:1: method (*FileSet) Iterate(f func(*File) bool)

One resolution would be to delete bexport (and the copy of it in x/tools).

[Google internal issue b/37534272]

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions