rust current on linux kernel only support x86_64 or um.
1 install libclang-17-dev
$ sudo vim /etc/apt/sources.list
add
deb http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main
deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main
$ sudo apt update
错误:7 https://apt.llvm.org/focal llvm-toolchain-focal-17 InRelease
由于没有公钥,无法验证下列签名: NO_PUBKEY 15CF4D18AF4F7421
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 15CF4D18AF4F7421
$ sudo apt update
$ sudo apt install libclang-17-dev
2 download llvm from kernel
https://mirrors.edge.kernel.org/pub/tools/llvm/
https://mirrors.edge.kernel.org/pub/tools/llvm/files/llvm-17.0.6-x86_64.tar.gz
3 tar -zxvf llvm-17.0.6-x86_64.tar.gz /media/fmin/nvme/llvm-17.0.6-x86_64
$ export PATH=$PATH:/media/fmin/nvme/llvm-17.0.6-x86_64/bin
4 following guide Documentation/rust/quick-start.rst
$ rustup override set $(scripts/min-tool-version.sh rustc)
$ rustup component add rust-src
$ cargo install --locked --version $(scripts/min-tool-version.sh bindgen) bindgen-cli
$ rustup component add rustfmt
$ rustup component add clippy
$ make LLVM=1 rustavailable
5 build kernel with rust enable
$ make x86_64_defconfig
$ make menuconfig
enable below configs
CONFIG_SAMPLES_RUST=y
CONFIG_SAMPLE_RUST_MINIMAL=y
CONFIG_SAMPLE_RUST_PRINT=y
CONFIG_SAMPLE_RUST_HOSTPROGS=y
$ time make LLVM=1 -j8
$ make LLVM=1 rust-analyzer