Skip to contentSkip to conversation

package/zabbix: fix BR2_SHARED_STATIC_LIBS

PATCH In review Fabrice Fontaine 3 participants 4 messages May 31, 2022 – Feb 7, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/zabbix: fix BR2_SHARED_STATIC_LIBS

--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

---
 package/zabbix/zabbix.mk | 7 +++++++
 1 file changed, 7 insertions(+)
package/zabbix/zabbix.mk +7 -0
index adc54028ad..85fd193b4d 100644
@@ -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) && \
Signature · 6 lines
2.35.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Hello Fabrice,

Quoted 12 lines · On Tue, 31 May 2022 21:07:02 +0200 Fabrice Fontaine…

--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?

package/zabbix/zabbix.mk endif · line 130

Quoted 3 lines
package/zabbix/zabbix.mk +3 -0
+# 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

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Hello Thomas,

Quoted 7 lines · Thomas Petazzoni

Hello Fabrice,

Quoted 1 line · On Tue, 31 May 2022 21:07:02 +0200 Fabrice Fontaine…

--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 ...

Quoted 12 lines
Quoted 11 lines

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'

Quoted 3 lines

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/[email protected]/

Quoted 7 lines

package/zabbix/zabbix.mk endif · line 130

Quoted 4 lines
package/zabbix/zabbix.mk +3 -0
+# 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.

Quoted 5 lines

Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training
https://bootlin.com

Best Regards,

Fabrice
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw
In reply to Fabrice Fontaine

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:

Quoted 1 line

--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.

Quoted 10 lines
---
 package/zabbix/zabbix.mk | 7 +++++++
 1 file changed, 7 insertions(+)
package/zabbix/zabbix.mk +0 -0
index adc54028ad..85fd193b4d 100644

package/zabbix/zabbix.mk endif · line 129

Quoted 5 lines
package/zabbix/zabbix.mk +2 -0
@@ -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.

Quoted 15 lines
package/zabbix/zabbix.mk +5 -0
+# 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) && \
Signature · 6 lines
2.35.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot