Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: conflicting types for 'fmul' #9

Closed
pyperanger opened this issue Oct 17, 2018 · 14 comments
Closed

error: conflicting types for 'fmul' #9

pyperanger opened this issue Oct 17, 2018 · 14 comments

Comments

@pyperanger
Copy link

pyperanger commented Oct 17, 2018

I don't know if this error is part of the module, but i resolved this issue change variable name and the calls.

OS => ArchLinux

FIX
grep -rl "fmul" ./ | xargs sed -i 's/fmul/fixedvar/g'

ERROR
curve25519-donna-c64.c:99:1: error: conflicting types for 'fmul' fmull(felem output, const felem in2, const felem in) { ^~~~~ In file included from /usr/lib/perl5/5.28/core_perl/CORE/perl.h:2026, from Curve25519.xs:3: /usr/include/bits/mathcalls-narrow.h:30:20: note: previous declaration of 'fmul' was here __MATHCALL_NARROW (__MATHCALL_NAME (mul), __MATHCALL_REDIR_NAME (mul), 2); ^~~~~~~~~~~~~~~ make: *** [Makefile:334: Curve25519.o] Error 1

PS => I found this error during execution of Net::Perl::SSH module.

@pwr22
Copy link

pwr22 commented Dec 11, 2018

I've also hit this on Manjaro - installing 0.05 works fine

@andk
Copy link

andk commented Dec 16, 2018

Also broken on Ubuntu cosmic (18.10).

@pyperanger
Copy link
Author

pyperanger commented Dec 17, 2018

Try this in the directory before compile: grep -rl "fmul" ./ | xargs sed -i 's/fmul/fixedvar/g'

I made a fork with the fix-> https://github.com/pyperanger/crypt-curve25519

@nailara-technologies
Copy link

nailara-technologies commented Dec 19, 2018

same here on debian 686-pae, the conflict was in /usr/include/i386-linux-gnu/bits/mathcalls-narrow.h
and renaming fmul works as well

gentoo-bot pushed a commit to gentoo/gentoo that referenced this issue Jun 13, 2019
With thanks to Mike Benson for trawling the upstream bug reports:
ajgb/crypt-curve25519#9 (comment)

No revision bump as the package does not install without the fix.
This uses a patch rather than a sed statement, as the latter could fail
silently.

Closes: https://bugs.gentoo.org/669436
Suggested-By: Mike Benson <mike@kambe.com.au>
Signed-Off-By: Tony Vroon <chainsaw@gentoo.org>
Package-Manager: Portage-2.3.66, Repoman-2.3.11
@nailara-technologies
Copy link

greetinx,

...now it no longer compiles on debian 64-bit as well... until this issue is fixed, the unmodified original has unfortunately become useless for direct installation from either CPAN or Github..

..is there any chance the author will fix the variable name, or can we consider Crypt::Curve25519 as abandoned / no longer maintained?

apologies for being so 'blunt' about this..

Taeki

@pyperanger
Copy link
Author

Send here the new error code... ajgb is away, but the community is always here ;)

@eserte
Copy link

eserte commented Sep 28, 2019

CPAN.pm users may use the following distropref file for automatic patching:
https://github.com/eserte/srezic-cpan-distroprefs/blob/master/Crypt-Curve25519.yml

@gitcnd
Copy link

gitcnd commented Mar 3, 2020

See attachment "patch_Curve25519.patch.txt".


# cd /root/.cpan/build/Crypt-Curve25519-0.06-1
# patch < patch_Curve25519.patch.txt 
patching file curve25519-donna.c
patching file curve25519-donna-c64.c

# perl Makefile.PL 
Generating a Unix-style Makefile
Writing Makefile for Crypt::Curve25519
Writing MYMETA.yml and MYMETA.json

# make test

[snip - works now]

# make install
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Curve25519.bs blib/arch/auto/Crypt/Curve25519/Curve25519.bs 644
Manifying 1 pod document
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/local/lib64/perl5/auto/Crypt/Curve25519/Curve25519.so
Installing /usr/local/lib64/perl5/Crypt/Curve25519.pm
Installing /usr/local/share/man/man3/Crypt::Curve25519.3pm
Appending installation info to /usr/lib64/perl5/perllocal.pod

[patch_Curve25519.patch.txt](https://github.com/ajgb/crypt-curve25519/files/4279114/patch_Curve25519.patch.txt)

@gitcnd
Copy link

gitcnd commented Mar 3, 2020

diff -Naur './curve25519-donna-200303.c' './curve25519-donna.c'
--- /home/cnd/keep/curve25519-donna-200303.c	2017-04-05 23:25:50.000000000 +0000
+++ ./curve25519-donna.c	2020-03-03 03:28:00.525177420 +0000
@@ -325,7 +325,7 @@
  * reduced coefficient.
  */
 static void
-fmul(limb *output, const limb *in, const limb *in2) {
+fmulcnd(limb *output, const limb *in, const limb *in2) {
   limb t[19];
   fproduct(t, in, in2);
   freduce_degree(t);
@@ -661,54 +661,54 @@
   /* 2 */ fsquare(z2,z);
   /* 4 */ fsquare(t1,z2);
   /* 8 */ fsquare(t0,t1);
-  /* 9 */ fmul(z9,t0,z);
-  /* 11 */ fmul(z11,z9,z2);
+  /* 9 */ fmulcnd(z9,t0,z);
+  /* 11 */ fmulcnd(z11,z9,z2);
   /* 22 */ fsquare(t0,z11);
-  /* 2^5 - 2^0 = 31 */ fmul(z2_5_0,t0,z9);
+  /* 2^5 - 2^0 = 31 */ fmulcnd(z2_5_0,t0,z9);
 
   /* 2^6 - 2^1 */ fsquare(t0,z2_5_0);
   /* 2^7 - 2^2 */ fsquare(t1,t0);
   /* 2^8 - 2^3 */ fsquare(t0,t1);
   /* 2^9 - 2^4 */ fsquare(t1,t0);
   /* 2^10 - 2^5 */ fsquare(t0,t1);
-  /* 2^10 - 2^0 */ fmul(z2_10_0,t0,z2_5_0);
+  /* 2^10 - 2^0 */ fmulcnd(z2_10_0,t0,z2_5_0);
 
   /* 2^11 - 2^1 */ fsquare(t0,z2_10_0);
   /* 2^12 - 2^2 */ fsquare(t1,t0);
   /* 2^20 - 2^10 */ for (i = 2;i < 10;i += 2) { fsquare(t0,t1); fsquare(t1,t0); }
-  /* 2^20 - 2^0 */ fmul(z2_20_0,t1,z2_10_0);
+  /* 2^20 - 2^0 */ fmulcnd(z2_20_0,t1,z2_10_0);
 
   /* 2^21 - 2^1 */ fsquare(t0,z2_20_0);
   /* 2^22 - 2^2 */ fsquare(t1,t0);
   /* 2^40 - 2^20 */ for (i = 2;i < 20;i += 2) { fsquare(t0,t1); fsquare(t1,t0); }
-  /* 2^40 - 2^0 */ fmul(t0,t1,z2_20_0);
+  /* 2^40 - 2^0 */ fmulcnd(t0,t1,z2_20_0);
 
   /* 2^41 - 2^1 */ fsquare(t1,t0);
   /* 2^42 - 2^2 */ fsquare(t0,t1);
   /* 2^50 - 2^10 */ for (i = 2;i < 10;i += 2) { fsquare(t1,t0); fsquare(t0,t1); }
-  /* 2^50 - 2^0 */ fmul(z2_50_0,t0,z2_10_0);
+  /* 2^50 - 2^0 */ fmulcnd(z2_50_0,t0,z2_10_0);
 
   /* 2^51 - 2^1 */ fsquare(t0,z2_50_0);
   /* 2^52 - 2^2 */ fsquare(t1,t0);
   /* 2^100 - 2^50 */ for (i = 2;i < 50;i += 2) { fsquare(t0,t1); fsquare(t1,t0); }
-  /* 2^100 - 2^0 */ fmul(z2_100_0,t1,z2_50_0);
+  /* 2^100 - 2^0 */ fmulcnd(z2_100_0,t1,z2_50_0);
 
   /* 2^101 - 2^1 */ fsquare(t1,z2_100_0);
   /* 2^102 - 2^2 */ fsquare(t0,t1);
   /* 2^200 - 2^100 */ for (i = 2;i < 100;i += 2) { fsquare(t1,t0); fsquare(t0,t1); }
-  /* 2^200 - 2^0 */ fmul(t1,t0,z2_100_0);
+  /* 2^200 - 2^0 */ fmulcnd(t1,t0,z2_100_0);
 
   /* 2^201 - 2^1 */ fsquare(t0,t1);
   /* 2^202 - 2^2 */ fsquare(t1,t0);
   /* 2^250 - 2^50 */ for (i = 2;i < 50;i += 2) { fsquare(t0,t1); fsquare(t1,t0); }
-  /* 2^250 - 2^0 */ fmul(t0,t1,z2_50_0);
+  /* 2^250 - 2^0 */ fmulcnd(t0,t1,z2_50_0);
 
   /* 2^251 - 2^1 */ fsquare(t1,t0);
   /* 2^252 - 2^2 */ fsquare(t0,t1);
   /* 2^253 - 2^3 */ fsquare(t1,t0);
   /* 2^254 - 2^4 */ fsquare(t0,t1);
   /* 2^255 - 2^5 */ fsquare(t1,t0);
-  /* 2^255 - 21 */ fmul(out,t1,z11);
+  /* 2^255 - 21 */ fmulcnd(out,t1,z11);
 }
 
 int curve25519_donna(u8 *, const u8 *, const u8 *);
@@ -727,7 +727,7 @@
   fexpand(bp, basepoint);
   cmult(x, z, e, bp);
   crecip(zmone, z);
-  fmul(z, x, zmone);
+  fmulcnd(z, x, zmone);
   freduce_coefficients(z);
   fcontract(mypublic, z);
   return 0;
diff -Naur './curve25519-donna-c64-200303.c' './curve25519-donna-c64.c'
--- /home/cnd/keep/curve25519-donna-c64-200303.c	2017-04-05 23:25:50.000000000 +0000
+++ ./curve25519-donna-c64.c	2020-03-03 03:28:21.942742166 +0000
@@ -96,7 +96,7 @@
  * On return, output[i] < 2**52
  */
 static inline void force_inline
-fmul(felem output, const felem in2, const felem in) {
+fmulcnd(felem output, const felem in2, const felem in) {
   uint128_t t[5];
   limb r0,r1,r2,r3,r4,s0,s1,s2,s3,s4,c;
 
@@ -305,22 +305,22 @@
   memcpy(origxprime, xprime, sizeof(limb) * 5);
   fsum(xprime, zprime);
   fdifference_backwards(zprime, origxprime);
-  fmul(xxprime, xprime, z);
-  fmul(zzprime, x, zprime);
+  fmulcnd(xxprime, xprime, z);
+  fmulcnd(zzprime, x, zprime);
   memcpy(origxprime, xxprime, sizeof(limb) * 5);
   fsum(xxprime, zzprime);
   fdifference_backwards(zzprime, origxprime);
   fsquare_times(x3, xxprime, 1);
   fsquare_times(zzzprime, zzprime, 1);
-  fmul(z3, zzzprime, qmqp);
+  fmulcnd(z3, zzzprime, qmqp);
 
   fsquare_times(xx, x, 1);
   fsquare_times(zz, z, 1);
-  fmul(x2, xx, zz);
+  fmulcnd(x2, xx, zz);
   fdifference_backwards(zz, xx);  // does zz = xx - zz
   fscalar_product(zzz, zz, 121665);
   fsum(zzz, xx);
-  fmul(z2, zz, zzz);
+  fmulcnd(z2, zz, zzz);
 }
 
 // -----------------------------------------------------------------------------
@@ -405,26 +405,26 @@
 
   /* 2 */ fsquare_times(a, z, 1); // a = 2
   /* 8 */ fsquare_times(t0, a, 2);
-  /* 9 */ fmul(b, t0, z); // b = 9
-  /* 11 */ fmul(a, b, a); // a = 11
+  /* 9 */ fmulcnd(b, t0, z); // b = 9
+  /* 11 */ fmulcnd(a, b, a); // a = 11
   /* 22 */ fsquare_times(t0, a, 1);
-  /* 2^5 - 2^0 = 31 */ fmul(b, t0, b);
+  /* 2^5 - 2^0 = 31 */ fmulcnd(b, t0, b);
   /* 2^10 - 2^5 */ fsquare_times(t0, b, 5);
-  /* 2^10 - 2^0 */ fmul(b, t0, b);
+  /* 2^10 - 2^0 */ fmulcnd(b, t0, b);
   /* 2^20 - 2^10 */ fsquare_times(t0, b, 10);
-  /* 2^20 - 2^0 */ fmul(c, t0, b);
+  /* 2^20 - 2^0 */ fmulcnd(c, t0, b);
   /* 2^40 - 2^20 */ fsquare_times(t0, c, 20);
-  /* 2^40 - 2^0 */ fmul(t0, t0, c);
+  /* 2^40 - 2^0 */ fmulcnd(t0, t0, c);
   /* 2^50 - 2^10 */ fsquare_times(t0, t0, 10);
-  /* 2^50 - 2^0 */ fmul(b, t0, b);
+  /* 2^50 - 2^0 */ fmulcnd(b, t0, b);
   /* 2^100 - 2^50 */ fsquare_times(t0, b, 50);
-  /* 2^100 - 2^0 */ fmul(c, t0, b);
+  /* 2^100 - 2^0 */ fmulcnd(c, t0, b);
   /* 2^200 - 2^100 */ fsquare_times(t0, c, 100);
-  /* 2^200 - 2^0 */ fmul(t0, t0, c);
+  /* 2^200 - 2^0 */ fmulcnd(t0, t0, c);
   /* 2^250 - 2^50 */ fsquare_times(t0, t0, 50);
-  /* 2^250 - 2^0 */ fmul(t0, t0, b);
+  /* 2^250 - 2^0 */ fmulcnd(t0, t0, b);
   /* 2^255 - 2^5 */ fsquare_times(t0, t0, 5);
-  /* 2^255 - 21 */ fmul(out, t0, a);
+  /* 2^255 - 21 */ fmulcnd(out, t0, a);
 }
 
 int curve25519_donna(u8 *, const u8 *, const u8 *);
@@ -443,7 +443,7 @@
   fexpand(bp, basepoint);
   cmult(x, z, e, bp);
   crecip(zmone, z);
-  fmul(z, x, zmone);
+  fmulcnd(z, x, zmone);
   fcontract(mypublic, z);
   return 0;
 }

@nicomen
Copy link

nicomen commented Apr 19, 2020

I got this error now on Ubuntu 19.10 – needed to build Net::SFTP – is there some way I can help getting this fix to CPAN?

@eserte
Copy link

eserte commented Apr 19, 2020

@pyperanger : Would you like to take over the module?
@nicomen : as I wrote some comments above --- for CPAN.pm users there's a solution which works out of the box without manual patching, so maybe it's worth to switch back from cpanminus to good old CPAN.pm...

@nicomen
Copy link

nicomen commented Apr 19, 2020

@eserte Thanks, I investigated the distroprefs feature, but it sems to not be implemented in cpanminus (nor CPANPLUS), so it's not viable for our deployments, but I will do a manual patch with cpan locally.

@Tux
Copy link

Tux commented Jun 21, 2020

FWIW the posted patch works for me

Linux 5.7.1-1-default [openSUSE Tumbleweed 20200618]
This is perl 5, version 32, subversion 0 (v5.32.0) built for x86_64-linux-thread-multi-ld
gcc (SUSE Linux) 10.1.1 20200507 [revision dd38686d9c810cecbaa80bb82ed91caaa58ad635]

@duttaANI
Copy link

duttaANI commented Mar 6, 2022

same here on debian 686-pae, the conflict was in /usr/include/i386-linux-gnu/bits/mathcalls-narrow.h and renaming fmul works as well

Thanks a lot, this approach worked . The issue was resolved by opening the file mathcalls-narrow.h and removing the below line -

__MATHCALL_NARROW (__MATHCALL_NAME (mul), __MATHCALL_REDIR_NAME (mul), 2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants