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

linux-stable-sw-v4.19.180-sw64-2203.tar.gz 编译错误排查方法

出现:

AR arch/sw_64/chip/chip3/built-in.a AR arch/sw_64/chip/built-in.a CC kernel/futex.o {standard input}: Assembler messages: {standard input}:8070: ??? lstw and rd_f the first register must be the same {standard input}:8453: ??? lstw and rd_f the first register must be the same {standard input}:8629: ??? lstw and rd_f the first register must be the same {standard input}:8665: ??? lstw and rd_f the first register must be the same {standard input}:8693: ??? lstw and rd_f the first register must be the same make[1]: *** [scripts/Makefile.build:304?kernel/futex.o] ?? 1

这个看不懂原因,大概是两个指令的寄存器必须一致吧,而这个指令在哪呢?

打开make的调试日志

make ARCH=sw_64 CROSS_COMPILE=sw_64-sunway-linux-gnu- V=1 >x.txt

查看最后输出的命令

sw_64-sunway-linux-gnu-gcc -Wp,-MD,kernel/.futex.o.d -nostdinc -isystem /opt/swgcc/usr/bin/../lib/gcc/sw_64-sunway-linux-gnu/10.3.0/include -I./arch/sw_64/include -I./arch/sw_64/include/generated -I./include -I./arch/sw_64/include/uapi -I./arch/sw_64/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Werror=return-type -Wno-format-security -std=gnu89 -fno-PIE -pipe -ffixed-8 -mno-fp-regs -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -Wno-address-of-packed-member -O2 -fno-allow-store-data-races -Wframe-larger-than=2048 -fno-stack-protector -Wno-unused-but-set-variable -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -Wno-stringop-truncation -Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned -DKBUILD_BASENAME='"futex"' -DKBUILD_MODNAME='"futex"' -c -o kernel/.tmp_futex.o kernel/futex.c

将这个命令改成编译出汇编

sw_64-sunway-linux-gnu-gcc -Wp,-MD,kernel/.futex.o.d -nostdinc -isystem /opt/swgcc/usr/bin/../lib/gcc/sw_64-sunway-linux-gnu/10.3.0/include -I./arch/sw_64/include -I./arch/sw_64/include/generated -I./include -I./arch/sw_64/include/uapi -I./arch/sw_64/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Werror=return-type -Wno-format-security -std=gnu89 -fno-PIE -pipe -ffixed-8 -mno-fp-regs -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -Wno-address-of-packed-member -O2 -fno-allow-store-data-races -Wframe-larger-than=2048 -fno-stack-protector -Wno-unused-but-set-variable -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -Wno-stringop-truncation -Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned-DKBUILD_BASENAME='"futex"' -DKBUILD_MODNAME='"futex"' -c -o kernel/.tmp_futex.S -S kernel/futex.c

查看汇编的8070行

代码来自 futex.h,仔细对照能找到对应的函数

下面我们从linux-stable-sw-v5.10.229-sw1.3.0.tar.gz 这个代码中找对应的函数,因为linux-stable-sw-v5.10.229-sw1.3.0.tar.gz是可以编译通过的

#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg, tmp) \ __asm__ __volatile__( \ "1: lldw %0, 0(%3)\n" \ " ldi %2, 1\n" \ " wr_f %2\n" \ insn \ "2: lstw %1, 0(%3)\n" \ " rd_f %1\n" \ " beq %1, 4f\n" \ " bis $31, $31, %1\n" \ "3: .subsection 2\n" \ "4: br 1b\n" \ " .previous\n" \ " .section __ex_table, \"a\"\n" \ " .long 1b-.\n" \ " ldi $31, 3b-1b(%1)\n" \ " .long 2b-.\n" \ " ldi $31, 3b-2b(%1)\n" \ " .previous\n" \ : "=&r" (oldval), "=&r"(ret), "=&r"(tmp) \ : "r" (uaddr), "r"(oparg) \ : "memory")

果然不一样了,然后将这个代码修改过去即可

/////

qemu执行内核的代码

#!/bin/bash bin/qemu-system-sw64 \ -M core3 \ -cpu core3 \ -m 4G \ -smp 1\ -name vm001 \ -kernel ./vmlinux \ -drive file=./busybox.qcow2,if=virtio \ -append "root=/dev/vda rw console=ttyS0 ignore_loglevel notc init=/init" \ -d int,guest_errors -D a.log \ -device VGA \ -serial stdio \ -monitor telnet:localhost:7100,server,nowait,nodelay \ -s

内核编译时注意dtb要采用内嵌的,名字是chip_vt

http://www.jsqmd.com/news/688583/

相关文章:

  • ESXi Unlocker:解锁VMware ESXi平台上的macOS虚拟化能力
  • 别再死记硬背了!用‘造句游戏’和‘俄罗斯套娃’理解上下文无关文法与BNF
  • MRF8P9040N功放设计避坑指南:负载牵引迭代、稳定性电路与匹配网络的那些事儿
  • 数组与函数的理解与应用
  • YOLO26精准识别37个猫狗品种(柯基/布偶/哈士奇…)(项目源码+YOLO数据集+模型权重+UI界面+python+深度学习+远程环境部署)
  • 基于FPGA的QAM调制解调:详细实验文档
  • 如何在3分钟内免费掌握FlicFlac:Windows平台终极音频格式转换解决方案
  • 保姆级教程:5分钟搞定吴恩达机器学习全套资源(笔记+视频+作业)的本地下载与配置
  • VisualCppRedist AIO终极指南:3步解决Windows程序启动失败的完整方案
  • 避开SPI读写W25Q128的三大坑:状态寄存器、页边界与擦除耗时
  • API 中转站怎么选?一周横评 6 家后的真实结论
  • 【GPA】从驻波到光栅:解锁波动与光学的工程应用密码
  • 如何在GitHub上完美显示数学公式:终极MathJax插件完全指南
  • UE5动画混合进阶:用遮罩和惯性化节点,让你的角色动作过渡更自然(附避坑指南)
  • 告别ST依赖:手把手教你为华大HC32L130(M0+)搭建纯净KEIL5工程(附源码)
  • 微加AI:以技术创新重塑AI营销官网,为企业构筑安全、自主的线上增长核心
  • 别再手动查IP了!用Docker Compose一键搞定MySQL和phpMyAdmin(附完整yml配置)
  • 探索TrafficMonitor插件生态系统:构建桌面监控系统的终极指南
  • 保姆级教程:用BAPI_GOODSMVT_CREATE搞定SAP生产订单入库(101/262)与移库(411/412)
  • Ubuntu 彻底卸载 Docker 完整步骤
  • 别再硬啃C代码了!用Simulink的Matlab Function模块手把手教你搭建CRC8校验模型(附完整M脚本)
  • YOLO26汽车损坏检测:mAP50=92.9%,精确率88.5%,召回率89.6%(附10218张数据集)(项目源码+数据集+模型权重+UI界面+python+深度学习+远程环境部署)
  • 代谢组学实战:用SIMCA软件一步步教你验证OPLS-DA模型(附Q2Y/R2Y解读)
  • 8. 计算费用
  • 终极离线语音识别工具TMSpeech:Windows平台实时字幕与会议转录完整指南
  • 从国赛到开源:手把手教你用Arduino Mega和麦克纳姆轮复刻一个物料搬运机器人
  • 软件使用教程
  • 阿里2026最新Java面试核心讲(终极版)
  • 从咖啡因到DNA:盘点生活中无处不在的‘官能团’,看懂它们如何塑造万物
  • #广州最推荐民办学校初中一线初中外语学校素质教育学校有哪些?2026年增城等地市场选择前五排名 - 十大品牌榜