Hi,
commit 57e304262262b0f483d76f9981bb4b99b8ec2869 breaks certain builds (likely those with --disable-shared). As a side effect, the oss-fuzz build for Wget2 fails.
Example:
./.bootstrap ./configure --enable-mini-gmp --enable-static --disable-shared --disable-documentation make clean && make
... make[1]: Entering directory '/usr/oms/src/nettle/testsuite' gcc -I.. -I.. -DHAVE_CONFIG_H -g -ggdb3 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -MT sha1-huge-test.o -MD -MP -MF sha1-huge-test.o.d -c sha1-huge-test.c && true gcc -I.. -I.. -DHAVE_CONFIG_H -g -ggdb3 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -MT testutils.o -MD -MP -MF testutils.o.d -c testutils.c && true In file included from testutils.c:3:0: testutils.c: In function ‘tstring_hex’: testutils.c:82:13: warning: pointer targets in passing argument 5 of ‘nettle_base16_decode_update’ differ in signedness [-Wpointer-sign] length, hex)); ^ testutils.h:293:11: note: in definition of macro ‘ASSERT’ if (!(x)) \ ^ In file included from testutils.c:5:0: ../base16.h:49:30: note: expected ‘const uint8_t * {aka const unsigned char *}’ but argument is of type ‘const char *’ #define base16_decode_update nettle_base16_decode_update ^ ../base16.h:96:1: note: in expansion of macro ‘base16_decode_update’ base16_decode_update(struct base16_decode_ctx *ctx, ^~~~~~~~~~~~~~~~~~~~ gcc -g -ggdb3 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -L.. sha1-huge-test.o testutils.o ../nettle-internal.o -lhogweed -lnettle -o sha1-huge-test ../libhogweed.a(mini-gmp.o): In function `mpn_zero_p': /usr/oms/src/nettle/mini-gmp.c:391: multiple definition of `mpn_zero_p' testutils.o:/usr/oms/src/nettle/testsuite/testutils.c:612: first defined here collect2: error: ld returned 1 exit status .test-rules.make:263: recipe for target 'sha1-huge-test' failed make[1]: *** [sha1-huge-test] Error 1 make[1]: Leaving directory '/usr/oms/src/nettle/testsuite' Makefile:49: recipe for target 'all' failed make: *** [all] Error 2
Regards, Tim
Tim Rühsen tim.ruehsen@gmx.de writes:
commit 57e304262262b0f483d76f9981bb4b99b8ec2869 breaks certain builds (likely those with --disable-shared). As a side effect, the oss-fuzz build for Wget2 fails.
Example:
../libhogweed.a(mini-gmp.o): In function `mpn_zero_p': /usr/oms/src/nettle/mini-gmp.c:391: multiple definition of `mpn_zero_p' testutils.o:/usr/oms/src/nettle/testsuite/testutils.c:612: first defined here
I see. Problem is, we can't use mpn_zero_p unconditionally (unless we want to require gmp-6.1.0 or later). And it was added to mini-gmp in the update of that commit.
The below patch to the testutils.h #ifdef:ery seems to fix the problem for me. Not sure if there's any prettier way to deal with it. (There's a corresponding #ifdef mpn_zero_p in the testutils.c file, which we don't need to touch if we do it this way).
Thanks for the bug report, /Niels
--- a/testsuite/testutils.h +++ b/testsuite/testutils.h @@ -163,13 +163,6 @@ test_armor(const struct nettle_armor *armor, const char *ascii);
#if WITH_HOGWEED -#ifndef mpn_zero_p -int -mpn_zero_p (mp_srcptr ap, mp_size_t n); -#endif - -void -mpn_out_str (FILE *f, int base, const mp_limb_t *xp, mp_size_t xn);
#if NETTLE_USE_MINI_GMP typedef struct knuth_lfib_ctx gmp_randstate_t[1]; @@ -180,8 +173,20 @@ void mpz_urandomb (mpz_t r, struct knuth_lfib_ctx *ctx, mp_bitcnt_t bits); /* This is cheating */ #define mpz_rrandomb mpz_urandomb
+/* mini-gmp defines this function (in the GMP library, it was added in + gmp in version 6.1.0). */ +#define mpn_zero_p mpn_zero_p + #endif /* NETTLE_USE_MINI_GMP */
+#ifndef mpn_zero_p +int +mpn_zero_p (mp_srcptr ap, mp_size_t n); +#endif + +void +mpn_out_str (FILE *f, int base, const mp_limb_t *xp, mp_size_t xn); + mp_limb_t * xalloc_limbs (mp_size_t n);
nettle-bugs@lists.lysator.liu.se