Compiling Nginx with `libdeflate` - possible?
mdounin at mdounin.ru
Mon Oct 25 16:50:52 UTC 2021
On Mon, Oct 25, 2021 at 07:50:42AM -0400, petecooper wrote:
> I am attempting to compile Nginx 1.21.3 with libdeflate with a view to
> comparing performance against classic Zlib and the Cloudflare fork of
> I can successfully compile Nginx with classic Zlib. I can also successfully
> compile Nginx with Cloudflare Zlib. I cannot yet compile Nginx with
> I am falling down during Nginx `make` with this error:
> cd ../../libdeflate-source/libdeflate-1.8 \
> && make distclean \
> && CFLAGS="-O2 -fomit-frame-pointer -pipe " CC="cc" \
> ./configure \
> && make libz.a
> make: Entering directory '/home/pete/libdeflate-source/libdeflate-1.8'
> make: *** No rule to make target 'distclean'. Stop.
> make: Leaving directory '/home/pete/libdeflate-source/libdeflate-1.8'
> make: *** [objs/Makefile:3107:
> ../../libdeflate-source/libdeflate-1.8/libz.a] Error 2
> make: Leaving directory '/home/pete/nginx-source/nginx-1.21.3'
> make: *** [Makefile:10: build] Error 2
> I confirm the directory `/home/pete/libdeflate-source/libdeflate-1.8` has
> the Makefile and is readable by Nginx make.
> Compiling libdeflate in isolation outside of Nginx with `make distclean`
> throws the same error:
> Question #0: Am I attempting the impossible here?
> Question #1: Is there a way to persuade libdeflate in its current state to
> compile with Nginx?
> Question #2: Is there something I should be raising on the libdeflate
> project side to achieve a compilation with Nginx?
> Thank you for reading, I am grateful for any advice and feedback.
It looks like you are trying to use "--with-zlib=..." configure
option to compile nginx with libdeflate. It is, however, designed
to compile zlib, and relies on zlib compilation procedure. It
might not work (and, actually, not expected to work) with other
libraries even if these libraries provide a zlib-compatible
Similarly, you cannot compile nginx with BoringSSL with
"--with-openssl=...", because BoringSSL use build system quite
different from OpenSSL's one.
Consider instead compiling libdeflate yourself, and building nginx
with appropriate --with-cc-opt="-I/path/to/include" and
--with-ld-opt="-I/path/to/lib" to provide paths to the libdeflate
includes and library files. This might work as long as libdeflate
provides zlib-compatible interfaces.
Note though that libdeflate does not seem to provide a
zlib-compatible interface, its README.md says "libdeflate has a
simple API that is not zlib-compatible". That is, using
libdeflate instead of zlib is not going to work without rewriting
the code to use libdeflate API.
Further, README.md says that "There is currently no support for
streaming". This means it is not usable in nginx (well, certainly
one can write a module which uses it, but this will be something
very different from the nginx gzip filter module).
More information about the nginx