Go: x/tools/cmd/gorename: cgo pkg-config not supported by loader(?)

Created on 7 Dec 2015  路  9Comments  路  Source: golang/go

(Sorry for the terrible issue description, I don't really understand all the pieces.)

When I use gorename on a project that transitively depends on a cgo library, I get the error:

cgo pkg-config not supported

I get this in go version go1.4.2 linux/amd64 but also on my other box which has a newer version of go.

I hear that @alandonovan knows about this. I find the error in this module:
https://code.google.com/p/go/source/browse/go/loader/cgo.go?repo=tools

FrozenDueToAge

Most helpful comment

All 9 comments

For what it's worth, I'd be fine with any simple workarounds you have -- the cgo module is not important to the code I'm editing. For example if I could check in the cgo-generated files to fix this, or use a build tag to remove the cgo files when using gorename, etc... (Obviously just fixing it is preferable though if that's easy.)

...which gives me an idea! I might try inlining the results of pkg-config into cflags/ldflags on the relevant source.

I have the same problem.

gorename output:

cgo pkg-config not supported
cgo pkg-config not supported
cgo pkg-config not supported
/Users/leo/src/mygo/src/github.com/moovweb/gokogiri/xml/attribute.go:13:3: undeclared name: XmlNode
/Users/leo/src/mygo/src/github.com/moovweb/gokogiri/xml/cdata.go:11:3: undeclared name: XmlNode
/Users/leo/src/mygo/src/github.com/moovweb/gokogiri/xml/comment.go:4:3: undeclared name: XmlNode
/Users/leo/src/mygo/src/github.com/moovweb/gokogiri/xml/element.go:4:3: undeclared name: XmlNode
/Users/leo/src/mygo/src/github.com/moovweb/gokogiri/xml/pi.go:4:3: undeclared name: XmlNode
/Users/leo/src/mygo/src/github.com/moovweb/gokogiri/gokogiri.go:21:38: undeclared name: html
/Users/leo/src/mygo/src/github.com/moovweb/gokogiri/gokogiri.go:33:37: XmlDocument not declared by package xml
/Users/leo/src/mygo/src/github.com/DSrcl/Microdata-Parser/parser.go:12:11: Node not declared by package xml
/Users/leo/src/mygo/src/github.com/DSrcl/Microdata-Parser/parser.go:80:41: undeclared name: xpath
/Users/leo/src/mygo/src/github.com/DSrcl/Microdata-Parser/parser.go:18:19: undeclared name: xpath
/Users/leo/src/mygo/src/github.com/DSrcl/Microdata-Parser/parser.go:18:38: undeclared name: xpath
/Users/leo/src/mygo/src/github.com/DSrcl/Microdata-Parser/parser.go:31:22: Node not declared by package xml
/Users/leo/src/mygo/src/github.com/DSrcl/Microdata-Parser/parser.go:67:32: undeclared name: xpath
/Users/leo/src/mygo/src/github.com/DSrcl/Microdata-Parser/parser.go:67:55: Node not declared by package xml
/Users/leo/src/mygo/src/github.com/DSrcl/Microdata-Parser/parser.go:129:24: Node not declared by package xml

same for me with https://github.com/abh/geoip

While scanning Go workspace:
// some text
GeoIP not declared by package geoip
Open not declared by package geoip

even though these functions are declared by this package.

This is a bug in golang.org/x/tools/go/loader. The fix requires adding logic to the runCgo function so that it executes pkg-config, following the logic in the go build command (see $GOROOT/src/cmd/go/build.go).

Is there an issue for this bug, or is this the issue? Is there a patch somewhere that I might be able to apply locally while waiting for this to make it into the release?

@alaska This is the issue. I don't think there is an existing patch. Alan outlined above what needs to happen.

Any luck here, its been open a while and doesn't seem to be scheduled. I am seeing while trying to use tools like errcheck or unused.

CL https://golang.org/cl/21121 mentions this issue.

Was this page helpful?
0 / 5 - 0 ratings