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

CentOS7.5编译glibc-2.28遇__sigsetjmp参数声明错误求助

在CentOS 7.5编译glibc-2.28时遇到__sigsetjmp参数类型声明错误的求助

环境与操作步骤

  • 系统:CentOS 7.5
  • 已更新工具版本:make 4.8、gcc 12.2.0
  • 编译glibc-2.28的执行步骤:
tar zxf glibc-2.28.tar.gz && cd glibc-2.28
mkdir build && cd build

../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

make -j 8

编译错误信息

编译过程中触发如下错误:

inux-gnu/12.2.0/include-fixed -isystem /usr/include -D_LIBC_REENTRANT -include /root/source/glibc-2.28/build/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h       -DTOP_NAMESPACE=glibc \
        -DGEN_AS_CONST_HEADERS -x c - \
        -MD -MP -MF /root/source/glibc-2.28/build/tcb-offsets.h.dT -MT '/root/source/glibc-2.28/build/tcb-offsets.h.d /root/source/glibc-2.28/build/tcb-offsets.h'
In file included from ../include/pthread.h:1,
                 from ../nptl/../nptl_db/thread_db.h:25,
                 from ../nptl/descr.h:32,
                 from ../sysdeps/x86_64/nptl/tls.h:130,
                 from ../sysdeps/unix/sysv/linux/x86_64/sysdep.h:24,
                 from <stdin>:1:
../sysdeps/nptl/pthread.h:744:47: error: argument 1 of type 'struct __jmp_buf_tag *' declared as a pointer [-Werror=array-parameter=]
  744 | extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL;
      |                         ~~~~~~~~~~~~~~~~~~~~~~^~~~~
In file included from ../include/setjmp.h:2,
                 from ../nptl/descr.h:24:
../setjmp/setjmp.h:54:46: note: previously declared as an array 'struct __jmp_buf_tag[1]'
   54 | extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROWNL;
      |                         ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [../Makerules:287: /root/source/glibc-2.28/build/tcb-offsets.h] Error 1
make[2]: Leaving directory '/root/source/glibc-2.28/csu'
make[1]: *** [Makefile:258: csu/subdir_lib] Error 2
make[1]: Leaving directory '/root/source/glibc-2.28'
make: *** [Makefile:9: all] Error 2

已尝试的无效操作

  • 执行make clean后重新编译
  • 删除glibc-2.28文件夹,重新解压编译
  • 移除-j 8并行编译参数后重试

可行解决方法

该错误源于高版本gcc(12.x)启用了-Warray-parameter严格警告,而glibc-2.28代码中__sigsetjmp的两处声明不一致(一处为指针、一处为数组),警告被当作错误导致编译中断,可通过以下方式解决:

方法1:临时禁用该警告

在configure阶段添加CFLAGS参数关闭对应错误:

../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin CFLAGS="-Wno-error=array-parameter"

执行完后重新运行make -j8即可。

方法2:使用兼容版本的gcc

glibc-2.28官方推荐适配gcc 8.x及以下版本,降级gcc到8.3.0这类兼容版本后再编译,可避免新编译器的严格检查问题。

方法3:手动修正代码声明

统一两处__sigsetjmp的参数声明:

  • 打开../sysdeps/nptl/pthread.h第744行,将参数改为数组形式:struct __jmp_buf_tag __env[1]
  • 或者修改../setjmp/setjmp.h第54行为指针形式:struct __jmp_buf_tag *__env
    修改完成后重新执行编译流程。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.23 20:47:42