Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Debugging Code Generation in Go
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
JBD
February 02, 2020
Programming
1.7k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Debugging Code Generation in Go
JBD
February 02, 2020
More Decks by JBD
See All by JBD
eBPF in Microservices Observability at eBPF Day
rakyll
1
2.2k
eBPF in Microservices Observability
rakyll
1
1.8k
OpenTelemetry at AWS
rakyll
1
1.9k
Are you ready for production?
rakyll
8
3k
Servers are doomed to fail
rakyll
3
1.6k
Serverless Containers
rakyll
1
290
Critical Path Analysis
rakyll
0
700
Monitoring and Debugging Containers
rakyll
2
1.2k
CPDD
rakyll
0
4.3k
Other Decks in Programming
See All in Programming
さぁV100、メモリをお食べ・・・
nilpe
0
140
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
170
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
11
4.1k
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
8
4.8k
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
690
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
3
2k
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
250
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
350
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
4
1k
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
230
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
260
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
170
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
460
My Coaching Mixtape
mlcsv
0
150
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
HDC tutorial
michielstock
2
710
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
390
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
230
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
180
Transcript
Debugging Code Generation in Go Jaana B. Dogan, Google
[email protected]
None
None
@rakyll Who needs this talk? • Developers who want to
debug the compilation. • Reverse engineers, security practitioners, ... • Current or prospective Go contributors. • Anyone who wants to study compilers.
Lexing and parsing Transformations on AST SSA optimizations
main program package main import "fmt" func main() { sum
:= 1 + 1 fmt.Printf("sum: %v\n", sum) }
main program $ go build -x WORK=/var/folders/zq/wgh6df4s6fz2wjwdp5dvzlww005d 21/T/go-build399551378 mkdir -p
$WORK/b001/ cat >$WORK/b001/importcfg.link << 'EOF' # internal packagefile github.com/rakyll/codegen=/Users/jbd/Library/Cach es/go-build/00/00ed60989b390a64bad3cb01d4ec61aae6 d0ea61e3e38fc35052d1ab5b0efe66-d packagefile ...
main program $ go build -n # run dry WORK=/var/folders/zq/wgh6df4s6fz2wjwdp5dvzlww005d
21/T/go-build399551378 mkdir -p $WORK/b001/ cat >$WORK/b001/importcfg.link << 'EOF' # internal packagefile github.com/rakyll/codegen=/Users/jbd/Library/Cach es/go-build/00/00ed60989b390a64bad3cb01d4ec61aae6 d0ea61e3e38fc35052d1ab5b0efe66-d packagefile ...
main program $ go build -a # build without the
cache
main program $ go build -work # don’t delete work
directory WORK=/var/folders/zq/wgh6df4s6fz2wjwdp5dvzlww005d 21/T/go-build444532126
main program $ go list -f {{.GoFiles}} # investigate files
[main.go] $ GOOS=windows go list -f {{.GoFiles}} [main.go main_windows.go] See https://golang.org/pkg/cmd/go/internal/list/ for more.
main program $ go build -gcflags="-S" # print Go assembly
# github.com/rakyll/codegen os.(*File).close STEXT dupok nosplit size=26 args=0x18 locals=0x0 0x0000 00000 (<autogenerated>:1) TEXT os.(*File).close(SB), DUPOK|NOSPLIT|ABIInternal, $0-24 0x0000 00000 (<autogenerated>:1) FUNCDATA$0, gclocals·e6397a44f8e1b6e77d0f200b4fba5269(SB) 0x0000 00000 (<autogenerated>:1) FUNCDATA...
main program $ go tool objdump -s main.main <binary> TEXT
main.main(SB) /Users/jbd/go/src/github.com/rakyll/codegen/main. go main.go:5 0x109adc0 65488b0c2530000000 MOVQ GS:0x30, CX main.go:5 0x109adc9 483b6110 CMPQ 0x10(CX), SP main.go:5 0x109adcd 0f8690000000 JBE 0x109ae63 main.go:5 0x109add3 4883ec68 SUBQ ...
main program $ go tool nm <binary> | grep runtime.walltime
1044b20 T runtime.walltime 1054c50 T runtime.walltime_trampoline
main program $ go build -gcflags="-N" # disable optimizations $
go build -gcflags="-l" # disable inlining $ go build -gcflags="-N -l" # disable both
main program $ GOSSAFUNC=main go build && open ssa.html
main program $ go build -gcflags="-m" # escape analysis $
go build -gcflags="-m=2" # more info
main program $ go build -gcflags="-live" # debug liveness $
go build -gcflags="-live=2" # more info
main program $ go build -gcflags="-bench=bench.out" $ go build -gcflags="-race"
# race detector $ go build -gcflags="-memprofile=profile.out" $ go build -gcflags="-traceprofile=trace.out" # ...
Thanks. Jaana B. Dogan, Google
[email protected]