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
Autocxx -RustからC++を安全かつ楽に-
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
minami
September 02, 2020
Programming
2
1.5k
Autocxx -RustからC++を安全かつ楽に-
下町.rs #3
minami
September 02, 2020
Tweet
Share
More Decks by minami
See All by minami
Account/Balanceモデルのシャーディングと課題点
minaminao
1
790
Rustで始める競技プログラミング
minaminao
0
330
Other Decks in Programming
See All in Programming
CSC307 Lecture 01
javiergs
PRO
0
690
Lambda のコードストレージ容量に気をつけましょう
tattwan718
0
140
開発者から情シスまで - 多様なユーザー層に届けるAPI提供戦略 / Postman API Night Okinawa 2026 Winter
tasshi
0
210
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
210
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
610
CSC307 Lecture 03
javiergs
PRO
1
490
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
2k
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.9k
AI巻き込み型コードレビューのススメ
nealle
2
1.3k
Claude Codeと2つの巻き戻し戦略 / Two Rewind Strategies with Claude Code
fruitriin
0
140
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
610
CSC307 Lecture 05
javiergs
PRO
0
500
Featured
See All Featured
We Are The Robots
honzajavorek
0
170
Between Models and Reality
mayunak
1
190
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
150
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
Designing Experiences People Love
moore
144
24k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
210
Mobile First: as difficult as doing things right
swwweet
225
10k
Embracing the Ebb and Flow
colly
88
5k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
280
Transcript
Autocxx - RustからC++を安全かつ楽に - minaminao @vinami - 下町.rs #3 1
自己紹介 • 岡南 直哉 (@vinami) • LayerX Labs リサーチャー ◦
ブロックチェーンのスケーラビリティ、 特にシャーディング • 未踏2020で『Shargri-La』開発中 ◦ シャーディングプロトコル開発を支援 するソフトウェア ◦ Rustです 2
Autocxxとは? 3
4 RustからC++を安全かつ楽に呼ぶツール https://github.com/google/autocxx
とりあえず試してみる(定義側) Autocxxとは? 5 再帰で階乗
とりあえず試してみる(呼び出し側) Autocxxとは? 6
とりあえず試してみる(実行) Autocxxとは? 7 できた!簡単 Source: https://github.com/minaminao/autocxx/tree/shitamachi/demo
仕組み 8
三段階の Procedural macro 仕組み 9 1. bindgen でバインディングを生成 2. それを解釈し
cxx::bridge に適したバインディングへ変換 3. cxx::bridge を実行
1. bindgen でバインディングを生成 仕組み 10 • bindgen (https://github.com/rust-lang/rust-bindgen) ◦ C(C++)のヘッダファイルからRust
FFIバインディングを自動 的に生成してくれるツール
2. cxx::bridge に適したバインディングへ変換 仕組み 11 • CXX (https://github.com/dtolnay/cxx) ◦ RustからC++をunsafeなしに呼び出せるツール
◦ C++からRustも可能
開発状況 12
対応済み 開発状況 13 • Primitives (u8, etc.) • Plain-old-data structs
• std::unique_ptr of POD • std::unique_ptr of std::string • Reference to POD • Reference to std::string
未対応 開発状況 14 • std::unique_ptr of opaque types • Methods
• #defines • Constants • Enums • Structs containing UniquePtr • Structs containing strings • make_unique
RustからC++を呼ぶ重要性 15
例: Chromium RustからC++を呼ぶ重要性 16 • 2015年度以降のインパクト高のバグの内訳 https://www.chromium.org/Home/chromium-security/memory-safety
例: Chromium RustからC++を呼ぶ重要性 17 https://www.chromium.org/Home/chromium-security/memory-safety/rust-and-c-interoperability
例: Chromium RustからC++を呼ぶ重要性 18 • ChromiumのコアはC++ • RustからC++の呼び出しが重要視されている https://www.chromium.org/Home/chromium-security/memory-safety
まとめ 19
20 • AutocxxはRustからC++を安全かつ楽に呼ぶツール ◦ 絶賛開発中 ◦ C++ベースのプロジェクトは、RustからC++を呼ぶ機能を 求めており、注目されている まとめ