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/gopls: support Go assembly files #71754

Open
adonovan opened this issue Feb 14, 2025 · 3 comments
Open

x/tools/gopls: support Go assembly files #71754

adonovan opened this issue Feb 14, 2025 · 3 comments
Labels
FeatureRequest Issues asking for a new feature that does not need a proposal. gopls Issues related to the Go language server, gopls. help wanted Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Feb 14, 2025

Gopls already supports navigating from Go source to assembly files (use "Go to definition" on a func declaration with no body), but it wouldn't be hard for it to support navigation within assembly files, and from assembly files to Go files. The necessary parts are:

  • a new file.Kind for Asm (see https://go.dev/cl/649461 for sketch) and go.s LanguageID.
  • a basic parser for assembly files that can extract symbol names and control labels reliably.
  • recording of parsed assembly files in cache.Package, analogous to CompiledGoFiles.
  • augmentation of the xrefs index to include cross-package references from assembly files.
  • new implementations of the Definitions and References queries for file.Asm.
  • bonus: an implementation of Hover for assembly could provide all kinds of helpful information to make reading easier.
  • bonus: DocumentHighlight could show, for a given register, its def/use chains by making them temporarily bold.
  • go.s languageID support in eglot, vscode-go, neovim.

This is obviously not a high priority, but it's a fun little project.

@golang/compiler @golang/runtime

@adonovan adonovan added the FeatureRequest Issues asking for a new feature that does not need a proposal. label Feb 14, 2025
@adonovan adonovan modified the milestones: Backlog, gopls/backlog Feb 14, 2025
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Feb 14, 2025
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/649461 mentions this issue: gopls/internal/cache: rudimentary support for Go *.s assembly

@gabyhelp
Copy link

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

gopherbot pushed a commit to golang/tools that referenced this issue Feb 20, 2025
This CL provides a minimal implementation of the
Definition query within Go assembly files, plus a test.
For now it only works for references to package-level
symbols in the same package or a dependency.

Details:
- add file.Kind Asm and protocol.LanguageKind "go.s".
- include .s files in metadata.Graph.IDs mapping.
- set LanguageKind correctly in gopls CLI.

Also:
- add String() method to file.Handle.
- add convenient forward deps iterator to Graph.
- internal/extract: extract notes from .s files too.

Updates golang/go#71754

Change-Id: I0c518c3279f825411221ebe23dc04654e129fc56
Reviewed-on: https://go-review.googlesource.com/c/tools/+/649461
Auto-Submit: Alan Donovan <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Alan Donovan <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
Commit-Queue: Alan Donovan <[email protected]>
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/654335 mentions this issue: gopls/internal/util/asm: better assembly parsing

gopherbot pushed a commit to golang/tools that referenced this issue Mar 4, 2025
This CL adds a rudimentary parser for symbols in Go .s files.
It is a placeholder for a more principled implementation,
but it is sufficient to make Definition support control labels
(also in this CL) and for a cross-references index (future work).

+ test of Definition on control label
+ test of asm.Parse

Updates golang/go#71754

Change-Id: I2ff19b4ade130c051197d6b097a1a3dbcd95555a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/654335
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Jonathan Amsterdam <[email protected]>
Auto-Submit: Alan Donovan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest Issues asking for a new feature that does not need a proposal. gopls Issues related to the Go language server, gopls. help wanted Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants