首页 > 解决方案 > 自动配置忽略 CFLAGS?

问题描述

我正在构建一个使用 GNU autoconf的包(副 3.4 )。运行./configure失败并显示以下消息:

checking size of time_t... 0
configure: error: can not figure type of time_t
error: Bad exit status from /var/tmp/rpm-tmp.wIgnPw (%build)

检查config.log,由于以下错误,这似乎失败了:

/usr/bin/ld: /tmp/ccMTSdtB.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status

我尝试通过添加-fPICCFLAGS环境变量来解决这个问题:

CFLAGS=-fPIC ./configure

但是,虽然这显然是在./configure...的其他阶段使用的

configure:3657: checking whether the C compiler works
configure:3679: gcc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE=1 -fPIC  -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld conftest.c  >&5

它似乎没有用于与以下相关的功能测试time_t

configure:9684: checking for time_t in time.h
configure:9700: gcc -c -g -O3 -Wall -Wformat -Wformat-signedness -Wshadow -Wpointer-arith -Wstrict-prototypes -Wuninitialized -Wunreachable-code -Wno-unused-parameter -Werror=implicit-function-declaration -Wfatal-errors  conftest.c >&5
[...]
configure:9753: checking size of time_t
configure:9758: gcc -o conftest -g -O3 -Wall -Wformat -Wformat-signedness -Wshadow -Wpointer-arith -Wstrict-prototypes -Wuninitialized -Wunreachable-code -Wno-unused-parameter -Werror=implicit-function-declaration -Wfatal-errors  -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld conftest.c  >&5

configure.ac,上面的代码是从以下位置生成的:

if test $bu_cv_decl_time_t_time_h = yes; then
  AC_CHECK_SIZEOF([time_t],[],[#include <time.h>])
else
  AC_CHECK_SIZEOF([time_t],[],[#include <sys/types.h>])
fi

我已经能够通过重新定义来解决这个问题CC

CC="gcc -fPIC" ./configure

这行得通,但很丑陋(如果有东西想在gcc 没有 -fPIC的情况下调用怎么办?)。有没有理由AC_CHECK_SIZEOF忽略CFLAGS

标签: cgccautotoolsautoconf

解决方案


看来我在评论中表达的怀疑得到了证实。VICE 配置程序执行CFLAGS某些检查(包括与time_t. 因此,这不是Autoconf忽略您的标志的问题,而是VICE这样做的问题。

我重申,我认为更重要的问题是配置首先不能为您开箱即用。我建议将其作为反对该项目的问题提出。尽管我不喜欢 VICE 如此漫不经心地忽略用户的CFLAGS.


推荐阅读