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
800
Rustで始める競技プログラミング
minaminao
0
330
Other Decks in Programming
See All in Programming
Migration to Signals, Signal Forms, Resource API, and NgRx Signal Store @Angular Days 03/2026 Munich
manfredsteyer
PRO
0
180
Codex CLI でつくる、Issue から merge までの開発フロー
amata1219
0
240
テレメトリーシグナルが導くパフォーマンス最適化 / Performance Optimization Driven by Telemetry Signals
seike460
PRO
2
190
Mastering Event Sourcing: Your Parents Holidayed in Yugoslavia
super_marek
0
130
AIコードレビューの導入・運用と AI駆動開発における「AI4QA」の取り組みについて
hagevvashi
0
570
How to stabilize UI tests using XCTest
akkeylab
0
150
Redox OS でのネームスペース管理と chroot の実現
isanethen
0
470
ネイティブアプリとWebフロントエンドのAPI通信ラッパーにおける共通化の勘所
suguruooki
0
220
「接続」—パフォーマンスチューニングの最後の一手 〜点と点を結ぶ、その一瞬のために〜
kentaroutakeda
4
2.1k
Feature Toggle は捨てやすく使おう
gennei
0
380
へんな働き方
yusukebe
6
2.9k
L’IA au service des devs : Anatomie d'un assistant de Code Review
toham
0
110
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
GitHub's CSS Performance
jonrohan
1032
470k
Un-Boring Meetings
codingconduct
0
240
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
Thoughts on Productivity
jonyablonski
75
5.1k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
64
54k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
230
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Fireside Chat
paigeccino
42
3.9k
Why Our Code Smells
bkeepers
PRO
340
58k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
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++を呼ぶ機能を 求めており、注目されている まとめ