~/talk

How to Write a Self-Hosted Go Compiler from Scratch

Talkat GopherCon 2020 · 2020-11-09..11-13· [compilers-and-language-design, go]
links:none on file
slides:none on file

Two handwritten Go compilers and a C-to-Go port produce working self-hosting compilers for a Go subset using GNU assembler and linker; the custom compiler outputs a 14 KB hello binary that runs in ~5 ms versus the official 1+ MB one at ~12 ms. Workflows use first- and second-generation bootstrapping, about six months to self-host for MiniGo, and a later BabyGo rebuild achieves self-hosting with <5,000 LOC while omitting GC, goroutines, maps and interfaces or implementing them trivially.

AI-written summary · about

  1. 0:00Intro
  2. 0:50Today's Goal
  3. 1:45Architecture of my compilers
  4. 2:17Architecture of the official Go compiler
  5. 2:38minigo & babygo
  6. 10:23Encounter with 8cc
  7. 13:02Learn C and Go at the same time
  8. 13:50Tried writing a Go compiler
  9. 15:38Writing a Go compiler in Go: the hard parts
  10. 16:52minigo: Struggles in the last half
  11. 19:25Implementation of "map"
  12. 19:41Implementation of "interface"
  13. 20:29Funny bug: break
  14. 22:11Tried reading the official Go compiler
  15. 22:44Official compiler: size of slice
  16. 22:58Official compiler: variable names for slice
  17. 23:11Tried submitting a patch
  18. 24:22Started writing another Go compiler
  19. 24:39babygo: First commit
  20. 25:40Stack machine (chibicc style)
  21. 25:59babygo: stack machine (chibicc-like)
  22. 27:04babygo: Handwritten syscall
  23. 28:06babygo: Order of implementation
  24. 30:16Conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.