Skip to content

x/tools/gopls: workspace symbols jumps to incorrect location with files with CGO #37659

Closed
@jackielii

Description

@jackielii

Please answer these questions before submitting your issue. Thanks!

What did you do?

source code at https://github.com/jackielii/gopls-bug-report/tree/cgo

.
├── go.mod
├── main.go
└── pkg
    ├── testcgo.go

testcgo.go content:

package pkg

// int one(){ return 1; }
import "C"

func One() int {
	return int(C.one())
}

main.go:

package main

func Hello() {
	panic("not implemented")
}

listing workspace symbols shows Hello properly, however, function One shows:

  One [Function] /home/jackieli/.cache/go-build/d5/d5d064d49f7b917851c19215a835b5b540b3a7e9d446f2381c7d23114aaefaf6-d

What did you expect to see?

expect One to be current workspace, not from build cache

What did you see instead?

image

Build info

golang.org/x/tools/gopls v0.3.3
    golang.org/x/tools/gopls@v0.3.3 h1:mTFqRDJQmpSsgDDWvbtGnSva1z9uX2XcDszSWa6DhBQ=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/sergi/go-diff@v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
    golang.org/x/mod@v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E=
    golang.org/x/sync@v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
    golang.org/x/tools@v0.0.0-20200227200655-6862ededa516 h1:OX66ZzpltgCOuBSGdaeT77hS2z3ub2AB+EuGxvGRBLE=
    golang.org/x/xerrors@v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
    honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=
    mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=

Go info

go version go1.14 linux/amd64

GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jackieli/.cache/go-build"
GOENV="/home/jackieli/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jackieli/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/jackieli/gomod/seismic-service/go.mod"
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-build803397157=/tmp/go-build -gno-record-gcc-switches"

Activity

added this to the Unreleased milestone on Mar 4, 2020
added
ToolsThis label describes issues relating to any tools in the x/tools repository.
goplsIssues related to the Go language server, gopls.
on Mar 4, 2020
gopherbot

gopherbot commented on Mar 4, 2020

@gopherbot
Contributor

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

stamblerre

stamblerre commented on Mar 4, 2020

@stamblerre
Contributor

Thanks for the report! /cc @heschik for cgo expertise

added
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
on Mar 4, 2020
gopherbot

gopherbot commented on Mar 4, 2020

@gopherbot
Contributor

Change https://golang.org/cl/222060 mentions this issue: internal/lsp/source: use logical filenames for workspace symbols

locked and limited conversation to collaborators on Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jackielii@stamblerre@gopherbot

        Issue actions

          x/tools/gopls: workspace symbols jumps to incorrect location with files with CGO · Issue #37659 · golang/go