准备工具和源码
- 下载 vscode
1
| https://code.visualstudio.com/
|
- 下载内核源码
1 2 3 4
| mkdir -pv ~/ws cd ~/ws wget https://mirrors.ustc.edu.cn/kernel.org/linux/kernel/v5.x/linux-5.4.100.tar.xz tar xf linux-5.4.100.tar.xz
|
- 系统必备包
1 2 3
| # 基于 ubuntu 24.04 sudo apt install bear clangd git tmux sudo apt install build-essential bc kmod cpio flex libncurses5-dev libelf-dev libssl-dev bison rsync lz4
|
配置工具
- 编译linux码
1 2 3 4
| cd ~/ws/linux-5.4.100 make oldconfig bear -- make -j12 # 编译完成后检查根目录是否生成了 compile_commands.json 文件
|
- 配置 vscode
在 vscode 中安装clangd插件,设置clangd的参数为,如下图
1
| --compile-commands-dir=${workspaceFolder} --background-index --completion-style=detailed --header-insertion=never -log=info
|
