nginx/njs

nginx filter unable to link to zlib / libxml2

Closed this issue · 2 comments

Hi,

https://tracker.debian.org/pkg/libnginx-mod-js
is available in debian now, however we had to disable linking to zlib and libxml2+libxslt because helloworld wouldn't start:

[emerg] 351957#351957: failed to create js VM

Using nginx 1.24.0 and njs 0.8.0 + zlib OR libxml2 fails too.
On the other hand, njs shell works.

Any ideas why it might fail ?
I find it difficult to get more info on that failure - is there a way to get more verbose message from njs ?

xeioex commented

Hi @kapouer,

Can you please, share the build log nginx binary and njs modules? And the result of /path/to/nginx/objs/ngx_http_js_module.so. I am trying to reproduce the issue, unsuccessful so far.

When an nginx module need some library dependency it states it in a ngx_module_libs variable. The following macros can be used to link against the same libraries as nginx: LIBXSLT, LIBGD, GEOIP, PCRE, OPENSSL, MD5, SHA1, ZLIB, and PERL.

NJS module uses this mechanism to require to be built with LIBXSLT and ZLIB for "xml" and "zlib" njs modules. This is done in order to use the same libraries as nginx binary (for example, when nginx is built with OPENSSL built from sources). To disable them provide the following shell variables while building: NJS_LIBXSLT=NO, NJS_ZLIB=NO.

Firstly we need to ensure that the NJS so files are linked against the libraries:

ldd ldd /path/nginx/objs/ngx_http_js_module.so 
        linux-vdso.so.1 (0x00007ffd619da000)
        libxml2.so.2 => /lib/x86_64-linux-gnu/libxml2.so.2 (0x00007fb31ee8d000)
        libxslt.so.1 => /lib/x86_64-linux-gnu/libxslt.so.1 (0x00007fb31ee4b000)
        libexslt.so.0 => /lib/x86_64-linux-gnu/libexslt.so.0 (0x00007fb31ee32000)
        ...

On the other hand, njs shell works.

When njs CLI is built standalone, it discovers the necessary libraries by itself.

Indeed, for now I have

ldd /usr/lib/nginx/modules/ngx_http_js_module.so
	linux-vdso.so.1 (0x00007ffe6d9b7000)
	libxml2.so.2 => /lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f0ac5f9b000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0ac5ebc000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0ac5cda000)
	libicuuc.so.72 => /lib/x86_64-linux-gnu/libicuuc.so.72 (0x00007f0ac5adc000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f0ac5abd000)
	liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f0ac5a8e000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f0ac626f000)
	libicudata.so.72 => /lib/x86_64-linux-gnu/libicudata.so.72 (0x00007f0ac3c00000)
	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f0ac3800000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f0ac5a68000)

however in debian we're building njs out of tree using an external tool, and maybe some flag isn't correctly passed.