diff mbox series

[1/1] package/zabbix: fix BR2_SHARED_STATIC_LIBS

Message ID 20220531190702.107175-1-fontaine.fabrice@gmail.com
State Superseded
Headers show
Series [1/1] package/zabbix: fix BR2_SHARED_STATIC_LIBS | expand

Commit Message

Fabrice Fontaine May 31, 2022, 7:07 p.m. UTC
--static is added to pkg-config call with BR2_SHARED_STATIC_LIBS
resulting in the following build failure with openssl or libcurl:

configure:13132: /home/autobuild/autobuild/instance-6/output-1/host/bin/or1k-buildroot-linux-gnu-gcc -o conftest -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Ofast -g0  -I/home/autobuild/autobuild/instance-6/output-1/host/or1k-buildroot-linux-gnu/sysroot/usr/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -rdynamic  -static -L/home/autobuild/autobuild/instance-6/output-1/host/or1k-buildroot-linux-gnu/sysroot/usr/lib conftest.c -lssl -lcrypto -lm   >&5
/home/autobuild/autobuild/instance-6/output-1/host/lib/gcc/or1k-buildroot-linux-gnu/10.3.0/../../../../or1k-buildroot-linux-gnu/bin/ld: /home/autobuild/autobuild/instance-6/output-1/host/or1k-buildroot-linux-gnu/sysroot/usr/lib/libcrypto.a(dso_dlfcn.o): in function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x2c): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/autobuild/autobuild/instance-6/output-1/host/lib/gcc/or1k-buildroot-linux-gnu/10.3.0/../../../../or1k-buildroot-linux-gnu/bin/ld: /home/autobuild/autobuild/instance-6/output-1/host/or1k-buildroot-linux-gnu/sysroot/usr/lib/libcrypto.a(b_addr.o): in function `BIO_lookup_ex':
b_addr.c:(.text+0x1128): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/autobuild/autobuild/instance-6/output-1/host/lib/gcc/or1k-buildroot-linux-gnu/10.3.0/../../../../or1k-buildroot-linux-gnu/bin/ld: /home/autobuild/autobuild/instance-6/output-1/host/or1k-buildroot-linux-gnu/sysroot/usr/lib/libcrypto.a(b_sock.o): in function `BIO_gethostbyname':
b_sock.c:(.text+0x90): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/autobuild/autobuild/instance-6/output-1/host/lib/gcc/or1k-buildroot-linux-gnu/10.3.0/../../../../or1k-buildroot-linux-gnu/bin/ld: /tmp/cceWHjDi.o: in function `main':
conftest.c:(.text.startup+0x8): undefined reference to `SSL_connect'

[...]

configure: error: OpenSSL library libssl or libcrypto not found

---

configure:15199: checking for main in -lz
configure:15219: /home/autobuild/autobuild/instance-13/output-1/host/bin/s390x-buildroot-linux-gnu-gcc -o conftest -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Ofast -g0 -D_FORTIFY_SOURCE=2  -I/home/autobuild/autobuild/instance-13/output-1/host/s390x-buildroot-linux-gnu/sysroot/usr/bin/../../usr/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -rdynamic  -static   -L/home/autobuild/autobuild/instance-13/output-1/host/s390x-buildroot-linux-gnu/sysroot/usr/bin/../../usr/lib conftest.c -lz   -lm    >&5
/home/autobuild/autobuild/instance-13/output-1/host/lib/gcc/s390x-buildroot-linux-gnu/10.3.0/../../../../s390x-buildroot-linux-gnu/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status

[...]

configure: error: static library z required for linking libcurl not found

Fixes:
 - http://autobuild.buildroot.org/results/c05230d13fa0538323bb77e8f35533e6dd02453f
 - http://autobuild.buildroot.org/results/cc947038510e16417298b381521f226f7c45f986

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 package/zabbix/zabbix.mk | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Thomas Petazzoni June 1, 2022, 12:27 p.m. UTC | #1
Hello Fabrice,

On Tue, 31 May 2022 21:07:02 +0200
Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:

> --static is added to pkg-config call with BR2_SHARED_STATIC_LIBS
> resulting in the following build failure with openssl or libcurl:
> 
> configure:13132: /home/autobuild/autobuild/instance-6/output-1/host/bin/or1k-buildroot-linux-gnu-gcc -o conftest -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Ofast -g0  -I/home/autobuild/autobuild/instance-6/output-1/host/or1k-buildroot-linux-gnu/sysroot/usr/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -rdynamic  -static -L/home/autobuild/autobuild/instance-6/output-1/host/or1k-buildroot-linux-gnu/sysroot/usr/lib conftest.c -lssl -lcrypto -lm   >&5
> /home/autobuild/autobuild/instance-6/output-1/host/lib/gcc/or1k-buildroot-linux-gnu/10.3.0/../../../../or1k-buildroot-linux-gnu/bin/ld: /home/autobuild/autobuild/instance-6/output-1/host/or1k-buildroot-linux-gnu/sysroot/usr/lib/libcrypto.a(dso_dlfcn.o): in function `dlfcn_globallookup':
> dso_dlfcn.c:(.text+0x2c): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
> /home/autobuild/autobuild/instance-6/output-1/host/lib/gcc/or1k-buildroot-linux-gnu/10.3.0/../../../../or1k-buildroot-linux-gnu/bin/ld: /home/autobuild/autobuild/instance-6/output-1/host/or1k-buildroot-linux-gnu/sysroot/usr/lib/libcrypto.a(b_addr.o): in function `BIO_lookup_ex':
> b_addr.c:(.text+0x1128): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
> /home/autobuild/autobuild/instance-6/output-1/host/lib/gcc/or1k-buildroot-linux-gnu/10.3.0/../../../../or1k-buildroot-linux-gnu/bin/ld: /home/autobuild/autobuild/instance-6/output-1/host/or1k-buildroot-linux-gnu/sysroot/usr/lib/libcrypto.a(b_sock.o): in function `BIO_gethostbyname':
> b_sock.c:(.text+0x90): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
> /home/autobuild/autobuild/instance-6/output-1/host/lib/gcc/or1k-buildroot-linux-gnu/10.3.0/../../../../or1k-buildroot-linux-gnu/bin/ld: /tmp/cceWHjDi.o: in function `main':
> conftest.c:(.text.startup+0x8): undefined reference to `SSL_connect'

Why is this error occurring in the first place? conftest.c has a main()
function calling SSL_connect(), and the gcc command line includes -lssl
-lcrypto. So why is gcc failing here?

> +# With BR2_SHARED_STATIC_LIBS=y, the generic infrastructure adds
> +# --static when calling pkg-config resulting in a build failure with
> +# libcurl or openssl. Adding --disable-static reverts this

This seems to paper over the real problem, but not to be an actual fix.

Thomas
Fabrice Fontaine June 1, 2022, 7:13 p.m. UTC | #2
Hello Thomas,

Le mer. 1 juin 2022 à 14:27, Thomas Petazzoni
<thomas.petazzoni@bootlin.com> a écrit :
>
> Hello Fabrice,
>
> On Tue, 31 May 2022 21:07:02 +0200
> Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:
>
> > --static is added to pkg-config call with BR2_SHARED_STATIC_LIBS

I made a typo here: --static is *NOT* added to pkg-config call with
BR2_SHARED_STATIC_LIBS ...

> > resulting in the following build failure with openssl or libcurl:
> >
> > configure:13132: /home/autobuild/autobuild/instance-6/output-1/host/bin/or1k-buildroot-linux-gnu-gcc -o conftest -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Ofast -g0  -I/home/autobuild/autobuild/instance-6/output-1/host/or1k-buildroot-linux-gnu/sysroot/usr/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -rdynamic  -static -L/home/autobuild/autobuild/instance-6/output-1/host/or1k-buildroot-linux-gnu/sysroot/usr/lib conftest.c -lssl -lcrypto -lm   >&5
> > /home/autobuild/autobuild/instance-6/output-1/host/lib/gcc/or1k-buildroot-linux-gnu/10.3.0/../../../../or1k-buildroot-linux-gnu/bin/ld: /home/autobuild/autobuild/instance-6/output-1/host/or1k-buildroot-linux-gnu/sysroot/usr/lib/libcrypto.a(dso_dlfcn.o): in function `dlfcn_globallookup':
> > dso_dlfcn.c:(.text+0x2c): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
> > /home/autobuild/autobuild/instance-6/output-1/host/lib/gcc/or1k-buildroot-linux-gnu/10.3.0/../../../../or1k-buildroot-linux-gnu/bin/ld: /home/autobuild/autobuild/instance-6/output-1/host/or1k-buildroot-linux-gnu/sysroot/usr/lib/libcrypto.a(b_addr.o): in function `BIO_lookup_ex':
> > b_addr.c:(.text+0x1128): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
> > /home/autobuild/autobuild/instance-6/output-1/host/lib/gcc/or1k-buildroot-linux-gnu/10.3.0/../../../../or1k-buildroot-linux-gnu/bin/ld: /home/autobuild/autobuild/instance-6/output-1/host/or1k-buildroot-linux-gnu/sysroot/usr/lib/libcrypto.a(b_sock.o): in function `BIO_gethostbyname':
> > b_sock.c:(.text+0x90): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
> > /home/autobuild/autobuild/instance-6/output-1/host/lib/gcc/or1k-buildroot-linux-gnu/10.3.0/../../../../or1k-buildroot-linux-gnu/bin/ld: /tmp/cceWHjDi.o: in function `main':
> > conftest.c:(.text.startup+0x8): undefined reference to `SSL_connect'
>
> Why is this error occurring in the first place? conftest.c has a main()
> function calling SSL_connect(), and the gcc command line includes -lssl
> -lcrypto. So why is gcc failing here?

I'm unable to reproduce this build failure with openssl and current
master. So, indeed, there is something fishy.
Instead, I got a build failure with openldap [1] as zabbix wrongly
assumes that gnutls must be available [2] (which I agree is unrelated
to this build failure).
However, If I disable openldap, zabbix fails to build with libcurl [3]
because curl-config will not retrieve idn2 dependencies such as
-lunistring. curl doesn't retrieve them because pkg-config is not
called with --static parameter.

Another solution would be to drop the BR2_SHARED_STATIC_LIBS option as
suggested by Arnout [4].
Do you think that this solution would be better?

[1] https://github.com/zabbix/zabbix/blob/a38b1cecd976017c93a7a2d5c0f5fd903c3d65ba/m4/ldap.m4#L122
[2] http://autobuild.buildroot.org/results/dc0/dc08c4be4bd2c0f02bc70b9b0b8da91e9cefa86b//zabbix-5.4.9/config.log
[3] http://autobuild.buildroot.org/results/39f/39face35a616c9d772edcd3ce1b7b75e62c0ecec/zabbix-5.4.9/config.log
[4] https://patchwork.ozlabs.org/project/buildroot/patch/20220416211323.3200669-1-fontaine.fabrice@gmail.com/

>
> > +# With BR2_SHARED_STATIC_LIBS=y, the generic infrastructure adds
> > +# --static when calling pkg-config resulting in a build failure with
> > +# libcurl or openssl. Adding --disable-static reverts this
>
> This seems to paper over the real problem, but not to be an actual fix.
>
> Thomas
> --
> Thomas Petazzoni, co-owner and CEO, Bootlin
> Embedded Linux and Kernel engineering and training
> https://bootlin.com

Best Regards,

Fabrice
Yann E. MORIN Feb. 7, 2023, 10:53 p.m. UTC | #3
Fabrice, All,

This patch has now reached the infamous status of being the oldest patch
in our backlog... Sorry for that. :-(

On 2022-05-31 21:07 +0200, Fabrice Fontaine spake thusly:
> --static is added to pkg-config call with BR2_SHARED_STATIC_LIBS

As already noticed by Thomas, this is not correct.

In fact, zabix uses custom --enable-{stati,shared} options, instead of
usingthe standard libtool directives:

  1276 AC_ARG_ENABLE(static,[  --enable-static         Build statically linked binaries],
  1277 [case "${enableval}" in
  1278   yes)
  1279     LDFLAGS="${LDFLAGS} -static"
  1280     AC_MSG_CHECKING(if static linking is possible)

This is where your -static is coming from, and is causing those issues.

So, your fix is technically correct (but see below), but for the wrong
reasons.

> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> ---
>  package/zabbix/zabbix.mk | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/package/zabbix/zabbix.mk b/package/zabbix/zabbix.mk
> index adc54028ad..85fd193b4d 100644
> --- a/package/zabbix/zabbix.mk
> +++ b/package/zabbix/zabbix.mk
> @@ -125,6 +125,13 @@ endif
>  
>  endif # BR2_PACKAGE_ZABBIX_SERVER
>  
> +# With BR2_SHARED_STATIC_LIBS=y, the generic infrastructure adds
> +# --static when calling pkg-config resulting in a build failure with

You'll also need to update that comment, of course.

Can you fix the commit log and the comment, and respin, please?

Again, sorry for the ong delay...

Regards,
Yann E. MORIN.

> +# libcurl or openssl. Adding --disable-static reverts this
> +ifeq ($(BR2_SHARED_STATIC_LIBS),y)
> +ZABBIX_CONF_OPTS += --disable-static
> +endif
> +
>  define ZABBIX_INSTALL_INIT_SYSTEMD
>  	$(foreach unit,$(ZABBIX_SYSTEMD_UNITS),\
>  		$(INSTALL) -D -m 0644 $(ZABBIX_PKGDIR)/$(unit) $(TARGET_DIR)/usr/lib/systemd/system/$(unit) && \
> -- 
> 2.35.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
diff mbox series

Patch

diff --git a/package/zabbix/zabbix.mk b/package/zabbix/zabbix.mk
index adc54028ad..85fd193b4d 100644
--- a/package/zabbix/zabbix.mk
+++ b/package/zabbix/zabbix.mk
@@ -125,6 +125,13 @@  endif
 
 endif # BR2_PACKAGE_ZABBIX_SERVER
 
+# With BR2_SHARED_STATIC_LIBS=y, the generic infrastructure adds
+# --static when calling pkg-config resulting in a build failure with
+# libcurl or openssl. Adding --disable-static reverts this
+ifeq ($(BR2_SHARED_STATIC_LIBS),y)
+ZABBIX_CONF_OPTS += --disable-static
+endif
+
 define ZABBIX_INSTALL_INIT_SYSTEMD
 	$(foreach unit,$(ZABBIX_SYSTEMD_UNITS),\
 		$(INSTALL) -D -m 0644 $(ZABBIX_PKGDIR)/$(unit) $(TARGET_DIR)/usr/lib/systemd/system/$(unit) && \