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
minami
September 02, 2020
Programming
2
1.4k
Autocxx -RustからC++を安全かつ楽に-
下町.rs #3
minami
September 02, 2020
Tweet
Share
More Decks by minami
See All by minami
Account/Balanceモデルのシャーディングと課題点
minaminao
1
770
Rustで始める競技プログラミング
minaminao
0
320
Other Decks in Programming
See All in Programming
AI POSにおけるLLM Observability基盤の導入 ― サイバーエージェントDXインターン成果報告
hekuchan
0
690
関数の挙動書き換える
takatofukui
4
710
CSC509 Lecture 10
javiergs
PRO
0
180
AIエージェントでのJava開発がはかどるMCPをAIを使って開発してみた / java mcp for jjug
kishida
4
680
問題の見方を変える「システム思考」超入門
panda_program
0
290
Verilator + Rust + gRPC と Efinix の RISC-V でAIアクセラレータをAIで作ってる話 RTLを語る会(18) 2025/11/08
ryuz88
0
360
チーム開発の “地ならし"
konifar
8
5.2k
PHPライセンス変更の議論を通じて学ぶOSSライセンスの基礎
matsuo_atsushi
0
160
TVerのWeb内製化 - 開発スピードと品質を両立させるまでの道のり
techtver
PRO
3
1.1k
JEP 496 と JEP 497 から学ぶ耐量子計算機暗号入門 / Learning Post-Quantum Crypto Basics from JEP 496 & 497
mackey0225
2
380
最新のDirectX12で使えるレイトレ周りの機能追加について
projectasura
0
260
競馬で学ぶ機械学習の基本と実践 / Machine Learning with Horse Racing
shoheimitani
13
13k
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
KATA
mclloyd
PRO
32
15k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Fireside Chat
paigeccino
41
3.7k
Embracing the Ebb and Flow
colly
88
4.9k
Code Review Best Practice
trishagee
72
19k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.3k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
1
30
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.7k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
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++を呼ぶ機能を 求めており、注目されている まとめ