diff mbox series

package/nettle: add missing host-gmp dependency

Message ID 20231026095506.876284-1-fabien.thomas@smile.fr
State Accepted
Headers show
Series package/nettle: add missing host-gmp dependency | expand

Commit Message

Fabien Thomas Oct. 26, 2023, 9:55 a.m. UTC
Since the generic package infrastructure removed auto derivation of
host dependencies [1] (2016.08), the host dependencies must be
explicitly set.

While adding the nettle host variant [2] the gmp dependency was not
duplicated and host-nettle was built without host-gmp (or built with
gmp installed on the build machine).

While building host-gnutls required for building mkeficapsule u-boot
tool, the configure script check if Libhogweed (nettle's companion
library) is build with libgmp support.

If internal toolchain is used, luckily host-gmp is built before
building host-nettle (and host-gnutls). But when using prebuilt
external toolchain, following error shows up :

Libhogweed (nettle's companion library) 3.6 was not found. Note that you must compile nettle with gmp support.

[1] https://gitlab.com/buildroot.org/buildroot/-/commit/4bdb067e380e72c3a6cb9c6ccf3791a6cf8661e0
[2] https://gitlab.com/buildroot.org/buildroot/-/commit/dac6e3011883ce3b35cbf64ec156186153bf0032
[3] https://gitlab.com/gnutls/gnutls/-/commit/eb24bfa808ee029e9b3b198d66d29256eea3fd08

Signed-off-by: Fabien Thomas <fabien.thomas@smile.fr>
---
 package/nettle/nettle.mk | 2 ++
 1 file changed, 2 insertions(+)

Comments

Romain Naour Oct. 26, 2023, 10:27 a.m. UTC | #1
Hi Fabien,

Le 26/10/2023 à 11:55, Fabien Thomas a écrit :
> Since the generic package infrastructure removed auto derivation of
> host dependencies [1] (2016.08), the host dependencies must be
> explicitly set.
> 
> While adding the nettle host variant [2] the gmp dependency was not
> duplicated and host-nettle was built without host-gmp (or built with
> gmp installed on the build machine).
> 
> While building host-gnutls required for building mkeficapsule u-boot
> tool, the configure script check if Libhogweed (nettle's companion
> library) is build with libgmp support.
> 
> If internal toolchain is used, luckily host-gmp is built before
> building host-nettle (and host-gnutls). But when using prebuilt
> external toolchain, following error shows up :
> 
> Libhogweed (nettle's companion library) 3.6 was not found. Note that you must compile nettle with gmp support.
> 
> [1] https://gitlab.com/buildroot.org/buildroot/-/commit/4bdb067e380e72c3a6cb9c6ccf3791a6cf8661e0
> [2] https://gitlab.com/buildroot.org/buildroot/-/commit/dac6e3011883ce3b35cbf64ec156186153bf0032
> [3] https://gitlab.com/gnutls/gnutls/-/commit/eb24bfa808ee029e9b3b198d66d29256eea3fd08
> 
> Signed-off-by: Fabien Thomas <fabien.thomas@smile.fr>

Reviewed-by: Romain Naour <romain.naour@smile.fr>
Acked-by: Romain Naour <romain.naour@smile.fr>

Best regards,
Romain

> ---
>  package/nettle/nettle.mk | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/package/nettle/nettle.mk b/package/nettle/nettle.mk
> index dd4dfbbe38..e2e3219057 100644
> --- a/package/nettle/nettle.mk
> +++ b/package/nettle/nettle.mk
> @@ -15,6 +15,8 @@ NETTLE_CPE_ID_VENDOR = nettle_project
>  # with static linking
>  NETTLE_CONF_OPTS = --disable-openssl
>  
> +HOST_NETTLE_DEPENDENCIES = host-gmp
> +
>  # ARM assembly requires v6+ ISA
>  ifeq ($(BR2_ARM_CPU_ARMV4)$(BR2_ARM_CPU_ARMV5)$(BR2_ARM_CPU_ARMV7M),y)
>  NETTLE_CONF_OPTS += --disable-assembler
Thomas Petazzoni Nov. 1, 2023, 11:40 a.m. UTC | #2
Hello Fabien,

On Thu, 26 Oct 2023 11:55:06 +0200
Fabien Thomas <fabien.thomas@smile.fr> wrote:

> Since the generic package infrastructure removed auto derivation of
> host dependencies [1] (2016.08), the host dependencies must be
> explicitly set.
> 
> While adding the nettle host variant [2] the gmp dependency was not
> duplicated and host-nettle was built without host-gmp (or built with
> gmp installed on the build machine).
> 
> While building host-gnutls required for building mkeficapsule u-boot
> tool, the configure script check if Libhogweed (nettle's companion
> library) is build with libgmp support.
> 
> If internal toolchain is used, luckily host-gmp is built before
> building host-nettle (and host-gnutls). But when using prebuilt
> external toolchain, following error shows up :
> 
> Libhogweed (nettle's companion library) 3.6 was not found. Note that you must compile nettle with gmp support.
> 
> [1] https://gitlab.com/buildroot.org/buildroot/-/commit/4bdb067e380e72c3a6cb9c6ccf3791a6cf8661e0
> [2] https://gitlab.com/buildroot.org/buildroot/-/commit/dac6e3011883ce3b35cbf64ec156186153bf0032
> [3] https://gitlab.com/gnutls/gnutls/-/commit/eb24bfa808ee029e9b3b198d66d29256eea3fd08
> 
> Signed-off-by: Fabien Thomas <fabien.thomas@smile.fr>
> ---
>  package/nettle/nettle.mk | 2 ++
>  1 file changed, 2 insertions(+)

I have applied, but to be honest, I wasn't sure. Indeed, gmp is
actually an optional dependency of the nettle package. We do handle it
as a mandatory dependency for the target nettle package, which I
believe isn't correct as we really try hard in Buildroot to not make
dependencies mandatory when they really are not.

In addition, it should be associated to the actual feature that needs
it. So I believe we would ideally need to do this:

 NETTLE_VERSION = 3.9.1
 NETTLE_SITE = https://ftp.gnu.org/gnu/nettle
-NETTLE_DEPENDENCIES = host-m4 gmp
+NETTLE_DEPENDENCIES = host-m4
 NETTLE_INSTALL_STAGING = YES
 NETTLE_LICENSE = Dual GPL-2.0+/LGPL-3.0+
 NETTLE_LICENSE_FILES = COPYING.LESSERv3 COPYINGv2
@@ -15,6 +15,13 @@ NETTLE_CPE_ID_VENDOR = nettle_project
 # with static linking
 NETTLE_CONF_OPTS = --disable-openssl
 
+ifeq ($(BR2_PACKAGE_GMP),y)
+NETTLE_CONF_OPTS += --enable-public-key
+NETTLE_DEPENDENCIES += gmp
+else
+NETTLE_CONF_OPTS += --disable-public-key
+endif
+
 HOST_NETTLE_DEPENDENCIES = host-m4 host-gmp
 
 # ARM assembly requires v6+ ISA

But of course this requires analyzing the reverse dependencies of
nettle, to figure out the ones that need vs. the ones that don't need
the public key support. The ones that need public key support would
have to select BR2_PACKAGE_GMP.

For the host variant of nettle, I'm not sure. We are a little bit less
strict on making all dependencies optional for host packages, because
there's no impact on the target root filesystem size, only an impact on
the build time. That's why I applied your patch as-is, even if you're
handling an optional dependency as a mandatory dependency.

Best regards,

Thomas
diff mbox series

Patch

diff --git a/package/nettle/nettle.mk b/package/nettle/nettle.mk
index dd4dfbbe38..e2e3219057 100644
--- a/package/nettle/nettle.mk
+++ b/package/nettle/nettle.mk
@@ -15,6 +15,8 @@  NETTLE_CPE_ID_VENDOR = nettle_project
 # with static linking
 NETTLE_CONF_OPTS = --disable-openssl
 
+HOST_NETTLE_DEPENDENCIES = host-gmp
+
 # ARM assembly requires v6+ ISA
 ifeq ($(BR2_ARM_CPU_ARMV4)$(BR2_ARM_CPU_ARMV5)$(BR2_ARM_CPU_ARMV7M),y)
 NETTLE_CONF_OPTS += --disable-assembler