-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/compile: add a README section on developing the compiler #30074
Comments
Wrapper tools: toolstash-check and compilecmp. (Maybe those should move to x/tools?) |
Maybe references to gosmith and how to fuzz the compiler and how to build and run a race-enabled compiler. Mention the SSA rulelog? Some basic tips (like start with the simplest possible reproduction and understand exactly what is happening with it). Pointers on where all the tests live (some in-package, some over in the test dir). |
Hmm, I've personally found it a bit unnecessary. What I do is always run Not exactly the same, as toolstash-check compares with the direct parent, but close enough :)
I think it would need documentation if we are to suggest it here :)
I worry that these would be a bit too advanced for the "modifying the compiler" intro section. We don't want to bombard new developers with two pages of tools to learn. Perhaps this could fall under a more advanced section.
Sure, but wouldn't this go in the SSA readme?
Good ideas! I was forgetting about the simpler pieces of advice like these. |
Here's another idea: How to measure whether a compiler patch produces smaller binaries. For example, if the prove pass is made a bit smarter, and we want to check that it's really removing many bounds checks from a large binary. I believe this is usually measured by comparing text section sizes between two built binaries, but I'm not sure what the tips for this are. For example:
|
It helps prevent making silly mistakes, which I have personally done more than I care to recount. Also, it makes it easy to check all platforms, which matters sometimes.
Yes. Mea culpa. Although FWIW most folks I have recommended it to (on CLs/issues) figure it out pretty readily. It could also use a bit of cleanup. I have also long had plans to unify some of the toolchain-wranging in compilecmp and toolstash-check and pull it into a re-usable package. I have some of it written, but never finished it.
compilecmp does a fair amount of this already. If you pass it |
For rapid development, I usually just Since it builds in /tmp, you can also check multiple CLs in parallel. And like @josharian mentioned, it can help checking other platforms too.
FWIW, I usually use -- Some other things to mention: how to inspect various stages of the compiler. For example, using -S to dump assembly output; GOSSAFUNC to dump SSA stuff; -W to dump the typechecked trees; etc. |
@mvdan want to write some docs, call this completed, or bump to 1.14? |
I do intend to work on this, ideally for 1.13. I assume it's fine to review and submit during the first half of the freeze, as it's only documentation that doesn't affect the release. But if people disagree, it can wait until 1.14. |
Documentation during the freeze is actively encouraged. |
Great! I'm currently at GopherCon Singapore, so I'll probably get to this later in May. |
A section about the |
I evidently did not get to this, and I haven't done any compiler development in a while, so this is up for grabs. Ideally by someone who actually keeps up to date with how to do compiler development nowadays. |
Change https://go.dev/cl/404694 mentions this issue: |
This CL updates the description of the frontend packages of the compiler, which I'm more familiar with. Updates #30074. Change-Id: Ic279007f6102b21072d6558fa9035f0fcc267d93 Reviewed-on: https://go-review.googlesource.com/c/go/+/404694 Reviewed-by: Keith Randall <[email protected]> Reviewed-by: David Chase <[email protected]>
Change https://go.dev/cl/503895 mentions this issue: |
FYI, I sent CL 503895, which adds a new "Tips" section to the cmd/compile README. I initially built it up as a classic "things I wish I knew a month ago", and hence is mostly focused on new-ish cmd/compile contributors. I fleshed it out by cross-checking against topics mentioned above. The CL currently at least touches on many of them, but not:
I can add more to the CL, though perhaps more advanced topics can be left to the future. |
This CL adds a new 'Tips' section to the cmd/compile README. The primary intent is to help new-ish contributors. It includes some basics on getting started, testing changes, viewing coverage, juggling different compiler versions, some links to additional tools, and so on. Updates #30074 Change-Id: I393bf1137db9d2bb851f7e254b08455273ccad8c Reviewed-on: https://go-review.googlesource.com/c/go/+/503895 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> Run-TryBot: t hepudds <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Keith Randall <[email protected]>
Hi @alandonovan, a brief follow-up on our discussion just now — it would be helpful I think if there was a short paragraph on export data (ideally with a few outbound links) added to cmd/compile/README.md. |
Change https://go.dev/cl/578055 mentions this issue: |
Updates #30074 Change-Id: Ic74d482943d992c20f69edb106c666a7b26291c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/578055 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Reviewed-by: Cuong Manh Le <[email protected]>
For example, such a section could mention:
toolstash restore && go install cmd/compile
to rebuild the compiler in a fast and stable waygo build -toolexec "toolstash -cmp" -a -v std cmd
toolstash
andbenchstat
to measure performance optimizationsAnything else that comes to mind, please add it to this issue. I plan on sending a CL to add a markdown section sometime during the 1.13 cycle.
I realise the SSA package has lots of extra checks and debugging flags one can enable, but I think those should be covered by
cmd/compile/internal/ssa/README
. I am also not nearly as familiar with those as I'm with this list here, so I'm leaving ssa's tips for another issue/CL./cc @josharian @mdempsky @aclements @randall77
The text was updated successfully, but these errors were encountered: