diff mbox series

[1/4] package/bind: enable static build

Message ID 20190423212406.13909-1-fontaine.fabrice@gmail.com
State Superseded
Headers show
Series [1/4] package/bind: enable static build | expand

Commit Message

Fabrice Fontaine April 23, 2019, 9:24 p.m. UTC
Static build has been disabled in 2014 with commit
6045904752b06a8b8e52ba8fc2e49a8548964e8d however bind can be built
statically thanks to --without-dlopen so enable it back

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 ...n_driver.c-fix-build-without-dlfcn.h.patch | 28 +++++++++++++++++++
 package/bind/Config.in                        |  5 ++--
 package/bind/bind.mk                          |  4 ++-
 3 files changed, 33 insertions(+), 4 deletions(-)
 create mode 100644 package/bind/0002-dlz_open_driver.c-fix-build-without-dlfcn.h.patch

Comments

Thomas Petazzoni April 24, 2019, 8:34 p.m. UTC | #1
Hello Fabrice,

On Tue, 23 Apr 2019 23:24:03 +0200
Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:

> Static build has been disabled in 2014 with commit
> 6045904752b06a8b8e52ba8fc2e49a8548964e8d however bind can be built
> statically thanks to --without-dlopen so enable it back
> 
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> ---
>  ...n_driver.c-fix-build-without-dlfcn.h.patch | 28 +++++++++++++++++++
>  package/bind/Config.in                        |  5 ++--
>  package/bind/bind.mk                          |  4 ++-
>  3 files changed, 33 insertions(+), 4 deletions(-)
>  create mode 100644 package/bind/0002-dlz_open_driver.c-fix-build-without-dlfcn.h.patch

The series looks good in principle, but sadly the following defconfig:

BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2019.02-rc1.tar.bz2"
BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_14=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_DHCP=y
# BR2_TARGET_ROOTFS_TAR is not set

fails to build with:

configure: error: Cannot find static libraries at /home/thomas/projets/buildroot/output/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib
make[1]: *** [package/pkg-generic.mk:231: /home/thomas/projets/buildroot/output/build/dhcp-4.4.1/.stamp_configured] Error 1

Looking at configure.ac sheds some light:

AC_ARG_ENABLE(libtool,
        AS_HELP_STRING([--enable-libtool],
[use GNU libtool for dynamic shared libraries (default is no).]),
        want_libtool="$enableval")

if test "$use_libbind" != "no"; then
        if test "$want_libtool" = "yes" -a \
                ! -f "$use_libbind/lib/libisc.la"
        then
                AC_MSG_ERROR([Cannot find dynamic libraries at $use_libbind/lib])
        fi
        if test "$want_libtool" = "no" -a \
                ! -f "$use_libbind/lib/libisc.a"
        then
                AC_MSG_ERROR([Cannot find static libraries at $use_libbind/lib])
        fi
fi

We are not passing --enable-libtool, so the code checks is libisc.a
exists, and it doesn't because a default build is BR2_SHARED_LIBS=y,
and therefore bind doesn't build/install any static library.

I suppose passing --enable-libtool would work, but I haven't tested.

Best regards,

Thomas
Fabrice Fontaine April 24, 2019, 8:46 p.m. UTC | #2
Hello Thomas,

Le mer. 24 avr. 2019 à 22:34, Thomas Petazzoni
<thomas.petazzoni@bootlin.com> a écrit :
>
> Hello Fabrice,
>
> On Tue, 23 Apr 2019 23:24:03 +0200
> Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:
>
> > Static build has been disabled in 2014 with commit
> > 6045904752b06a8b8e52ba8fc2e49a8548964e8d however bind can be built
> > statically thanks to --without-dlopen so enable it back
> >
> > Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> > ---
> >  ...n_driver.c-fix-build-without-dlfcn.h.patch | 28 +++++++++++++++++++
> >  package/bind/Config.in                        |  5 ++--
> >  package/bind/bind.mk                          |  4 ++-
> >  3 files changed, 33 insertions(+), 4 deletions(-)
> >  create mode 100644 package/bind/0002-dlz_open_driver.c-fix-build-without-dlfcn.h.patch
>
> The series looks good in principle, but sadly the following defconfig:
>
> BR2_arm=y
> BR2_TOOLCHAIN_EXTERNAL=y
> BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
> BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
> BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2019.02-rc1.tar.bz2"
> BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y
> BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_14=y
> BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
> # BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
> BR2_TOOLCHAIN_EXTERNAL_CXX=y
> BR2_INIT_NONE=y
> BR2_SYSTEM_BIN_SH_NONE=y
> # BR2_PACKAGE_BUSYBOX is not set
> BR2_PACKAGE_DHCP=y
> # BR2_TARGET_ROOTFS_TAR is not set
>
> fails to build with:
>
> configure: error: Cannot find static libraries at /home/thomas/projets/buildroot/output/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib
> make[1]: *** [package/pkg-generic.mk:231: /home/thomas/projets/buildroot/output/build/dhcp-4.4.1/.stamp_configured] Error 1
>
> Looking at configure.ac sheds some light:
>
> AC_ARG_ENABLE(libtool,
>         AS_HELP_STRING([--enable-libtool],
> [use GNU libtool for dynamic shared libraries (default is no).]),
>         want_libtool="$enableval")
>
> if test "$use_libbind" != "no"; then
>         if test "$want_libtool" = "yes" -a \
>                 ! -f "$use_libbind/lib/libisc.la"
>         then
>                 AC_MSG_ERROR([Cannot find dynamic libraries at $use_libbind/lib])
>         fi
>         if test "$want_libtool" = "no" -a \
>                 ! -f "$use_libbind/lib/libisc.a"
>         then
>                 AC_MSG_ERROR([Cannot find static libraries at $use_libbind/lib])
>         fi
> fi
>
> We are not passing --enable-libtool, so the code checks is libisc.a
> exists, and it doesn't because a default build is BR2_SHARED_LIBS=y,
> and therefore bind doesn't build/install any static library.
>
> I suppose passing --enable-libtool would work, but I haven't tested.
OK, I'll test it and send a v2.
>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
Fabrice
diff mbox series

Patch

diff --git a/package/bind/0002-dlz_open_driver.c-fix-build-without-dlfcn.h.patch b/package/bind/0002-dlz_open_driver.c-fix-build-without-dlfcn.h.patch
new file mode 100644
index 0000000000..8b73e746e4
--- /dev/null
+++ b/package/bind/0002-dlz_open_driver.c-fix-build-without-dlfcn.h.patch
@@ -0,0 +1,28 @@ 
+From 92b738a0fe8a7d65346de9e6dd7a8f135ee29765 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Date: Tue, 23 Apr 2019 22:45:25 +0200
+Subject: [PATCH] dlz_open_driver.c: fix build without dlfcn.h
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+[Upstream status: https://gitlab.isc.org/isc-projects/bind9/issues/995]
+---
+ bin/named/unix/dlz_dlopen_driver.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/bin/named/unix/dlz_dlopen_driver.c b/bin/named/unix/dlz_dlopen_driver.c
+index 74d29ffa09..ab8a5c9493 100644
+--- a/bin/named/unix/dlz_dlopen_driver.c
++++ b/bin/named/unix/dlz_dlopen_driver.c
+@@ -14,7 +14,9 @@
+ #include <inttypes.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if HAVE_DLFCN_H
+ #include <dlfcn.h>
++#endif
+ 
+ #include <dns/log.h>
+ #include <dns/result.h>
+-- 
+2.20.1
+
diff --git a/package/bind/Config.in b/package/bind/Config.in
index 049a90cbaf..5b34b66f7a 100644
--- a/package/bind/Config.in
+++ b/package/bind/Config.in
@@ -2,7 +2,6 @@  config BR2_PACKAGE_BIND
 	bool "bind"
 	depends on BR2_USE_MMU # fork()
 	depends on BR2_TOOLCHAIN_HAS_THREADS
-	depends on !BR2_STATIC_LIBS
 	help
 	  BIND (Berkeley Internet Name Domain) is an
 	  implementation of the Domain Name System (DNS) protocols
@@ -41,6 +40,6 @@  config BR2_PACKAGE_BIND_TOOLS
 
 endif
 
-comment "bind needs a toolchain w/ threads, dynamic library"
+comment "bind needs a toolchain w/ threads"
 	depends on BR2_USE_MMU
-	depends on !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS
+	depends on !BR2_TOOLCHAIN_HAS_THREADS
diff --git a/package/bind/bind.mk b/package/bind/bind.mk
index b2bbafab20..30a4482db5 100644
--- a/package/bind/bind.mk
+++ b/package/bind/bind.mk
@@ -24,6 +24,7 @@  BIND_CONF_ENV = \
 	BUILD_CC="$(TARGET_CC)" \
 	BUILD_CFLAGS="$(TARGET_CFLAGS)"
 BIND_CONF_OPTS = \
+	$(if $(BR2_STATIC_LIBS),--with-dlopen,--without-dlopen) \
 	--without-lmdb \
 	--with-libjson=no \
 	--with-randomdev=/dev/urandom \
@@ -54,12 +55,13 @@  BIND_CONF_OPTS += --with-libxml2=no
 endif
 
 ifeq ($(BR2_PACKAGE_OPENSSL),y)
-BIND_DEPENDENCIES += openssl
+BIND_DEPENDENCIES += host-pkgconf openssl
 BIND_CONF_OPTS += \
 	--with-openssl=$(STAGING_DIR)/usr \
 	--with-ecdsa=yes \
 	--with-eddsa=no \
 	--with-aes=yes
+BIND_CONF_ENV += LIBS=`$(PKG_CONFIG_HOST_BINARY) --libs openssl`
 # GOST cipher support requires openssl extra engines
 ifeq ($(BR2_PACKAGE_OPENSSL_ENGINES),y)
 BIND_CONF_OPTS += --with-gost=yes