[tor-bugs] #24249 [Core Tor/Tor]: Create automated mechanism for C/Rust types to stay in sync

Tor Bug Tracker & Wiki blackhole at torproject.org
Sat Jun 9 15:51:47 UTC 2018


#24249: Create automated mechanism for C/Rust types to stay in sync
--------------------------+------------------------------
 Reporter:  chelseakomlo  |          Owner:  chelseakomlo
     Type:  enhancement   |         Status:  assigned
 Priority:  Medium        |      Milestone:
Component:  Core Tor/Tor  |        Version:
 Severity:  Normal        |     Resolution:
 Keywords:  rust          |  Actual Points:
Parent ID:                |         Points:
 Reviewer:                |        Sponsor:
--------------------------+------------------------------

Comment (by chelseakomlo):

 Initial implementation at `http://github.com/chelseakomlo/types-parser`-
 documentation is currently a bit rough so please let me know how this can
 be further improved.

 One TODO that I'm currently working on is a suggestion from Nick, which is
 to allow the ability to give items a prefix in C that they don't have in
 Rust. That is fairly easy and I'll fix this up.

 This tool can be extended to enums and structs, but I think we should take
 a look at Bindgen again before deciding we want to build capacity for
 generating FFI.

 A few questions:
 1) Is this something we want in the core tor codebase, or should this be
 an external tool (as it relies on `https://github.com/dtolnay/syn`? I'm
 leaning towards this remaining external but would be interested to hear
 what others think. One argument for making this internal is that we could
 have a make task that would search for all `_generated.rs` files and
 generate corresponding c files (as opposed to having this be a manual task
 during development).

 2) What code conventions do we want for where generated files should be in
 the tor codebase? I think it might be good to have a separate file for
 each subdomain/subsystem- i.e, bridges, hidden services, dirauths, etc,
 but it would be good to also logically be able to track easily which files
 are generated or not. Curious what others think.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/24249#comment:4>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list