当前位置: 首页 > news >正文

使用llvm 编译最新的linux 内核(LoongArch)

1. 准备交叉工具链

llvm 使用了最新的llvm-17, 编译方法见:编译LoongArch的llvm交叉工具链

gcc 从linux 官方下载:http://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-loongarch64-linux.tar.xz

发布llvm和gcc 相应的环境变量

$ llc --version
LLVM (http://llvm.org/):LLVM version 17.0.0rcOptimized build.Default target: x86_64-unknown-linux-gnuHost CPU: haswellRegistered Targets:aarch64     - AArch64 (little endian)aarch64_32  - AArch64 (little endian ILP32)aarch64_be  - AArch64 (big endian)amdgcn      - AMD GCN GPUsarm         - ARMarm64       - ARM64 (little endian)arm64_32    - ARM64 (little endian ILP32)armeb       - ARM (big endian)avr         - Atmel AVR Microcontrollerbpf         - BPF (host endian)bpfeb       - BPF (big endian)bpfel       - BPF (little endian)hexagon     - Hexagonlanai       - Lanailoongarch32 - 32-bit LoongArchloongarch64 - 64-bit LoongArchmips        - MIPS (32-bit big endian)mips64      - MIPS (64-bit big endian)mips64el    - MIPS (64-bit little endian)mipsel      - MIPS (32-bit little endian)msp430      - MSP430 [experimental]nvptx       - NVIDIA PTX 32-bitnvptx64     - NVIDIA PTX 64-bitppc32       - PowerPC 32ppc32le     - PowerPC 32 LEppc64       - PowerPC 64ppc64le     - PowerPC 64 LEr600        - AMD GPUs HD2XXX-HD6XXXriscv32     - 32-bit RISC-Vriscv64     - 64-bit RISC-Vsparc       - Sparcsparcel     - Sparc LEsparcv9     - Sparc V9systemz     - SystemZthumb       - Thumbthumbeb     - Thumb (big endian)ve          - VEwasm32      - WebAssembly 32-bitwasm64      - WebAssembly 64-bitx86         - 32-bit X86: Pentium-Pro and abovex86-64      - 64-bit X86: EM64T and AMD64xcore       - XCore

2. 下载内核源码

从https://www.kernel.org/ 下载最新的版本(linux-next) ,本次用的是linux 6.6rc1

3. 编译内核

$ cd linux-next
$ export ARCH=loongarch$ make O=./build_llvm LLVM=1 loongson3_defconfig
$ make O=./build_llvm LLVM=1 -j4
make[1]: 进入目录“/home/loongson/work/oh/kernel/linux-next-next-20230906/build_llvm”GEN     MakefileCALL    ../scripts/checksyscalls.shAS      arch/loongarch/kernel/genex.o
<instantiation>:11:9: error: Cannot represent a difference across sections.dword 768b-766b^
<instantiation>:11:9: error: Cannot represent a difference across sections                                                              .dword 768b-766b^
<instantiation>:11:9: error: Cannot represent a difference across sections                                                              .dword 768b-766b^
<instantiation>:11:9: error: Cannot represent a difference across sections 

出现上面的错误是因为不relocalable 特性,修改内核配置 关掉CONFIG_RELOCATABLE

CONFIG_CRASH_DUMP=n
CONFIG_RELOCATABLE=n   
$ make O=./build_llvm LLVM=1 -j4../arch/loongarch/include/asm/percpu.h:20:4: error: compiler support for the model attribute is necessary when a recent assembler is used20 | #  error compiler support for the model attribute is necessary when a recent assembler is used|    ^

出现上面的错误是因为不module 也还不支持,修改内核配置 关掉CONFIG_MODULES

 CONFIG_MODULES=n
http://www.lryc.cn/news/156970.html

相关文章:

  • Using Multiple RDF Knowledge Graphs for Enriching ChatGPT Responses
  • 【Hive-小文件合并】Hive外部分区表利用Insert overwrite的暴力方式进行小文件合并
  • 位运算 |(按位或) (按位与) ^(按位异或)
  • Qt应用开发(基础篇)——复选按钮 QCheckBox 单选按钮 QRadioButton
  • AERMOD模型大气环境影响评价
  • 递归组装树结构的数据
  • 企业架构LNMP学习笔记7
  • 开店星小程序上架教程和后台Request failed with status code 500[undefined]问题处理
  • 第一百三十六回 WillPopScope组件
  • 【论文爬虫】自动将论文详细信息直送notion并自动下载(含源码)
  • Android知识点整理
  • JSON与电子表格
  • Oracle创建用户、授权视图权限
  • MT4移动端应用指南:随时随地进行交易
  • 【数据挖掘】学习笔记
  • MyBatis-Plus排除不必要的字段
  • webpack打包
  • 【Java SE】抽象类与接口
  • HTML <time> 标签
  • C++的向上转型
  • Android开发-Mac Android开发环境搭建(Android Studio Mac环境详细安装教程,适合新手)...
  • 公园气象站:用科技力量,感知气象变化
  • mysql-norebuild的ddl测试
  • 上海控安SmartRocket系列产品推介(六):SmartRocket PeneX汽车网络安全测试系统
  • [TQLCTF 2022]simple_bypass
  • 【每日一题】657. 机器人能否返回原点
  • Java反射:探索对象创建与类信息获取
  • 【100天精通Python】Day55:Python 数据分析_Pandas数据选取和常用操作
  • f12工具
  • Spring MVC实现RESTful