3 ms·
I have actually started to do this to see for myself how much work it would be http://blog.dkhenry.com/2016/02/17/deciding-to-rewrite-getaddrinfo-in-rust/ http
by dkhenry 11y ago
I have actually started to do this to see for myself how much work it would be
http://blog.dkhenry.com/2016/02/17/deciding-to-rewrite-getaddrinfo-in-rust/ http://blog.dkhenry.com/2016/02/17/deciding-to-rewrite-getad...
- rtpg 11y agoThanks for doing this... I think the way to tackle a rust glibc rewrite: Step 0 - write a code generator that just generates rust code that call the C versions of glibc symbols ( based off of the publicly exposed API in the library files). Get test suite to run Step 1 - Make that rust code generate a 100% drop-in replacement fro the C symbols (maybe this requires injecting version numbers) Step 2 - write the `getaddrinfo` replacement in Rust ??? Step 4 - have all of glibc ported EDIT: Does anyone know of any gotchas with linking that would cause this to happen? Seriously considering taking a day off to do step O.
- JoshTriplett 11y agoFor step 0, look at Rust's libc crate. For step 1, you'd need to carefully look at glibc's ABI, which is even more complicated than its API due to backward compatibility and symbol versioning.
- dkhenry 11y agoYeah ABI compatibility might be problematic, my currently plan is to LD_PRELOAD what I have to test it for speed. I have the feeling that rust could mock the ABI and serve as a general replacement, but first things first is it even fast enough to use at the lowest levels of the system.
- steveklabnik 11y agoIf it's not, please file bugs. It should be.
- tayo42 11y agoThis sounds interesting. I wouldn't even know where to start.
- Eridrus 11y agoIf you get anywhere, you may be interested in this program: https://www.google.com/about/appsecurity/patch-rewards/ https://www.google.com/about/appsecurity/patch-rewards/
- blahdeeblah 11y agoThe mere existence of getaddrinfo is a symptom of the disease. Just look at it. It lacks a clear interface. It's designed for calling code which is like, "Gee, I don't know exactly what I've got. Maybe it's a local IPv6 address, maybe it's a remote hostname. But I might want to bind it. Or maybe connect to it. I'll get back a list of these things which might be useful. Most likely I'll choose the first one or maybe write an ad-hoc filter to pick the one I actually want." Systems programming doesn't have to be this crappy. I get it, the idea is to replace this core low-level library with something you could maybe run C programs on top of. But damn, that is a crappy interface (which is specified by both an ISO standard and an IETF RFC so I must be an idiot, right?).