-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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/go/loader: panic loading cgo program #11627
Comments
I reproduced the issue in a Linux VM:
|
Thanks for reporting this; I can reproduce it easily on Linux. The problem is very simple but not simple to fix: go/loader only performs cgo preprocessing on imported packages, not ad hoc packages such as the one consisting of ["p.go"]. The workarounds is to move the cgo code into a separate package and import it. The fix is to rethink go/loader, which I will do after go1.5. Notes to self: we need to copy and adapt the logic of goFilesPackage (from $GOROOT/src/cmd/go/build.go). Once this is done, all the loader.Config methods (Import and Create) will return the same kind of entity, essentially a build.Package. Perhaps we can even reuse this type directly. Also: we should support swig. |
…package See golang/go#11627. Change-Id: I458bc4ea54d0db34f3ba96060d284eda4bad7111 Reviewed-on: https://go-review.googlesource.com/12190 Reviewed-by: David Crawshaw <crawshaw@golang.org>
As a workaround I submitted this CL https://go-review.googlesource.com/#/c/12190/, which reports an internal error instead of panicking. |
@alandonovan, is this the same bug as users being unable to use tools like |
No, this bug occurs only when files containing 'import "C"' appear on the command line, as opposed to being imported. This is the first I've heard of the cgo + pkg-config problem, but now that you mention it, support for pkg--config is obviously missing. Feel free to file another issue for it. |
Filed #13526. |
Ping, any progress on this issue? |
Sorry, no. (The required fix is invasive and entails an API change.) |
Since support |
When trying to load a simple cgo program I get a panic: "internal error: unexpected import: C"
What version of Go are you using (go version)?
What operating system and processor architecture are you using?
OS X and amd64
What did you do?
Ran this program:
Which loads this program:
What did you expect to see?
The loading program run successfully.
What did you see instead?
The text was updated successfully, but these errors were encountered: