mailru / graphite-nginx-module

An nginx module for collecting stats into Graphite
135 stars 34 forks source link

Build failure with version >= 1.21.5 #47

Closed MindHunter86 closed 2 years ago

MindHunter86 commented 2 years ago

Привет. Пытаюсь собрать модуль со свежим nginx и напоролся на то, что не собираемся с версии 1.21.5 и больше. Я сделал мальенький воркфлоу в гитхаб экшнс и проверил, что версии 1.21.1 - 1.21.4 собираются нормально.

Мои опции сборки (вырезано из моего большого докерфайла):

RUN ./configure \
        --user=nginx \
        --group=nginx \
        --prefix=/etc/nginx \
        --pid-path=/var/run/nginx.pid \
        --lock-path=/var/run/nginx.lock \
        --sbin-path=/usr/sbin/nginx \
        --modules-path=/usr/lib/nginx/modules \
        --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/cache/nginx/client_temp \
        --http-proxy-temp-path=/var/cache/nginx/proxy_temp \
        --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
        --with-pcre \
        --with-pcre-jit \
        --without-select_module \
        --without-poll_module \
        --without-http_ssi_module \
        --without-http_split_clients_module \
        --without-http_uwsgi_module \
        --without-http_scgi_module \
        --without-http_memcached_module \
        --without-http_empty_gif_module \
        --without-http_browser_module \
        --without-http_userid_module \
        --with-threads \
        --with-file-aio \
        --with-http_ssl_module \
        --with-http_v2_module \
        --with-http_realip_module \
        --with-http_auth_request_module \
        --with-http_sub_module \
        --with-http_secure_link_module\
        --with-http_stub_status_module \
        --with-http_dav_module \
        --with-http_realip_module \
        --with-http_addition_module \
        --with-stream=dynamic \
        --with-stream_ssl_preread_module \
        --with-stream_realip_module \
        --with-http_xslt_module=dynamic \
        --with-http_image_filter_module=dynamic \
        --with-http_geoip_module=dynamic \
        --with-compat \
        --add-dynamic-module=../ngx_http_auth_pam_module-${NGXMOD_PAM_VERSION} \
        --add-dynamic-module=../ngx_brotli-${NGXMOD_BROTLI_VERSION} \
        --add-module=../graphite-nginx-module-${NGXMOD_GRAPHITE_VERSION} \
        --add-module=../testcookie-nginx-module-${NGXMOD_TSTCK_VERSION} \
        --add-module=../nginx-http-rdns-${NGXMOD_RDNS_VERSION} \
        --add-module=../headers-more-nginx-module-${NGXMOD_HEADMR_VERSION} \
        --with-cc-opt='-O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic'

Не могу точно сказать это конфликт модулей или все же апдейт самого nginx. Исходя из чейндж лога там прикрутили PCRE по дефолту, может быть с этим связано.

Изменения в nginx 1.21.5                                          28.12.2021

    *) Изменение: теперь nginx по умолчанию собирается с библиотекой PCRE2.

    *) Изменение: теперь nginx всегда использует sendfile(SF_NODISKIO) на
       FreeBSD.

    *) Добавление: поддержка sendfile(SF_NOCACHE) на FreeBSD.

    *) Добавление: переменная $ssl_curve.

    *) Исправление: при использовании HTTP/2 без SSL вместе с директивами
       sendfile и aio соединения могли зависать.

Вот сам лог с ошибкой:

2022-03-13T20:15:17.5216749Z #22 35.11  -o objs/addon/src/ngx_http_graphite_module.o \
2022-03-13T20:15:17.5217196Z #22 35.11  ../graphite-nginx-module-3.1/src/ngx_http_graphite_module.c
2022-03-13T20:15:17.8217463Z #22 35.43 cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wno-deprecated-declarations  -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/include -I /usr/include/libxml2 -I objs -I src/http -I src/http/modules -I src/http/v2 -I ../graphite-nginx-module-3.1/src -I src/stream \
2022-03-13T20:15:17.8218534Z #22 35.43  -o objs/addon/src/ngx_http_graphite_net.o \
2022-03-13T20:15:17.8218986Z #22 35.43  ../graphite-nginx-module-3.1/src/ngx_http_graphite_net.c
2022-03-13T20:15:17.9284531Z #22 35.59 cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wno-deprecated-declarations  -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/include -I /usr/include/libxml2 -I objs -I src/http -I src/http/modules -I src/http/v2 -I ../graphite-nginx-module-3.1/src -I src/stream \
2022-03-13T20:15:17.9285638Z #22 35.59  -o objs/addon/src/ngx_http_testcookie_access_module.o \
2022-03-13T20:15:17.9286145Z #22 35.59  ../testcookie-nginx-module-master/src/ngx_http_testcookie_access_module.c
2022-03-13T20:15:18.0788225Z #22 35.60 ../graphite-nginx-module-3.1/src/ngx_http_graphite_module.c: In function 'ngx_http_graphite_get_source':
2022-03-13T20:15:18.0789135Z #22 35.60 ../graphite-nginx-module-3.1/src/ngx_http_graphite_module.c:1963:42: error: passing argument 2 of 'ngx_regex_exec' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
2022-03-13T20:15:18.0789702Z #22 35.60  1963 |             if (ngx_regex_exec(rc.regex, name, NULL, 0) >= 0)
2022-03-13T20:15:18.0790010Z #22 35.60       |                                          ^~~~
2022-03-13T20:15:18.0790290Z #22 35.60 In file included from src/core/ngx_core.h:73,
2022-03-13T20:15:18.0791112Z #22 35.60                  from ../graphite-nginx-module-3.1/src/ngx_http_graphite_module.c:3:
2022-03-13T20:15:18.0791673Z #22 35.60 src/core/ngx_regex.h:66:54: note: expected 'ngx_str_t *' but argument is of type 'const ngx_str_t *'
2022-03-13T20:15:18.0792088Z #22 35.60    66 | ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s, int *captures,
2022-03-13T20:15:18.0792412Z #22 35.60       |                                           ~~~~~~~~~~~^
2022-03-13T20:15:18.3800666Z #22 35.93 cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wno-deprecated-declarations  -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/include -I /usr/include/libxml2 -I objs -I src/http -I src/http/modules -I src/http/v2 -I ../graphite-nginx-module-3.1/src -I src/stream \
2022-03-13T20:15:18.3801786Z #22 35.93  -o objs/addon/nginx-http-rdns-master/ngx_http_rdns_module.o \
2022-03-13T20:15:18.3802265Z #22 35.93  ../nginx-http-rdns-master/ngx_http_rdns_module.c
2022-03-13T20:15:19.1319527Z #22 36.69 cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wno-deprecated-declarations  -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/include -I /usr/include/libxml2 -I objs -I src/http -I src/http/modules -I src/http/v2 -I ../graphite-nginx-module-3.1/src -I src/stream \
2022-03-13T20:15:19.1320622Z #22 36.69  -o objs/addon/src/ngx_http_headers_more_filter_module.o \
2022-03-13T20:15:19.1321165Z #22 36.69  ../headers-more-nginx-module-master/src/ngx_http_headers_more_filter_module.c
2022-03-13T20:15:19.5836912Z #22 37.17 cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wno-deprecated-declarations  -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/include -I /usr/include/libxml2 -I objs -I src/http -I src/http/modules -I src/http/v2 -I ../graphite-nginx-module-3.1/src -I src/stream \
2022-03-13T20:15:19.5838004Z #22 37.17  -o objs/addon/src/ngx_http_headers_more_headers_out.o \
2022-03-13T20:15:19.5838519Z #22 37.17  ../headers-more-nginx-module-master/src/ngx_http_headers_more_headers_out.c
2022-03-13T20:15:19.7344392Z #22 37.26 cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wno-deprecated-declarations  -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/include -I /usr/include/libxml2 -I objs -I src/http -I src/http/modules -I src/http/v2 -I ../graphite-nginx-module-3.1/src -I src/stream \
2022-03-13T20:15:19.7345514Z #22 37.26  -o objs/addon/src/ngx_http_headers_more_headers_in.o \
2022-03-13T20:15:19.7346028Z #22 37.26  ../headers-more-nginx-module-master/src/ngx_http_headers_more_headers_in.c
2022-03-13T20:15:20.0115784Z #22 37.68 cc1: all warnings being treated as errors
2022-03-13T20:15:20.1621302Z #22 37.74 make[1]: *** [objs/Makefile:1393: objs/addon/src/ngx_http_graphite_module.o] Error 1
2022-03-13T20:15:20.1621695Z #22 37.74 make[1]: *** Waiting for unfinished jobs....
2022-03-13T20:15:20.2638328Z #22 37.90 make[1]: Leaving directory '/usr/src/nginx/nginx-1.21.5'
2022-03-13T20:15:20.2638744Z #22 37.90 make: *** [Makefile:10: build] Error 2
2022-03-13T20:15:20.2639409Z #22 ERROR: process "/bin/sh -c make -j$(( `nproc` + 1 )) \t&& make DESTDIR=/usr/local/nginx install" did not complete successfully: exit code: 2
2022-03-13T20:15:20.2639810Z ------
2022-03-13T20:15:20.2640223Z  > [builder 15/18] RUN make -j$(( `nproc` + 1 ))   && make DESTDIR=/usr/local/nginx install:
2022-03-13T20:15:20.2640917Z #22 37.17  -o objs/addon/src/ngx_http_headers_more_headers_out.o \
2022-03-13T20:15:20.2641424Z #22 37.17  ../headers-more-nginx-module-master/src/ngx_http_headers_more_headers_out.c
2022-03-13T20:15:20.2642854Z #22 37.26 cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wno-deprecated-declarations  -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/include -I /usr/include/libxml2 -I objs -I src/http -I src/http/modules -I src/http/v2 -I ../graphite-nginx-module-3.1/src -I src/stream \
2022-03-13T20:15:20.2643891Z #22 37.26  -o objs/addon/src/ngx_http_headers_more_headers_in.o \
2022-03-13T20:15:20.2644397Z #22 37.26  ../headers-more-nginx-module-master/src/ngx_http_headers_more_headers_in.c
2022-03-13T20:15:20.2644785Z #22 37.68 cc1: all warnings being treated as errors
2022-03-13T20:15:20.2645156Z #22 37.74 make[1]: *** [objs/Makefile:1393: objs/addon/src/ngx_http_graphite_module.o] Error 1
2022-03-13T20:15:20.2645514Z #22 37.74 make[1]: *** Waiting for unfinished jobs....
2022-03-13T20:15:20.2645934Z #22 37.90 make[1]: Leaving directory '/usr/src/nginx/nginx-1.21.5'
2022-03-13T20:15:20.2646259Z #22 37.90 make: *** [Makefile:10: build] Error 2
2022-03-13T20:15:20.2646530Z ------
2022-03-13T20:15:20.2708031Z Dockerfile:97
2022-03-13T20:15:20.2708474Z --------------------
2022-03-13T20:15:20.2708726Z   96 |     # make && make install
2022-03-13T20:15:20.2709075Z   97 | >>> RUN make -j$(( `nproc` + 1 )) \
2022-03-13T20:15:20.2777121Z   98 | >>>     && make DESTDIR=/usr/local/nginx install
2022-03-13T20:15:20.2778616Z   99 |     
2022-03-13T20:15:20.2782298Z --------------------
2022-03-13T20:15:20.2783184Z error: failed to solve: process "/bin/sh -c make -j$(( `nproc` + 1 )) \t&& make DESTDIR=/usr/local/nginx install" did not complete successfully: exit code: 2

При необходимости полный докерфайл и полные логи сборки можно найти тут https://github.com/MindHunter86/docker-nginx и тут https://github.com/MindHunter86/docker-nginx/actions

Заранее благодарю за фикс)

dvershinin commented 2 years ago

@MindHunter86

2022-03-13T20:15:18.0789135Z #22 35.60 ../graphite-nginx-module-3.1/src/ngx_http_graphite_module.c:1963:42: error: passing argument 2 of 'ngx_regex_exec' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]

Соответственно можете собрать с -Wno-error=discarded-qualifiers добавленным в --with-cc-opt=" .... ".

А вообще собирать желательно с PCRE2.

MindHunter86 commented 2 years ago

Спасибо! Сделал сборку с pcre2 и добавил опции по вашей рекомендации. Но как я понимаю, опцию можно будет убирать после вышеуказанного коммита?)

sorc1 commented 2 years ago

Да, опцию лучше будет убрать, иначе что-то более серьезное можно пропустить в будущем.

MindHunter86 commented 2 years ago

Да, опцию лучше будет убрать, иначе что-то более серьезное можно пропустить в будущем.

Хорошо, понял) Тогда жду мерж. Спасибо большое за помощь)