Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/cmd/oracle: `describe` operation doesn't work with import "C" statements #13971

bruno-medeiros opened this issue Jan 15, 2016 · 2 comments


Copy link

@bruno-medeiros bruno-medeiros commented Jan 15, 2016

Take this source for file /devel/go-workspace/src/foo/foo.go:

package main

#include <time.h>
#include <stdlib.h>
import "C"
import "fmt"

func Random() int {
    return int(C.rand())

func Seed() {

func main() {

Then trying to run oracle describe doesn't work:
oracle -pos=/devel/go-workspace/src/foo/foo.go:#8,#8 describe ___
This results in error:
oracle: no buildable Go source files in /devel/go-workspace/src/foo

Copy link

@gopherbot gopherbot commented Mar 7, 2017

CL mentions this issue.

Copy link

@joegrasse joegrasse commented Jan 12, 2018

@alandonovan @ianlancetaylor Looks like there has been a CL submitted but no progress since then. Just curious what the status is on this?

FrankReh added a commit to FrankReh/tools that referenced this issue Mar 13, 2018
The logic in guru for collecting files for the definition and describe
modes had expressly avoided go files that included the import "C"
statement (known as cgo files) by setting CgoEnabled to false.

Cgo files normally get handed off to the cgo command, requiring a temp
directory and separate processes, which is much more time consuming than
having the go files parsed directly by the loader.

With this change, the cgo files are collected but then they are moved to
the go files list so the expensive cgo processing is avoided and the cgo
files are parsed along with the normal go files.

Guru already set a loader AllowErrors flag to get as much of the ASTs
returned as possible.  Failures in cgo file parsing due to cgo not
having been run is not expected to make the guru results worse.  The
only extra time should be due to extra files now being parsed, generally
making the guru search more complete.

Adds a testdata/cgo/cgo.go test case.

Fixes golang/go#13971
Fixes golang/go#15710
@gopherbot gopherbot added the Tools label Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.