Skip to content

ngx crate doesn't compile without manual fixes #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
annmuor opened this issue May 12, 2025 · 1 comment
Open

ngx crate doesn't compile without manual fixes #156

annmuor opened this issue May 12, 2025 · 1 comment

Comments

@annmuor
Copy link

annmuor commented May 12, 2025

Describe the bug
Default compile flags for nginx-sys doesn't allow to compile ngx crate without manual intervention on gcc 15.1 (Arch Linux rolling)

There's 2 erros to fix:

  1. Default ZLIB_VERSION (1.3.0) doesn't exist on the website anymore. I had to rewrite to 1.3.1
  2. nginx-sys crate compilation fails with the following error:
 src/http/v2/ngx_http_v2_filter_module.c:151:36: error: initializer-string for array of ‘unsigned char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (6 chars into 5 available) [-Werror=unterminated-string-initialization]
 src/http/v2/ngx_http_v2_filter_module.c:154:9: error: initializer-string for array of ‘unsigned char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (13 chars into 12 available) [-Werror=unterminated-string-initialization]

To fix it I had to manually add attribute ((nonstring)) to declaration into .cargo/registry/.../

To Reproduce

  1. cargo init --lib
  2. cargo add ngx
  3. cargo build

Expected behavior
Cargo builds simple library

Your environment

  • Version of ngx = 0.4.1
  • Version of Rust = 1.86.0
  • Version of NGINX = 1.22.0
  • Arch Linux rolling, gcc version 15.1.1 20250425 (GCC)

Additional context
I'm not sure if I need to send PR to nginx repo with attribute param or to you to change build flags, so feel free to close this issue if it's inappropriate repo.

@bavshin-f5
Copy link
Member

  • Default ZLIB_VERSION (1.3.0) doesn't exist on the website anymore. I had to rewrite to 1.3.1

This is fixed in the dev branch, but we haven't tagged a release for a while.

  • nginx-sys crate compilation fails with the following error:

Fixed in nginx/nginx#631 and released in nginx 1.28.0. Unfortunately, the current stable release of ngx does not offer any way to work around that other than setting NGX_VERSION=1.28.0.

For the next release, I'm planning to make nginx-sys use a preconfigured external nginx source tree specified with NGINX_SOURCE_DIR/NGINX_BUILD_DIR by default. This solves any non-standard configuration requirements and allows building against patched nginx sources with API changes (e.g. Linux distribution packages).
The change is already available in the master branch if you don't mind git dependencies, and will be released to crates.io in the next couple of months.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants