Welcome! Log In Create A New Profile

Advanced

Re: Nginx won't build with xslt into static linked binary

Maxim Dounin
February 12, 2023 05:44PM
Hello!

On Sun, Feb 12, 2023 at 05:31:30PM +0100, Kevin Weis via nginx wrote:

> Hi,
> I aim to build nginx from source, statically linked, and run into issues
> when `http_xslt_module` is enabled or I'm building with NJS 0.7.10
> (which also needs xslt).
>
> I've created a simplified docker build to debug this issue at
> https://git.compilenix.org/CompileNix/docker-nginx-static
>
> The error occures while running `./auto/configure` if
> `--with-ld-opt="-static"` is added. The build succeeds without it
> (remove line 176 from Dockerfile).
>
> The configure ends with:
> ```
> checking for libxslt ... not found
> checking for libxslt in /usr/local/ ... not found
> checking for libxslt in /usr/pkg/ ... not found
> checking for libxslt in /opt/local/ ... not found
>
> ./auto/configure: error: the HTTP XSLT module requires the libxml2/libxslt
> libraries. You can either do not enable the module or install the libraries.
> ```
>
> The issue is not that libxml2 and libxslt aren't installed, they are.
>
> I've looked into why libxslt is reported to be "not found" by inspecting
> the configure log file `objs/autoconf.err`, which shows the following error:
> ``
> checking for libxslt
>
> /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../lib/libxml2.a(libxml2_la-xmlIO.o):
> in function `xmlFreeZMemBuff':
> /home/buildozer/aports/main/libxml2/src/libxml2-2.10.3/xmlIO.c:1482:
> undefined reference to `deflateEnd'
> /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../lib/libxml2.a(libxml2_la-xmlIO.o):
> in function `xmlGzfileOpenW':
> /home/buildozer/aports/main/libxml2/src/libxml2-2.10.3/xmlIO.c:1172:
> undefined reference to `gzdopen'
>
> <for more see full build log linked below>
> ```
>
> Here is the full build log:
> https://compilenix.org/static/95Yeyaxv/build-static.log
>
> If you are wondering why I also build libxslt from source instead of
> using the alpine `libxslt-dev` package.. `libxslt-dev` does not contain
> "libxslt.a", which is required for static linking.
>
> Additionally: I've also looked into other distros like ubuntu, fedora or
> gentoo. None of them install "libxslt.a" and show the same configure
> error messages.
>
> Steps to reproduce:
> ```
> git clone https://git.compilenix.org/CompileNix/docker-nginx-static.git
> cd docker-nginx-static
> ./build.sh -t docker-nginx-static --no-cache | tee build.log
> ```
>
> Any help, suggestions or hints are very welcome :)

Static linking requires more than just "-static". In particular,
for all the libraries being used you'll have to manually provide
library dependencies.

The particular error suggests that libxml2 depends on zlib, so
something like "--with-ld-opt="-static -lz"" should help.
Likely there will be other similar errors and you'll have to
include other libraries as well. For example, on FreeBSD static
linking with libxslt requires "-static -lz -lm -llzma -lmd".

Something like

pkg-config --static libxslt

might be a good starting point for full list of required
libraries, assuming libxslt package information is properly
installed. Alternatively, ldd on the dynamic library might be a
good start.

Note well that in general it might not be a good idea to compile
things statically unless you have some good reasons to and
understand possible consequences.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Nginx won't build with xslt into static linked binary

Kevin Weis via nginx February 12, 2023 11:32AM

Re: Nginx won't build with xslt into static linked binary

Maxim Dounin February 12, 2023 05:44PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 131
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready