[GH-ISSUE #9] Failure to compile with mainline NGINX #141

Closed
opened 2026-03-13 16:30:53 +03:00 by kerem · 3 comments
Owner

Originally created by @dvershinin on GitHub (Dec 8, 2020).
Original GitHub issue: https://github.com/ADD-SP/ngx_waf/issues/9

Latest release 2.0.2 does not compile with NGINX 1.19.5. Errors:

In file included from ngx_waf-2.0.2/src/ngx_http_waf_module_core.c:13:
ngx_waf-2.0.2/src/../inc/ngx_http_waf_module_config.h: In function 'ngx_http_waf_create_srv_conf':
ngx_waf-2.0.2/src/../inc/ngx_http_waf_module_config.h:184:25: error: too few arguments to function 'ngx_log_init'
     srv_conf->ngx_log = ngx_log_init(NULL);
                         ^~~~~~~~~~~~
In file included from src/core/ngx_core.h:60,
                 from ngx_waf-2.0.2/src/../inc/ngx_http_waf_module_core.h:2,
                 from ngx_waf-2.0.2/src/ngx_http_waf_module_core.c:2:
src/core/ngx_log.h:231:12: note: declared here
 ngx_log_t *ngx_log_init(u_char *prefix, u_char *error_log);
            ^~~~~~~~~~~~

Looks like the function ngx_log_init has changed its signature at some point and requires a second argument on the mainline branch only (stable is fine).

Originally created by @dvershinin on GitHub (Dec 8, 2020). Original GitHub issue: https://github.com/ADD-SP/ngx_waf/issues/9 Latest release 2.0.2 does not compile with NGINX 1.19.5. Errors: ``` In file included from ngx_waf-2.0.2/src/ngx_http_waf_module_core.c:13: ngx_waf-2.0.2/src/../inc/ngx_http_waf_module_config.h: In function 'ngx_http_waf_create_srv_conf': ngx_waf-2.0.2/src/../inc/ngx_http_waf_module_config.h:184:25: error: too few arguments to function 'ngx_log_init' srv_conf->ngx_log = ngx_log_init(NULL); ^~~~~~~~~~~~ In file included from src/core/ngx_core.h:60, from ngx_waf-2.0.2/src/../inc/ngx_http_waf_module_core.h:2, from ngx_waf-2.0.2/src/ngx_http_waf_module_core.c:2: src/core/ngx_log.h:231:12: note: declared here ngx_log_t *ngx_log_init(u_char *prefix, u_char *error_log); ^~~~~~~~~~~~ ``` Looks like the function `ngx_log_init` has changed its signature at some point and requires a second argument on the mainline branch only (stable is fine).
kerem 2026-03-13 16:30:53 +03:00
Author
Owner

@dvershinin commented on GitHub (Dec 9, 2020):

Shouldn't you be using something along the lines of "#ifdef nginx_version" ? That constant is bumped between stable and mainline and can be used to detect backward-incompatible changes...

#define nginx_version 1019005

In src/core/nginx.h. For mainline it's 1019005 and for stable it is 1018000

The breaking change of ngx_log_t *ngx_log_init(u_char *prefix, u_char *error_log); was introduced only at 1.19.5 which is 1019005, so I think it's easiest to do conditional code based on nginx_version >= 1019005 (instead of introducing another define/compilation option, just use what's there).

<!-- gh-comment-id:741592848 --> @dvershinin commented on GitHub (Dec 9, 2020): Shouldn't you be using something along the lines of `"#ifdef nginx_version"` ? That constant is bumped between stable and mainline and can be used to detect backward-incompatible changes... > #define nginx_version 1019005 In `src/core/nginx.h`. For mainline it's `1019005` and for stable it is `1018000` The breaking change of `ngx_log_t *ngx_log_init(u_char *prefix, u_char *error_log);` was introduced only at 1.19.5 which is `1019005`, so I think it's easiest to do conditional code based on nginx_version >= 1019005 (instead of introducing another define/compilation option, just use what's there).
Author
Owner

@ADD-SP commented on GitHub (Dec 9, 2020):

Shouldn't you be using something along the lines of "#ifdef nginx_version" ? That constant is bumped between stable and mainline and can be used to detect backward-incompatible changes...

#define nginx_version 1019005

In src/core/nginx.h. For mainline it's 1019005 and for stable it is 1018000

The breaking change of ngx_log_t *ngx_log_init(u_char *prefix, u_char *error_log); was introduced only at 1.19.5 which is 1019005, so I think it's easiest to do conditional code based on nginx_version >= 1019005 (instead of introducing another define/compilation option, just use what's there).

Good idea, I didn't know about the nginx_version before.

<!-- gh-comment-id:741624795 --> @ADD-SP commented on GitHub (Dec 9, 2020): > Shouldn't you be using something along the lines of `"#ifdef nginx_version"` ? That constant is bumped between stable and mainline and can be used to detect backward-incompatible changes... > > > #define nginx_version 1019005 > > In `src/core/nginx.h`. For mainline it's `1019005` and for stable it is `1018000` > > The breaking change of `ngx_log_t *ngx_log_init(u_char *prefix, u_char *error_log);` was introduced only at 1.19.5 which is `1019005`, so I think it's easiest to do conditional code based on nginx_version >= 1019005 (instead of introducing another define/compilation option, just use what's there). Good idea, I didn't know about the `nginx_version` before.
Author
Owner

@ADD-SP commented on GitHub (Dec 9, 2020):

Thanks for your suggestion. This module is already compatible with the current Mainline NGINX, but considering that Mainline is still under development, there may be other compatibility issues in the future. So if in the future you encounter a compile error due to incompatibility with Mainline, it is recommended to reopen this issue unless necessary.

<!-- gh-comment-id:741688029 --> @ADD-SP commented on GitHub (Dec 9, 2020): Thanks for your suggestion. This module is already compatible with the current Mainline NGINX, but considering that Mainline is still under development, there may be other compatibility issues in the future. So if in the future you encounter a compile error due to incompatibility with Mainline, it is recommended to reopen this issue unless necessary.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ngx_waf#141
No description provided.