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.qastaging.content.paddev.net/arighi/linux-rust/ubuntu lunar main 
deb-src https://ppa.qastaging.content.paddev.net/arighi/linux-rust/ubuntu lunar main 
Signing key:
4096R/1FFEA0F2681BB21A6D5F86F9137DF367D1707550 (What is this?)
Fingerprint:
1FFEA0F2681BB21A6D5F86F9137DF367D1707550

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

13 of 3 results
Package Version Uploaded by
linux-meta-rust 6.2.0.1005.5 Andrea Righi ()
linux-rust 6.2.0-1005.5 Andrea Righi ()
rust-for-linux 1.62.0ubuntu3 Andrea Righi ()
13 of 3 results

Latest updates

  • linux-rust 76 weeks ago
    Successfully built
  • linux-meta-rust 76 weeks ago
    Successfully built
  • rust-for-linux 76 weeks ago
    Successfully built