为什么-Werror会导致configure错误

4

我想从源代码构建nginx。因此,我编写了一个bash脚本来完成这个任务:

#!/bin/bash
export LD_LIBRARY_PATH="/usr/lib64:$LD_LIBRARY_PATH"
dir=$(realpath `dirname $BASH_SOURCE`)

cd $dir/modules
for folder in *
do
    ADD_MODULES="$ADD_MODULES \
    --add-module=$dir/modules/$folder"
done

cd $dir/nginx
./auto/configure \
--prefix=/usr/share/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/lib/nginx/tmp/client_body \
--http-proxy-temp-path=/var/lib/nginx/tmp/proxy \
--http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi \
--http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi \
--http-scgi-temp-path=/var/lib/nginx/tmp/scgi \
--pid-path=/run/nginx.pid \
--lock-path=/run/lock/subsys/nginx \
--user=nginx \
--group=nginx \
--with-file-aio \
--with-ipv6 \
--with-http_ssl_module \
--with-http_spdy_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module \
--with-http_image_filter_module \
--with-http_geoip_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_stub_status_module \
--with-http_perl_module \
--with-mail \
--with-mail_ssl_module \
--with-pcre \
--with-debug \
$ADD_MODULES \
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' \
--with-ld-opt='-Wl,-z,relro -Wl,-E' 

if [ $? -ne 0 ]; then
    exit
fi

read -p 'Run make & make install? [Y/n]> ' RUN

if [ "x$RUN" = "x" -o "x$RUN" = "xY" -o "x$RUN" = "xy" ]; then
    make -j8
    make install
fi

当我运行这个脚本时,configure 成功了,但编译期间出现一个警告(未使用但已设置的变量),被视为错误导致 make 失败。
因此,我编辑了 "--with-cc-opt" 选项,将 "-Wall" 改成了 "-Werror",这一次configure失败了。
./auto/configure: error: the HTTP XSLT module requires the libxml2/libxslt
libraries. You can either do not enable the module or install the libraries.

然后我将“-Werror”更改为“-Werror=unused-but-set-variable”,但配置失败并出现错误。
./auto/configure: no supported file AIO was found
Currently file AIO is supported on FreeBSD 4.3+ and Linux 2.6.22+ only

(我试图删除-W选项,但与-Wall相同)

谁知道为什么?!

编辑:

我通过编辑nginx的configure选项文件来解决...

我注意到make日志的末尾

cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -O2 -g -pipe -Werror=unused-but-set-variable -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -I src/core -I (.... etc

我认为这些问题是nginx的configure自动添加一些CC-opt在我的之前

因此我使用grep '\-Wall' ./auto -Rgrep '\-Werror' ./auto -R找到并删除它们。

现在我完全控制CC标志了。

感谢R的回答:D

2个回答

3

删除--with-file-aio选项,它没有用处。

要么删除--with-http_xslt_module选项,要么安装libxml2和libxslt。

通常情况下,不要使用你不理解的 --with--enable 选项。


我正在使用来自yum包的nginx -V配置选项,但添加了一些第三方模块($ADD_MODULES)。我想知道-Wall-Werror之间的区别以及它们在配置期间为什么会产生影响。 - GongT
这是至理名言。除非你或其他人使用它们,否则不要启用所有你不了解的功能(除非在配置bash时)。 - S.S. Anne

3

第一个问题(错误:HTTP XSLT模块需要libxml2/libxslt)可以通过安装libxslt-devel包来解决。


3
对于我(在Ubuntu上),我需要安装“libxslt1-dev”。 - Steel Brain

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接