GopherCon 2016: The Design of the Go Assembler - Rob Pike

Gopher Academy · 115K views · 2016 · 23:57

Open on YouTube

C, C++, Rust, Go & systems languagesCompilers, interpreters & program analysistalk

Why Hacker News recommends it

HN points to it for background on how the Go toolchain targets many architectures and why its assembler is designed that way.

What it is

Rob Pike's GopherCon 2016 talk on the design of the Go assembler, explaining why Go uses a common assembly language translated to each architecture.

Recommended by 3 HN commenters across 3 different months, 2017 to 2025.

What Hacker News said

Recommends chubot · 2017-02 · on “Show HN: How to write a tiny compiler”

Have you looked at the Go toolchain at all? I don't know much about it, but they implemented their back ends in a manner that is much smaller than LLVM and GCC. And it sounds like the architecture of the compiler is significantly different. I watched this talk and it was pretty interesting: [this video] [LINK] If I am understanding right, the claim is that they have a single assembly language for ALL GO architectures, based on something Ken Thompson wrote in the 90's for some National Instruments (?) chip. He actually says that all assembly language looks the same now. I was sort of surprised by that claim. I would like to hear a critique of this from other compiler writers. Does the fact that Go

Recommends bkeroack · 2017-04 · on “A Foray into Go Assembly Programming”

Here's a good talk about the Go assembler backend: [this video] Spoiler: they're nearly to the point (maybe now they've achieved it fully) of autogenerating a new language backend from ISA documentation PDFs! Bring that up next time someone complains about Go not using LLVM.

Recommends fourseventy · 2017-09 · on “Go Assembly by Example”

This is relevant [this video] Its Rob Pike talking about the go assembler and he answers a few of your questions.

Cites znpy · 2017-08 · on “Orbit: An Optimizing Compiler for Scheme (1986) [pdf]”

Interestingly, one of the pages you link ( [LINK] ) links a paper (grep "1986: Kelsey dissertation on rewrite-based compilation ") that shows the implementation of a compiler with multiple frontends (BASIC, Scheme, Pascal) using only source-to-source) transformation. I find this interesting because in a certain way, this reminds me of how the go assembler works ( [this video] ). For those who haven't seen the talk: basically the go compiler works on the assumption that pretty much all computer, in a way, move memory from one address to another, generate and handle interrupts, have call/return instructions and so on. Thus, the go compiler emits (IIRC) some sort of "intermediate assembler" (somehow

Cites jhawk28 · 2018-12 · on “Porting Alpine Linux to RISC-V”

Go uses a common assembly with ways to covert into the specific architecture which makes porting the toolchain to new targets somewhat trivial. ( [this video] )

Cites cxr · 2023-03 · on “The Simplicity of Single-File Golang Deployments”

> I kind of miss cgi-bin. If we're ever to get back to a place where random "power users" can knock up a quick server to meet some computing need they have, easy deployment has to be a big part of that. Can we make it as easy to deploy as to post on Instagram? I'd be happy with a future that takes some cues from literate programming, where if you want to deploy some application, the way you do it is to upload a copy of the software manual/specification. This should be sufficient to "teach" the server how the application should behave. It's tempting to say "Ah, sounds like super advanced ChatGPT-ops or something approaching real AGI", but what I have in mind is something decidedly less magica

Cites yencabulator · 2024-05 · on “Runtime code generation and execution in Go”

Generally the inline assembly is hand-written and must follow the platform rules, see "Architecture-specific details" in [LINK] The few tools that generate that asm, such as [LINK] , would also have follow the rules. You're not meant to take C source, crank it through GCC, and slurp that in as inline asm in Go. Background: [this video]

Cites saclark11 · 2024-10 · on “Show HN: Go Plan9 Memo”

> Overall, pretty weird stuff. I am not sure why the Go team went down this route. Maybe it simplifies the compiler by having this bespoke assembly format? Rob Pike spoke on the design of Go's assembler at a talk in 2016 [1][2]. I think it basically came down to the observation that most assembly language is roughly the same, so why not build a common assembly language that "lets you talk to the machine at the lowest level and yet not have to learn a new syntax." It also enables them to automatically generate a working assembler given an instruction manual PDF for a new architecture as input. [1]: [this video] [2]: [LINK]