macos m1下编译linux内核
2022/7/11 5:20:07
本文主要是介绍macos m1下编译linux内核,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
说明
结合网上一些资源并折腾了一段时间后才成功的。因为完全参考无法正常编译,记录一下供有需要的,希望能对其有所帮助
uboot也可以参考编译通过
macos版本
uname -a Darwin finnmac-mini.local 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:29 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T8101 arm64
安装环境
brew install make brew install aarch64-elf-gcc brew install openssl@1.1
依赖环境
elf.h
个人在内核源码同级新建include目录,拷贝其中
编译步骤
- 下载内核
linux-5.18.9 - 配置内核
/opt/homebrew/opt/make/libexec/gnubin/make ARCH=arm64 CROSS_COMPILE=aarch64-elf- defconfig # 去掉CONFIG_KVM选项避免不必要的报错 # [ ] Virtualization ---- /opt/homebrew/opt/make/libexec/gnubin/make ARCH=arm64 CROSS_COMPILE=aarch64-elf- menuconfig
- 修改内核
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 1c451d5..0d66689 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -43,6 +43,10 @@ typedef struct { __u8 b[16]; } uuid_le; +#ifdef __APPLE__ +#define uuid_t compat_uuid_t +#endif + typedef struct { __u8 b[16]; } uuid_t;
- 编译内核
/opt/homebrew/opt/make/libexec/gnubin/make ARCH=arm64 CROSS_COMPILE=aarch64-elf- HOSTCFLAGS="-I../include -I/opt/homebrew/opt/openssl@1.1/include/" HOSTLDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib/" -j8
效果展示
(master) ~/WorkSpace/github/linux-5.18.9 ✘ ls 1.txt Kconfig README compile_commands.json init modules-only.symvers samples usr COPYING LICENSES System.map crypto ipc modules.builtin scripts virt CREDITS MAINTAINERS arch drivers kernel modules.builtin.modinfo security vmlinux Documentation Makefile block fs lib modules.order sound vmlinux.o Kbuild Module.symvers certs include mm net tools vmlinux.symvers (master) ~/WorkSpace/github/linux-5.18.9 ✘ file vmlinux vmlinux: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), statically linked, BuildID[sha1]=3cfb7eb4d00450fdddde0bf6f1c1dcef63b7ad4a, not stripped (master) ~/WorkSpace/github/linux-5.18.9 ✘
这篇关于macos m1下编译linux内核的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-18git仓库有更新,jenkins 自动触发拉代码怎么配置的?-icode9专业技术文章分享
- 2024-12-18Jenkins webhook 方式怎么配置指定的分支?-icode9专业技术文章分享
- 2024-12-13Linux C++项目实战入门教程
- 2024-12-13Linux C++编程项目实战入门教程
- 2024-12-11Linux部署Scrapy教程:新手入门指南
- 2024-12-11怎么将在本地创建的 Maven 仓库迁移到 Linux 服务器上?-icode9专业技术文章分享
- 2024-12-10Linux常用命令
- 2024-12-06谁看谁服! Linux 创始人对于进程和线程的理解是…
- 2024-12-04操作系统教程:新手入门及初级技巧详解
- 2024-12-04操作系统入门:新手必学指南