c - 自动配置忽略 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
我尝试通过添加-fPIC
到CFLAGS
环境变量来解决这个问题:
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
?
解决方案
推荐阅读
- multidimensional-array - Scilab - 多维整合
- mysql - 将查询值检索到触发器正文中
- mongodb - 使用 $facet 和 mongoDB $search 进行过滤器导航
- c++ - 在两个线程中打印数字
- html - 有没有办法制作可点击的图像并选择一个特定的图像?
- c - ffmpeg lib报错指定样本格式-1无效或不支持
- php - 在php中定义未定义的数组键
- python - 有没有办法水平翻转kivy中的标签?
- php - Codeigniter 4 - 如何使用 form_checkbox?
- javascript - 访问者进入我的网站时如何通知手机/电脑桌面?