3 ms·
I played around with getting a Rust kernel module to work before. And I eventually got a "hello world" in my dmesg. But what I realized in so doing was that see
by drvdevd 10y ago
I played around with getting a Rust kernel module to work before. And I eventually got a "hello world" in my dmesg. But what I realized in so doing was that seemingly 90% of the higher level features of Rust were lost to my module -- essentially I got the language memory security features (borrowing and ownership) but with very little standard library help, which made the whole endeavour seem much less practical still than just using C and libc (because I would have to reimplement a lot of that functionality in Rust -- Kernel Rust, if you will).
I think if the Rust communtiy wants to make it somehow to the Linux (or other UNIX or windows) Kernel space, there needs to be an effort to build Kernel Rust, if there isn't one already..
- gdamjan1 10y agowell, you can't use libc for a kernel module either :)
- drvdevd 10y agoNo, but there's 'kernel C' (not an actual/official name) with a large reproduction of much of libc ready for use there. printk() is a good example which actually has a format string implementation (https://www.kernel.org/doc/Documentation/printk-formats.txt https://www.kernel.org/doc/Documentation/printk-formats.txt)
- gdamjan1 10y agoright, that shouldn't be hard to map to rust I guess
- dbaupp 10y agoWhen were you doing this? There's now a large chunk of the standard library[1] that's explicitly designed to be used in bare-metal/zero-dependency situations, and it even includes "fancy" things like the formatting infrastructure[2] (it has to be hooked up to a writable/IO device, but that's just a trait implementation away) and string processing, certainly more than the zero-allocation subset of libc. [1]: https://doc.rust-lang.org/core/ https://doc.rust-lang.org/core/ [2]: https://doc.rust-lang.org/core/fmt/ https://doc.rust-lang.org/core/fmt/
- drvdevd 10y agoIt has been at least 6 months and it's possible I just missed this! That's quite cool. Thanks! I will give this a try.