-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
go/types: UsesCgo exposes mangled names #39072
Comments
In CL 33677, I added support for resolving |
So two limitations that will need to be addressed through further cmd/cgo support, and probably can't be resolved this late in the release cycle:
|
@heschik provided https://golang.org/cl/234057 as a test case. |
Change https://golang.org/cl/234525 mentions this issue: |
@heschik I've uploaded CL 234525. It passes your test case. I'd appreciate if you could test it out in the context of gopls. My expectation is that it should mean the I'll give the caveat that I think this should be fine, but it's somewhat more invasive than I feel really comfortable with at this point in the release cycle. I still think it's worth testing out now though, because if this is a desirable direction to go, I think we should tweak the |
Change https://golang.org/cl/234526 mentions this issue: |
Change https://golang.org/cl/237417 mentions this issue: |
This API and functionality was added late in the Go 1.15 release cycle, and use within gopls has revealed some shortcomings. It's possible (but not decided) that we'll want a different API long-term, so for now this CL renames UsesCgo to a non-exported name to avoid long-term commitment under the Go 1 compat guarantee. Updates #16623. Updates #39072. Change-Id: I04bc0c161a84adebe43e926df5df406bc794c3db Reviewed-on: https://go-review.googlesource.com/c/go/+/237417 Run-TryBot: Matthew Dempsky <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]>
Change https://golang.org/cl/237423 mentions this issue: |
Change https://golang.org/cl/237422 mentions this issue: |
Updates golang/go#16623. Updates golang/go#39072. Change-Id: I6612cdac14faa5ad724ceb805e1d6c823b4046ff Reviewed-on: https://go-review.googlesource.com/c/tools/+/237423 Run-TryBot: Matthew Dempsky <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]>
@heschik FYI, last night I rebased golang.org/cl/234525 and cleaned it up somewhat. It changes the There's still one issue I'm aware of: if you have a global C variable or macro, the Go type will likely be wrong. In particular, for something like:
cgo makes I'd be interested to know if you can spot any other issues. |
Apologies for the rather extreme delay. It looks good and is a definite improvement. The one thing I noticed is that while the mangled names are no longer visible at the top level, they've moved to the C package. It would be nice to hide them from there too if possible. The incorrect types will confuse autocomplete somewhat. If the user has a function that takes a |
Thanks for the test report.
Interesting. You mean like the I thought this should hide the mangled names as non-exported (https://go-review.googlesource.com/c/go/+/234525/5/src/go/types/object.go):
I can probably just suppress declaring the mangled identifiers though. |
Yeah. I see |
@mdempsky is it too late to get this merged? |
Howdy, and thank you Heschik and Matthew!
Yes, it currently is. However I shall punt this to Go1.17 and make it early-in-cycle. |
Should we try to merge this for 1.17, or push again? Thanks. |
Bump. What is the status of this? Did this get merged into 1.17 .. ? I am using go 1.17.1 and this problem is still there. Any suggestions to workaround would be appreciated. Thanks in advance. |
At this point it doesn't seem like a high priority. Bumping to backlog. cc @findleyr |
I ran into this problem this morning using |
@mccolljr, sorry, catching up with this discussion. Doing some research, I think #35721 covers better support for working with cgo, particularly completion after Matthew, any interest in reviving that CL? If not, perhaps someone else can pick it up--do you know of any reason why your approach wouldn't work? |
When UsesCgo is enabled, cgo symbols appear in the package as their mangled names, e.g.
_CFunc_GoString
. This breaks autocomplete in gopls forC
symbols. Also, it exposes things that are implementation details, like the_cgo_
and__cgofn
symbols.We can try to fix this in gopls, but probably it'd be better in
go/types
. I'm not sure offhand how it'll work, given that each package needs its own version of "C". Maybe the package path could be rewritten to something specific?The text was updated successfully, but these errors were encountered: