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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
300
Critical Path Analysis
rakyll
0
710
Monitoring and Debugging Containers
rakyll
2
1.2k
CPDD
rakyll
0
4.3k
Other Decks in Programming
See All in Programming
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
220
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
750
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
3
1.1k
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
290
torikago - Ruby::Boxで照らすモジュラモノリスの実行境界
se4weed
1
300
Android CLI
fornewid
0
200
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
140
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
3.3k
5分で問診!Composer セキュリティ健康診断
codmoninc
0
770
改善しないと、タスクが回らない。 “てんこ盛りポジション” を引き継いだ情シスの、入社3ヶ月の業務改善録
krm963
0
240
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
420
Build-to-own AI: Agentic Development for Humans
inesmontani
PRO
0
160
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
The SEO identity crisis: Don't let AI make you average
varn
0
520
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
330
How to Talk to Developers About Accessibility
jct
2
460
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
350
Code Reviewing Like a Champion
maltzj
528
40k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
430
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.7k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.4k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
360
Skip the Path - Find Your Career Trail
mkilby
1
170
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
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]