linux-rust

PPA description

Ubuntu kernel with Rust support enabled
=======================================

Git repository: https://git.launchpad.net/~arighi/+git/linux

Steps to compile a Rust kernel module:

1) Add this ppa

2) Install prerequisite packages and rust-for-linux + linux-rust from this ppa (and reboot)

3) Git clone the linux source code:

$ git clone https://git.launchpad.net/~arighi/+git/linux

4) Install kernel build dependencies

$ cd linux
$ fakeroot debian/rules clean
$ sudo apt build-dep .

5) Prepare the linux source to build Rust modules:

$ cp /boot/config-$(uname -r) .config
$ export PATH=/var/lib/rust-for-linux/bin:$PATH
$ make EXTRAVERSION=$(uname -r | sed "s/.*\(-.*-generic\)/\1/") LOCALVERSION= modules_prepare

5) Now you can build Rust modules using the prepared Linux source directory as your kernel source target

=======================================

Example Rust module:

== hello_rust.rs ==

// SPDX-License-Identifier: GPL-2.0

//! Rust hello world example.
//! Build with:
//! $ make KDIR=<linux_source_directory>

use kernel::prelude::*;

module! {
    type: HelloRust,
    name: "hello_rust",
    author: "Andrea Righi <email address hidden>",
    description: "Rust hello world example",
    license: "GPL v2",
}

struct HelloRust {
}

impl kernel::Module for HelloRust {
    fn init(_module: &'static ThisModule) -> Result<Self> {
        pr_info!("hello from Rust!\n");
        Ok(HelloRust{})
    }
}

impl Drop for HelloRust {
    fn drop(&mut self) {
        pr_info!("Goodbye from Rust\n");
    }
}

== Makefile ==

NAME=hello_rust

export PATH:=/var/lib/rust-for-linux/bin:$(PATH)

ifndef KERNELRELEASE
ifndef KDIR
KDIR:=/lib/modules/`uname -r`/build
endif
PWD := $(shell pwd)

all:
 $(MAKE) -C $(KDIR) M=$(PWD) modules
install:
 $(MAKE) -C $(KDIR) M=$(PWD) modules_install
clean:
 rm -f *.o *.ko *.mod* .*.cmd *.d Module.symvers modules.order
 rm -rf .tmp_versions
else
 obj-m := $(NAME).o
endif

Adding this PPA to your system

You can update your system with unsupported packages from this untrusted PPA by adding ppa:arighi/linux-rust to your system's Software Sources. (Read about installing)

sudo add-apt-repository ppa:arighi/linux-rust
sudo apt update
        
Technical details about this PPA

This PPA can be added to your system manually by copying the lines below and adding them to your system's software sources.

deb https://ppa.launchpadcontent.net/arighi/linux-rust/ubuntu oracular main 
deb-src https://ppa.launchpadcontent.net/arighi/linux-rust/ubuntu oracular main 
Signing key:
4096R/882A7727752A6461FCDDCFE5DCFA0E1546589D85 (What is this?)
Fingerprint:
882A7727752A6461FCDDCFE5DCFA0E1546589D85

For questions and bugs with software in this PPA please contact Andrea Righi.

PPA statistics

Activity
0 updates added during the past month.
View package details

Overview of published packages

Latest updates

linux-rust has no updates.