4 ms·
Would it be a good idea to rewrite glibc in Rust?
by marcodiego 3y ago
Would it be a good idea to rewrite glibc in Rust?
- mustache_kimono 3y agoAlready exists: https://github.com/redox-os/relibc https://github.com/redox-os/relibc
- bregma 3y agoRewrite the C standard library in Rust? I'm not sure I understand how that even makes sense. Are there problems this would solve?
- mustache_kimono 3y agoA C standard library rewritten in Rust already exists. [0] glibc has its share of CVEs, and many of the bugs are of the double free, use-after-free, buffer overflow variety. [1] [0]: https://github.com/redox-os/relibc https://github.com/redox-os/relibc [1]: https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=glibc https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=glibc
- pjmlp 3y agoMany C standard libraries are actually re-written in C++ nowadays, e.g. Microsoft and clang's, so doing it in Rust is hardly any different, it would be safer than C++, minus the usual C gotchas that are anyway exposed on the public APIs and the implementations can't do much about it (like bad pointers or size).
- toast0 3y ago> Rewrite the C standard library in Rust? I'm not sure I understand how that even makes sense. Are there problems this would solve? The C standard library isn't necessarily a standard library of C code, it's more of a standard library for C code. There's plenty of languages these days where the standard library is built in other languages, somewhere between partially and fully; some portion of the C standard library can probably benefit greatly from the memory lifetime structures of Rust; although the constant need to interface with C code may reduce the effectiveness.
- saagarjha 3y agoCan’t say whether it would be a good idea but it probably wouldn’t be a bad one.
- curt15 3y agoSince Rust doesn't yet support shared libraries, would each binary end up statically linking its own copy of glibc?
- dmytrish 3y agoRust supports dynamic libraries with C ABI very well. Technically, it also supports Rust ABI dynamic libraries, but their portability is quite fragile due to changes in the compiler. That's why Rust parts of the code are usually statically linked.
- jcranmer 3y ago#![crate_type = "cydlib"] Rust supports shared libraries.