编译Linux内核开启Rust支持
编译Rust for Linux过程记录
安装依赖
1 | git clone https://github.com/Rust-for-Linux/linux.git -b rust --single-branch |
配置与编译
1 | for amd64 |
运行
1 | 1. 从https://people.debian.org/~gio/dqib/下载预编译好的debian,解压 |
错误记录
执行
make LLVM=1 rustavailable
出现./scripts/rust_is_available.sh: 21: arithmetic expression: expecting primary:
原因分析:在
rust_is_available.sh
里加set -x
可发现是bindgen_libclang_cversion
为空,因没有安装libclang引起的。解决方法:安装clang和llvm
menuconfig里没有找到Rust samples
原因分析:在General setup -> Rust support没有选中,选中它即解决此问题。
执行
make LLVM=1
提示linker 'ld.lld' not found
原因分析:没有安装它,通过
sudo apt install lld
安装执行
make LLVM=1
提示'libelf.h' file not found
和'gelf.h' file not found
解决方法:
sudo apt install libelf-dev
执行
make ARCH=arm64 CROSS_COMPILE=aarch64_linux_gnu LLVM=1 -j
提示unknown target triple 'aarch64_linux_gnu'
解决方法:使用
CLANG_TRIPLE=
执行
make ARCH=riscv LLVM=1 LLVM_IAS=0 -j
提示ERROR: modpost: "riscv_cbom_block_size" undefined
原因分析:使用gcc也报同样的问题。这是内核bug,待修复。
解决方法:关闭”Virtualization”以绕过此问题。