You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GCC编译生成损坏依赖文件问题排查求助

GCC 12.2.0 Bootstrap编译随机性文件损坏问题排查方向

环境信息

  • 待编译版本:gcc v12.2.0(使用make bootstrap编译)
  • 编译工具链:gcc v11.2.0
  • 配置命令:
    ../configure --prefix=/usr --libdir=/usr/lib64 --mandir=/usr/man --infodir=/usr/info --enable-shared --enable-bootstrap --enable-languages=ada,c,c++,d,fortran,go,lto,objc,obj-c++ --enable-threads=posix --enable-checking=release --enable-objc-gc --with-system-zlib --enable-libstdcxx-dual-abi --with-default-libstdcxx-abi=new --disable-libstdcxx-pch --disable-libunwind-exceptions --enable-__cxa_atexit --disable-libssp --enable-gnu-unique-object --enable-plugin --enable-lto --disable-install-libiberty --disable-werror --with-gnu-ld --with-isl --verbose --with-arch-directory=amd64 --disable-gtktest --enable-clocale=gnu --disable-multilib --target=x86_64-slackware-linux --build=x86_64-slackware-linux --host=x86_64-slackware-linux
    
  • 构建环境:Slackware x86_64 v15.0 Docker镜像
  • 主机环境:已在两台不同主机复现——Ubuntu x86_64 v20.04.5、Windows 10

问题现象

约50%概率构建失败,错误集中在d/.deps/目录下的随机文件,报错信息分为两种:

  1. *** target pattern contains no '%'. Stop.
  2. *** missing separator. Stop.

典型报错日志

make[4]: Entering directory '/tmp/gcc-12.2.0/gcc.build.lnx/prev-gcc'
rm -f stamp-gnatlib2-rts stamp-tools
d/.deps/opover.Po:1: *** target pattern contains no '%'.  Stop.
make[4]: Leaving directory '/tmp/gcc-12.2.0/gcc.build.lnx/prev-gcc'
make[3]: *** [Makefile:3279: stmp-fixinc] Error 2
make[3]: *** Waiting for unfinished jobs....
rm gcc.pod gfortran.pod gccgo.pod gdc.pod
make[3]: Leaving directory '/tmp/gcc-12.2.0/gcc.build.lnx/gcc'
make[2]: *** [Makefile:5005: all-stage2-gcc] Error 2
make[2]: Leaving directory '/tmp/gcc-12.2.0/gcc.build.lnx'
make[1]: *** [Makefile:30918: stage2-bubble] Error 2
make[1]: Leaving directory '/tmp/gcc-12.2.0/gcc.build.lnx'
make: *** [Makefile:31130: bootstrap] Error 2

损坏文件的字节特征

出错文件存在异常字节(如opover.o与:之间的f2 3a fd 7f),十六进制示例:

00000000  64 2f 6f 70 6f 76 65 72  2e 6f f2 3a fd 7f 3a 20  |d/opover.o.:..: |
00000010  2e 2e 2f 2e 2e 2f 67 63  63 2f 64 2f 64 6d 64 2f  |../../gcc/d/dmd/|
00000020  6f 70 6f 76 65 72 2e 64  20 5c 0a 20 2f 74 6d 70  |opover.d \. /tmp|
00000030  2f 67 63 63 2d 31 32 2e  32 2e 30 2f 67 63 63 2f  |/gcc-12.2.0/gcc/|
00000040  64 2f 64 6d 64 2f 63 6c  6f 6e 65 2e 64 20 2f 74  |d/dmd/clone.d /t|

这些异常字符未在make输出中显示。

可能的排查方向

  1. 并行编译的文件系统竞争
    Docker的overlayfs存储层可能存在写入延迟,并行编译时多进程读写.deps目录易引发文件内容损坏。可尝试:

    • 将编译目录挂载到主机物理磁盘,避开overlayfs
    • 降低并行线程数(如make -j1 bootstrap),验证是否稳定
  2. 内存硬件故障
    随机文件损坏可能由内存错误导致,用memtest86+检测主机内存,排除硬件层面的内存 corruption。

  3. GCC D语言前端bug
    错误集中在D语言相关的.deps目录,大概率和D语言前端的依赖生成逻辑有关:

    • 修改configure命令,从--enable-languages中移除d,验证编译是否稳定
    • 检查GCC 12.x后续小版本的补丁,确认是否已有相关修复
  4. make版本兼容性
    检查Slackware 15.0自带的make版本,尝试升级到最新稳定版后重新编译,排除构建工具的兼容性问题。

  5. 磁盘IO错误
    主机或容器磁盘的潜在IO问题可能导致写入字节损坏,用smartctl检测主机磁盘健康状态,或更换存储介质验证。

内容的提问来源于stack exchange,提问作者Matt Cole

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 18:01:29