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

构建Linux From Scratch 12.3 systemd时GCC 14.2.0编译失败求助

LFS 12.3 systemd版第8章GCC第三次编译失败(mulxc3函数报错)

正在构建Linux From Scratch 12.3 systemd版本系统,第8章的第三次GCC编译失败,问题出在mulxc3函数。日志文件最后几行如下:

/sources/gcc-14.2.0/build/./gcc/xgcc -B/sources/gcc-14.2.0/build/./gcc/ -B/usr/x86_64-pc-linux-gnu/bin/ -B/usr/x86_64-pc-linux-gnu/lib/ -isystem /usr/x86_64-pc-linux-gnu/include -isystem /usr/x86_64-pc-linux-gnu/sys-include    -g -O2 -O2  -g -O2 -DIN_GCC   -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fpic -mlong-double-80 -DUSE_ELF_SYMVER -fcf-protection -mshstk -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector  -fpic -mlong-double-80 -DUSE_ELF_SYMVER -fcf-protection -mshstk -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include -I../../../libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS  -DUSE_TLS  -o _mulxc3.o -MT _mulxc3.o -MD -MP -MF _mulxc3.dep -DL_mulxc3 -c ../../../libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
during RTL pass: expand
In file included from ../../../libgcc/libgcc2.c:56:
../../../libgcc/libgcc2.c: In function '__mulxc3':
../../../libgcc/libgcc2.h:269:17: internal compiler error: Illegal instruction
  269 | #define __N(a)  __ ## a
      |                 ^~
../../../libgcc/libgcc2.h:370:33: note: in expansion of macro '__N'
  370 | #define __mulxc3                __N(mulxc3)
      |                                 ^~~
../../../libgcc/libgcc2.c:2667:25: note: in expansion of macro '__mulxc3'
 2667 | #define _CONCAT3(A,B,C) A##B##C
      |                         ^
../../../libgcc/libgcc2.c:2666:25: note: in expansion of macro '_CONCAT3'
 2666 | #define CONCAT3(A,B,C)  _CONCAT3(A,B,C)
      |                         ^~~~~~~~
../../../libgcc/libgcc2.c:2697:1: note: in expansion of macro 'CONCAT3'
 2697 | CONCAT3(__mul,MODE,3) (MTYPE a, MTYPE b, MTYPE c, MTYPE d)
      | ^~~~~~~
0x561776d6d973 crash_signal
    ../../gcc/toplev.cc:319
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

第5章和第6章的前两次GCC编译均能正常完成。

各次GCC构建配置

第5章

../configure                  \
    --target=$LFS_TGT         \
    --prefix=$LFS/tools       \
    --with-glibc-version=2.41 \
    --with-sysroot=$LFS       \
    --with-newlib             \
    --without-headers         \
    --enable-default-pie      \
    --enable-default-ssp      \
    --disable-nls             \
    --disable-shared          \
    --disable-multilib        \
    --disable-threads         \
    --disable-libatomic       \
    --disable-libgomp         \
    --disable-libquadmath     \
    --disable-libssp          \
    --disable-libvtv          \
    --disable-libstdcxx       \
    --enable-languages=c,c++

第6章

../configure                                       \
    --build=$(../config.guess)                     \
    --host=$LFS_TGT                                \
    --target=$LFS_TGT                              \
    LDFLAGS_FOR_TARGET=-L$PWD/$LFS_TGT/libgcc      \
    --prefix=/usr                                  \
    --with-build-sysroot=$LFS                      \
    --enable-default-pie                           \
    --enable-default-ssp                           \
    --disable-nls                                  \
    --disable-multilib                             \
    --disable-libatomic                            \
    --disable-libgomp                              \
    --disable-libquadmath                          \
    --disable-libsanitizer                         \
    --disable-libssp                               \
    --disable-libvtv                               \
    --enable-languages=c,c++

第8章

../configure --prefix=/usr            \
             LD=ld                    \
             --enable-languages=c,c++ \
             --enable-default-pie     \
             --enable-default-ssp     \
             --enable-host-pie        \
             --disable-multilib       \
             --disable-bootstrap      \
             --disable-fixincludes    \
             --with-system-zlib

环境说明

在VirtualBox(Windows 10主机)中使用Linux Mint 21作为基础系统,除GCC外,所有目标系统组件都使用-march=slm优化选项交叉编译,也尝试过-march=core2选项以及不使用优化,但结果一致。

解决思路与尝试方案

  • 清理环境变量:检查第8章编译时的CFLAGS、CXXFLAGS等环境变量,确保没有残留交叉编译的-march或其他可能冲突的参数,编译GCC自身时应使用原生兼容的编译选项
  • 调整GCC配置参数:尝试移除--enable-host-pie选项,或者添加--disable-fcf-protection、--disable-mshstk(日志显示编译时启用了这两个特性,可能虚拟机CPU不完全支持)
  • 调整虚拟机CPU设置:在VirtualBox中修改虚拟机的CPU配置,比如选择具体的CPU型号(如Intel Core i7-6700K),关闭"Nested VT-x/AMD-V",或者启用"PAE/NX"等兼容选项
  • 彻底重建GCC:删除第8章的GCC构建目录,重新解压源码,严格按照LFS手册步骤配置编译,避免残留旧构建文件的干扰
  • 验证前置依赖:确认第6章编译的GCC组件已完整安装到目标系统,尤其是/usr/lib下的libgcc相关文件权限和完整性正常

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.12 18:05:56