Skip to content

cmd/compile: Compiler doesn't expand paths specified in the //line directive #40365

@nd

Description

@nd

What version of Go are you using (go version)?

$ go version
go version go1.15beta1 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/nd/.cache/go-build"
GOENV="/home/nd/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/nd/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/nd/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/nd/go/go1.15beta1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/nd/go/go1.15beta1/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build338441636=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Compiled code containing //line directives. Code has the following structure:

  • $GOPATH/gen/f.go:
package main

import "gen/pkg"

func main() {
	F("ok")     
	pkg.F("ok")
}

func F(s string) {
//line foo:2
	println(s)
}
  • $GOPATH/gen/foo:
function F(var s) {
  println(s)
}
  • $GOPATH/gen/pkg/f.go:
package pkg

func F(s string) {
//line foo:2
	println(s)
}
  • $GOPATH/gen/pkg/foo:
function G(var s) {
  println(s)
}

Code is compiled with go build -gcflags="all=-N -l" .

What did you expect to see?

Debug info contains 2 entries: path/to/gen/foo and path/to/gen/pkg/foo.

What did you see instead?

A single file entry:

 The Directory Table is empty.

 The File Name Table (offset 0x1cadb):
  Entry Dir     Time    Size    Name
  1     0       0       0       <autogenerated>
  2     0       0       0       /home/nd/go/src/gen/f.go
  3     0       0       0       foo
  4     0       0       0       /home/nd/go/src/gen/pkg/f.go

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions