Seems like a good time to learn rust

no comments (yet)

sorted by: hot top controversial new old
there doesn't seem to be anything here
13 comments in c/linux@programming.dev view that post
[–] 15 points 2 weeks ago (9 children)

If someone makes a Rust-free fork, please name it Stainless.

  • source
  • hideshow 9 child comments
  • [–] -1 points 2 weeks ago (8 children)

    Is very easy to build the kernel without rust, and is the default scenario

  • source
  • parent
  • hideshow 8 child comments
  • [–] 2 points 2 weeks ago (7 children)
  • [–] 0 points 2 weeks ago* (6 children)

    The default is GCC, and you need to build the kernel with clang to build the kernel with the rust support, how is possible rust arrives by default? https://docs.kernel.org/rust/quick-start.html

    Maybe is the default in your distribution, but is not the default in the kernel

  • source
  • parent
  • hideshow 6 child comments
  • [–] 1 point 2 weeks ago (5 children)

    you need to build the kernel with clang to build the kernel with the rust support

    I believe this statement is incompatible with how C works. The kernel can load modules written in any language as long as it outputs a .ko, so there can be no technical requirement for building the rest of the kernel itself with clang.

  • source
  • parent
  • hideshow 5 child comments
  • [–] 0 points 2 weeks ago (4 children)

    You can't load modules built with a different compiler. The modules aren't external programs, the modules are literally part of the kernel. And if you want to use a module wrote in rust you also need to have built in the rust support in the kernel

  • source
  • parent
  • hideshow 4 child comments
  • [–] 1 point 1 week ago* (last edited 1 week ago) (3 children)

    You can’t load modules built with a different compiler.

    Sure you can. There's even multiple guides for how to write C++ kernel modules, which inherently is going to use a different compiler than what was used for the kernel itself. BOSS Linux even writes C++ kernel modules.

    if you want to use a module wrote in rust you also need to have built in the rust support in the kernel

    Only if the module uses rust-specific interfaces in the kernel, otherwise it can be assembled into a .ko to have plain C-style symbols loaded by the kernel like normal.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 1 point 1 week ago (2 children)

    The C and C++ compilers use the same backends (and rust to, llvm), just try to build a module with clang for a kernel build with GCC, or it fails in compile phase or when you try to load the module. You can write a module in the lenguaje that you want if you use the same backend, but if we are talking about avoiding to use a kernel with rust, man is the default in the kernel, just read the config, rust is disabled

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 1 week ago (1 child)

    just try to build a module with clang for a kernel build with GCC

    I did just now, and it worked fine.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 1 week ago

    Maybe depends for the configs, in my case I need to build the external modules with the same compiler, and in lkml you can see a few warnings about do not mix the compiles: https://lkml.iu.edu/hypermail/linux/kernel/2107.3/08102.html

    For rust modules you need to use LVM=1 because you need to use all the LVM stack instead of the GCC stack, if I define in the Makefike the LVM=1 then the build fails with a lot of clang: error: unknown argument: ...

    So for me is impossible to build my rust modules for a kernel build with a GCC kernel

  • source
  • parent
  • [–] -1 points 2 weeks ago (1 child)

    How much of this will be slop?

  • source
  • hideshow 1 child comment
  • [–] -5 points 2 weeks ago

    Rust is slower... Shouldn't be used in the kernel...

  • source