fishinabarrel / linux-kernel-module-rust

Framework for writing Linux kernel modules in safe Rust
GNU General Public License v2.0
1.33k stars 118 forks source link

Upstream support for building rust modules to mainline kernel #139

Open alex opened 5 years ago

alex commented 5 years ago

Kees thinks this is a good next step -- what we can do is upstream support for building rust with an arbitrary target file + xbuild, but not include any of our code (including our build.rs).

We think we want to support something that looks roughly like:

obj-m += helloworld.o
helloworld-crates := Cargo.toml

all:
        $(MAKE) -C $(KDIR) M=$(CURDIR)

clean:
        $(MAKE) -C $(KDIR) M=$(CURDIR) clean
alex commented 5 years ago

New concept, inspired by the kernel's ASN.1 support (yeah, that's what you want to hear...)

obj-m += helloworld.rust.o

all:
        $(MAKE) -C $(KDIR) M=$(CURDIR)

clean:
        $(MAKE) -C $(KDIR) M=$(CURDIR) clean

Things that are .rust.o would be assumed that M was a directory with a Cargo project. You should probably be able to optionally override that, but it'd be the default.

alex commented 5 years ago

Started hacking on this here: https://github.com/alex/linux/pull/3

kees commented 5 years ago

Why not include the linux-kernel-module code as part of it? That'd be needed by anyone doing kernel modules in rust. (Though it likely needs to be a separate module somehow... I haven't looked at how Rust handles shared objects...)

alex commented 5 years ago

My thought was to keep the size of the individual pieces to land as small as possible: Landing build system support is smaller than landing the full SDK, so we should do build system only first.