Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
clang(LLVM) 编译 linux kernel 成功
Apps Section
2850
views ·
0
replies ·
To
floor
Go
lostmemory
deepin
2014-09-04 06:38
Author
据说 kernel 3.15 版初步加入了 llvm 的支持。
Google 没有结果,自己反复尝试了几次后终于成功了。
下载 kernel 最新稳定版(这里用的是3.16),链接
http://mirrors.ustc.edu.cn/linux-kernel/v3.x/linux-3.16.tar.xz
注:中科大的源
解压到任意文件夹,这里假设是 /home/XXX(你的用户名)/linux-3.16
一、安装必要的工具软件(debian 系的为例)
sudo apt-get install kernel-package fakeroot patch
Copy the Code
(build-essential gcc g++ 等会自动带上)
sudo apt-get install llvm
Copy the Code
(clang 会自动带上)
sudo apt-get install libncurses5-dev
Copy the Code
(一个简易的图形库,不装执行 make menuconfig 报错)
二、切换到源码根目录下
cd ~/linux-3.16
Copy the Code
(~表示用户目录 /home/XXX(你的用户名) )
三、修改编译选项
make defconfig
Copy the Code
(这个选项会根据你机器的CPU架构来载入默认配置)
make localmodconfig
Copy the Code
(这个选项会去掉你从未使用过得模块,从而达到自动精简的目的)
make menuconfig
Copy the Code
(纯手动选择,需要一定的知识,可以参考 金步国 的资料
http://works.jinbuguo.com/kernel/longte ... tions.html
)
新手就做 1 2 步即可。
四、补丁部分
到 llvm.linuxfoundation.org 下载补丁包。
注:我用的是 x86_64 其他平台请修改
wget http://buildbot.llvm.linuxfoundation.org/configs/x86_64/kernel-patches.tar.bz2
Copy the Code
五、打上补丁(在内核源码根目录(~/linux-3.16)下执行)
bzcat patch_dir/kernel-patches.tar.bz2 | patch -p1
Copy the Code
(patch_dir) 是下载补丁的路径
补丁显示有错误,估计是版本比较老
手动修改 ~/linux-3.16/arch/x86/makefile 23行
$(call cc-option, -fno-unit-at-a-time))
Copy the Code
改为
$(call cc-option, -no-integrated-as,))
Copy the Code
六、编译源码并打包
根据补丁官网的指示:
make HOSTCC=clang CC=clang
Copy the Code
打包为 deb:
make deb-pkg
Copy the Code
七、安装
cd ..
Copy the Code
(切换到上级目录,并安装软件包)
sudo dpkg -i linux-XXX(软件包名)
Copy the Code
记住要先装 linux-image 包
八、重启
最后重启电脑,在开机后按住 shift 不放,看见内核启动选项,选择你编译的版本即可。
Reply
Like 0
Favorite
View the author
All Replies
No replies yet
Please
sign
in first
Featured Collection
Change
UOS AI 2.8 Released! Three New Intelligent Agents & Major Evolution
Solid Q&A | deepin 25 Common Questions – The Immutable System Edition
New Thread
Popular Ranking
Change
Deepin 25.0.1 installation no desktop, Thinkpad T480
Popular Events
More
Google 没有结果,自己反复尝试了几次后终于成功了。
下载 kernel 最新稳定版(这里用的是3.16),链接
http://mirrors.ustc.edu.cn/linux-kernel/v3.x/linux-3.16.tar.xz
注:中科大的源
解压到任意文件夹,这里假设是 /home/XXX(你的用户名)/linux-3.16
一、安装必要的工具软件(debian 系的为例)
二、切换到源码根目录下
三、修改编译选项
新手就做 1 2 步即可。
四、补丁部分
到 llvm.linuxfoundation.org 下载补丁包。
注:我用的是 x86_64 其他平台请修改
五、打上补丁(在内核源码根目录(~/linux-3.16)下执行)
(patch_dir) 是下载补丁的路径
补丁显示有错误,估计是版本比较老
手动修改 ~/linux-3.16/arch/x86/makefile 23行
六、编译源码并打包
根据补丁官网的指示:
七、安装
八、重启
最后重启电脑,在开机后按住 shift 不放,看见内核启动选项,选择你编译的版本即可。