Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
GoでCコンパイラを作った話
Search
repunit11
July 21, 2026
Technology
200
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GoでCコンパイラを作った話
repunit11
July 21, 2026
More Decks by repunit11
See All by repunit11
パーソナライズPodcastを作った話
repunit
0
81
Goから始める低レイヤ
repunit
0
28
-共通テストから学ぶ- ネットワークにDeep Dive
repunit
0
18
技術カンファレンスはただの学び場ではない「最高の遊び場だ」
repunit
0
22
Other Decks in Technology
See All in Technology
TinyGo 開発サイクルを高速化する:Go で作るエミュレータ入門
zozotech
PRO
1
750
ユーザー価値を届け続けるためにウォンテッドリーが大切にしている文化
kotaminato
0
180
AI 時代のスタートアップエコシステ厶から考究する技術的負債との向き合い方
m3m0r7
PRO
3
2.3k
銀行勘定系システムにおける開発プロセス刷新×AIによる環境モダナイゼーション / Development Process Transformation and AI-Driven Environment Modernization
muit
1
2.3k
俺の仕事は AIに奪われないし、たぶんその BIも要らない
hikaruri
0
520
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
12k
aws-iot-platform-architecture-use-cases.pdf
ma2shita
0
320
事業課題から技術的負債に向き合う
sansantech
PRO
2
2k
GoのInterface内部構造から学ぶ!最高パフォーマンスを出すコード設計
yappli_developers
0
160
Vibe Coding で作ったプロダクトをどう安全に動かすか / How to Safely Run Products Built with Vibe Coding
glidenote
0
170
2026-09-18 gotanda.sre Terraformで複数環境作ったり、複数Stateに分割したりそれとTerragrunt / Terraform multi envs and multi states
masasuzu
2
540
The Knowledge Spine: A Machine-Executable Ontology for Governed Marketing Activation
vananth22
0
110
Featured
See All Featured
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
500
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
300
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
3
4.3k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
510
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
The Cult of Friendly URLs
andyhume
79
7k
Building Applications with DynamoDB
mza
96
7.2k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.8k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.1k
HDC tutorial
michielstock
2
870
Transcript
GoでCコンパイラを 作った話 Fukuoka.go #23
自己紹介 レプ # seccamp 26 # Go言語 @repunit11 # 分散アルゴリズム
# システムプログラミング # マジック # アニメ # ステッカー帳 2
目次 01 自作Cコンパイラの紹介 02 printの実装 3
自作Cコンパイラ の紹介 4
コンパイラとは ソースコードを別の言語や形式に変換するプログラム Cプログラム アセンブリ コード コ ン パ イ ル
自作Cコンパイラの紹介 オブジェクト ファイル ア セ ン ブ ル 実行 ファイル リ ン ク 5
コンパイラとは ソースコードを別の言語や形式に変換するプログラム 今回:C言語からLinuxx86-64アセンブリへの変換 Cプログラム アセンブリ コード コ ン パ イ
ル 自作Cコンパイラの紹介 オブジェクト ファイル ア セ ン ブ ル 実行 ファイル リ ン ク 6
コンパイルの流れ シンプルなコンパイラのステップ 字句解析 構文解析 トークン AST 抽象構文木 自作Cコンパイラの紹介 意味解析 最適化
コード生成 型システム 中間表現 IR アセンブリ 7
実際にコンパイルできるもの 自作Cコンパイラの紹介 8
Cコンパイラを作ろうと思った理由 去年の12月ごろ:低レイヤ開発に興味が出てきた CコンパイラをC言語で書く教科書はあるのでそれをやってみる Goが好きなのでGoで実装してみる この登壇を機にprintを実装した 自作Cコンパイラの紹介 参考にした教科書:低レイヤを知りたい人のためのCコンパイラ作成入門 9
printの実装 10
実装したprintの内容 printの実装 11
printの仕組み print:メモリ上の文字列を標準出力へ書き出す処理 ~処理の流れ~ 文字列を用意する アドレスと長さを指定する writeシステムコールを呼ぶ ファイルディスクリプタ、配置されているメモリアドレス、文字数 (0:標準入力、1:標準出力、2:エラー出力) printの実装 12
システムコールとは printの実装 13
アセンブリでHello Worldする方法 x86-64 上のLinux printの実装 引用:『Goならわかるシステムプログラミング 第2版』 14
Goパッケージのシステムコールの実装 システムコールをアセンブリから呼び出したいとき 使いたいシステムコールの番号、引数をネットやmanを使って調べる syscallパッケージを読もう printの実装 15
Goパッケージのシステムコールの実装 syscallパッケージ:GoからOSのシステムコールを呼びだすためのパッケージ Goはlibcを経由せずにシステムコールを呼べる システムコールがOSまで届く流れをGoのソースコードだけで追いやすい 今回参考にした実装:syscall/zsyscall_linux_amd64.go ※ syscallパッケージは現在は更新されていないので、新しく使いたい場合は golang.org/x/sys/unix を使うべき printの実装
詳しくは:https://go.googlesource.com/proposal/+/refs/heads/master/design/freeze-syscall.md 16
まとめ 17
まとめ CコンパイラをGoで実装してみた アセンブリでシステムコールを呼びだす方法 システムコールの使い方はsyscallパッケージに書いてあるので助かる まとめ 18