matsumotory / ngx_mruby

ngx_mruby - A Fast and Memory-Efficient Web Server Extension Mechanism Using Scripting Language mruby for nginx
https://ngx.mruby.org/
988 stars 112 forks source link

Failed to build using Nginx 1.25.5 or later #524

Closed matsudai closed 3 weeks ago

matsudai commented 1 month ago

*This is a machine translation.

The build failed when using Nginx 1.25.5 or later.

An error occurs during the build with build.sh :

/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c: In function 'ngx_stream_mrb_add_listener':
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:56:3: error: unknown type name 'ngx_stream_listen_t'; did you mean 'ngx_stream_filter_pt'?
   56 |   ngx_stream_listen_t *ls, *als;
      |   ^~~~~~~~~~~~~~~~~~~
      |   ngx_stream_filter_pt
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:79:28: error: 'ngx_stream_core_main_conf_t' has no member named 'listen'
   79 |   ls = ngx_array_push(&cmcf->listen);
      |                            ^~
In file included from src/core/ngx_core.h:53,
                 from /path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.h:11,
                 from /path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:7:
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:84:26: error: 'ngx_stream_listen_t' undeclared (first use in this function); did you mean 'ngx_stream_filter_pt'?
   84 |   ngx_memzero(ls, sizeof(ngx_stream_listen_t));
      |                          ^~~~~~~~~~~~~~~~~~~
src/core/ngx_string.h:88:57: note: in definition of macro 'ngx_memzero'
   88 | #define ngx_memzero(buf, n)       (void) memset(buf, 0, n)
      |                                                         ^
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:84:26: note: each undeclared identifier is reported only once for each function it appears in
   84 |   ngx_memzero(ls, sizeof(ngx_stream_listen_t));
      |                          ^~~~~~~~~~~~~~~~~~~
src/core/ngx_string.h:88:57: note: in definition of macro 'ngx_memzero'
   88 | #define ngx_memzero(buf, n)       (void) memset(buf, 0, n)
      |                                                         ^
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:91:5: error: request for member 'backlog' in something not a structure or union
   91 |   ls->backlog = NGX_LISTEN_BACKLOG;
      |     ^~
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:94:5: error: request for member 'rcvbuf' in something not a structure or union
   94 |   ls->rcvbuf = -1;
      |     ^~
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:95:5: error: request for member 'sndbuf' in something not a structure or union
   95 |   ls->sndbuf = -1;
      |     ^~
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:97:5: error: request for member 'type' in something not a structure or union
   97 |   ls->type = SOCK_STREAM;
      |     ^~
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:98:5: error: request for member 'wildcard' in something not a structure or union
   98 |   ls->wildcard = u.wildcard;
      |     ^~
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:99:5: error: request for member 'ctx' in something not a structure or union
   99 |   ls->ctx = cf->ctx;
      |     ^~
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:102:5: error: request for member 'ipv6only' in something not a structure or union
  102 |   ls->ipv6only = 1;
      |     ^~
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:107:7: error: request for member 'type' in something not a structure or union
  107 |     ls->type = SOCK_DGRAM;
      |       ^~
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:111:9: error: request for member 'type' in something not a structure or union
  111 |   if (ls->type == SOCK_DGRAM) {
      |         ^~
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:118:11: error: request for member 'so_keepalive' in something not a structure or union
  118 |     if (ls->so_keepalive) {
      |           ^~
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:122:11: error: request for member 'proxy_protocol' in something not a structure or union
  122 |     if (ls->proxy_protocol) {
      |           ^~
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:127:13: error: 'ngx_stream_core_main_conf_t' has no member named 'listen'
  127 |   als = cmcf->listen.elts;
      |             ^~
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:132:9: error: request for member 'sockaddr' in something not a structure or union
  132 |    ls[n].sockaddr = u.addrs[n].sockaddr;
      |         ^
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:133:9: error: request for member 'socklen' in something not a structure or union
  133 |    ls[n].socklen = u.addrs[n].socklen;
      |         ^
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:134:9: error: request for member 'addr_text' in something not a structure or union
  134 |    ls[n].addr_text = u.addrs[n].name;
      |         ^
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:135:9: error: request for member 'wildcard' in something not a structure or union
  135 |    ls[n].wildcard = ngx_inet_wildcard(ls[n].sockaddr);
      |         ^
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:135:44: error: request for member 'sockaddr' in something not a structure or union
  135 |    ls[n].wildcard = ngx_inet_wildcard(ls[n].sockaddr);
      |                                            ^
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:137:24: error: 'ngx_stream_core_main_conf_t' has no member named 'listen'
  137 |    for (i = 0; i < cmcf->listen.nelts - u.naddrs + n; i++) {
      |                        ^~
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:138:15: error: request for member 'type' in something not a structure or union
  138 |      if (ls[n].type != als[i].type) {
      |               ^
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:138:30: error: request for member 'type' in something not a structure or union
  138 |      if (ls[n].type != als[i].type) {
      |                              ^
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:142:33: error: request for member 'sockaddr' in something not a structure or union
  142 |      if (ngx_cmp_sockaddr(als[i].sockaddr, als[i].socklen, ls[n].sockaddr, ls[n].socklen, 1) != NGX_OK) {
      |                                 ^
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:142:50: error: request for member 'socklen' in something not a structure or union
  142 |      if (ngx_cmp_sockaddr(als[i].sockaddr, als[i].socklen, ls[n].sockaddr, ls[n].socklen, 1) != NGX_OK) {
      |                                                  ^
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:142:65: error: request for member 'sockaddr' in something not a structure or union
  142 |      if (ngx_cmp_sockaddr(als[i].sockaddr, als[i].socklen, ls[n].sockaddr, ls[n].socklen, 1) != NGX_OK) {
      |                                                                 ^
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:142:81: error: request for member 'socklen' in something not a structure or union
  142 |      if (ngx_cmp_sockaddr(als[i].sockaddr, als[i].socklen, ls[n].sockaddr, ls[n].socklen, 1) != NGX_OK) {
      |                                                                                 ^
/path/to/ngx_mruby-2.6.0/src/stream/ngx_stream_mruby_core.c:146:96: error: request for member 'addr_text' in something not a structure or union
  146 |       ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "duplicate \"%V\" address and port pair", &ls[n].addr_text);
      |                                                                                                ^
make[2]: *** [objs/Makefile:1620: objs/addon/stream/ngx_stream_mruby_core.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/path/to/nginx-1.25.5'
make[1]: *** [Makefile:10: build] Error 2
make[1]: Leaving directory '/path/to/nginx-1.25.5'
make: *** [Makefile:99: build_ngx_mruby] Error 2

Full error log: https://gist.github.com/matsudai/a86659a73df0b4bec26002265aca506e

It seems that the error is caused because the ngx_stream_listen_t structure has been removed in the changes from Nginx 1.25.4 to 1.25.5. (It appears that ngx_stream_listen_opt_t was added as a replacement.)

This change is still being maintained, and the same issue occurs in versions 1.26 and 1.27 as well.

ngx_mruby ver. Nginx ver. Succeeded
2.6.0 1.23.4 (minor latest)
2.6.0 1.24.0 (minor latest)
2.6.0 1.25.4
2.6.0 1.25.5 (minor latest)
2.6.0 1.26.0
2.6.0 1.26.2 (minor latest)
2.6.0 1.27.2 (latest)

Nginx 1.25.5 以降を利用したビルドが失敗しました。

build.sh でのビルド時に次のエラーが発生します :
エラー全文 : https://gist.github.com/matsudai/a86659a73df0b4bec26002265aca506e

Nginx 1.25.4 から 1.25.5 の変更で ngx_stream_listen_t が削除されており、この構造体が参照できないエラーが発生したようです。
(おそらくその代わりとして ngx_stream_listen_opt_t が追加されています)

この変更は現在も維持されており、 1.26 や 1.27 でも同様の現象が発生いたします。

DimitriosLisenko commented 1 month ago

We are also experiencing this issue - tried to compile for NGINX 1.26.2.

matsumotory commented 3 weeks ago

最近別件が忙しくてなかなか対応できませんので、PR頂ければマージします。ご指摘のとおり構造体の変更によるもの思いますので、機械的に変更すればビルド通りそうです。

matsumotory commented 3 weeks ago

どなたか対応できますでしょうか? /cc @pyama86 @yyamano

matsudai commented 2 weeks ago

@matsumotory @pyama86 ご対応いただきありがとうございました! お手数おかけいたしました。

ngx_mruby ver. Nginx ver. Succeeded
v2.6.0 1.23.4 (minor latest)
v2.6.0 1.24.0 (minor latest)
v2.6.0 1.25.4
V2.7.0 1.25.5 (minor latest)
V2.7.0 1.26.0
V2.7.0 1.26.2 (minor latest)
V2.7.0 1.27.2 (latest)