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
750
Rustで始める競技プログラミング
minaminao
0
320
Other Decks in Programming
See All in Programming
What's new in Adaptive Android development
fornewid
0
120
テスターからテストエンジニアへ ~新米テストエンジニアが歩んだ9ヶ月振り返り~
non0113
2
240
抽象化という思考のツール - 理解と活用 - / Abstraction-as-a-Tool-for-Thinking
shin1x1
1
890
Quality Gates in the Age of Agentic Coding
helmedeiros
PRO
1
110
Understanding Kotlin Multiplatform
l2hyunwoo
0
230
マッチングアプリにおけるフリックUIで苦労したこと
yuheiito
0
250
変化を楽しむエンジニアリング ~ いままでとこれから ~
murajun1978
0
570
Reactの歴史を振り返る
tutinoko
1
150
コーディングエージェント概観(2025/07)
itsuki_t88
0
450
LLMは麻雀を知らなすぎるから俺が教育してやる
po3rin
2
1.4k
脱Riverpod?fqueryで考える、TanStack Queryライクなアーキテクチャの可能性
ostk0069
0
570
それ CLI フレームワークがなくてもできるよ / Building CLI Tools Without Frameworks
orgachem
PRO
13
3.1k
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.6k
Building an army of robots
kneath
306
45k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.7k
Become a Pro
speakerdeck
PRO
29
5.4k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.9k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
720
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Visualization
eitanlees
146
16k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
18
1k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
138
34k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
860
Building a Modern Day E-commerce SEO Strategy
aleyda
42
7.4k
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++を呼ぶ機能を 求めており、注目されている まとめ