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.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
Rails Girls Tokyo 18th GMO Pepabo Sponsor Talk
yutokyokutyo
0
200
NOT A HOTEL - 建築や人と融合し、自由を創り出すソフトウェア
not_a_hokuts
2
590
Claude Code、ちょっとした工夫で開発体験が変わる
tigertora7571
0
200
「やめとこ」がなくなった — 1月にZennを始めて22本書いた AI共創開発のリアル
atani14
0
360
モジュラモノリスにおける境界をGoのinternalパッケージで守る
magavel
0
3.4k
go directiveを最新にしすぎないで欲しい話──あるいは、Go 1.26からgo mod initで作られるgo directiveの値が変わる話 / Go 1.26 リリースパーティ
arthur1
2
490
Swift ConcurrencyでよりSwiftyに
yuukiw00w
0
250
Python’s True Superpower
hynek
0
200
Claude Code の Skill で複雑な既存仕様をすっきり整理しよう
yuichirokato
1
310
Codex の「自走力」を高める
yorifuji
0
960
日本だけで解禁されているアプリ起動の方法
ryunakayama
0
370
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
210
Featured
See All Featured
Abbi's Birthday
coloredviolet
2
5.1k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
190
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.6k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.4k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
130
Skip the Path - Find Your Career Trail
mkilby
1
72
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
62
51k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Design in an AI World
tapps
0
160
Designing for humans not robots
tammielis
254
26k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
0
450
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++を呼ぶ機能を 求めており、注目されている まとめ