我想從源代碼構建nginx。所以我寫了一個bash腳本來做到這一點:why -Werror cause配置錯誤
#!/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 =未用,但是設定變量」,並且configure
失敗,錯誤
./auto/configure: no supported file AIO was found
Currently file AIO is supported on FreeBSD 4.3+ and Linux 2.6.22+ only
(I試圖刪除-W選項,但是是相同的與-Wall)
誰知道爲什麼?
編輯:
我通過編輯nginx的configure
選項文件解決...
我注意到make
日誌尾部
CC -c -pipe -O -W -Wall -Wpointer-arith
-Wno-unused-參數-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 /核心-I(....等
我覺得這些問題是nginx的configure
汽車prepend一些CC-opt臥鋪礦
所以我用grep '\-Wall' ./auto -R
和grep '\-Werror' ./auto -R
找到並刪除它。
現在我有CC標誌的「完整」控制。
感謝對R的答案:d
我正在使用yum軟件包中'nginx -V'的配置選項,但添加了一些第三方模塊($ ADD_MODULES)。我想知道'-Wall'和'-Werror'的不同之處,以及爲什麼它們在配置期間有效。 – GongT