3 ms·
Dumb question (not a kernel or C developer): can't you call into code compiled from a memory safe language, like in a shared object file?
by Aachen 6y ago
Dumb question (not a kernel or C developer): can't you call into code compiled from a memory safe language, like in a shared object file?
- pjmlp 6y agoDefinitely, for example check how to make Go .so libraries. https://medium.com/swlh/build-and-use-go-packages-as-c-libraries-889eb0c19838 https://medium.com/swlh/build-and-use-go-packages-as-c-libra... Naturally the runtime also comes along, but that is another matter.
- loeg 6y agoYeah, and we're slowly slowly moving towards that model. One barrier is that some safe languages, like Rust, support far fewer target platforms than the Linux kernel does. There are C compilers for everything, but only a few Rust backends. Something similar to Wuffs[0] (posted on HN very recently), which compiles down to C, might be a good compromise between portability and safe languages. (There may be some contorted way to have Rust emit C, too.) [0]: https://github.com/google/wuffs https://github.com/google/wuffs
- nine_k 6y agoRust uses LLVM, which likely should have easier time being ported than an entire Rust compiler. Rust handles cross-compilation pretty well so you don't have to compile on an actual embedded device, or something. I wonder if an LLVM backend that issues a very simple and predictable subset of C would be a viable way to support exotic old architectures which only have a C compiler. LLVM-cbe is a thing: https://github.com/JuliaComputing/llvm-cbe https://github.com/JuliaComputing/llvm-cbe