keyhunt icon indicating copy to clipboard operation
keyhunt copied to clipboard

Compile issues on M1 Mac

Open MATICtoPOL opened this issue 4 years ago • 3 comments
trafficstars

Hi @albertobsd I am using the latest version on Mac and still seeing a few errors during make - can you take a look and help? Thanks in advance.

% make
gcc -O3 -c bloom/bloom.c -o bloom.o
g++ -O3 -c sha256/sha256.c -o sha256.o
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
gcc -O3 -c base58/base58.c -o base58.o
gcc -O3 -c rmd160/rmd160.c -o rmd160.o
gcc -O3 -c sha3/sha3.c -o sha3.o
gcc -O3 -c xxhash/xxhash.c -o xxhash.o
g++ -O3 -c util.c -o util.o
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
g++ -m64 -mssse3 -Wno-unused-result -Wno-write-strings -O2 -c secp256k1/Int.cpp -o Int.o
clang: warning: argument unused during compilation: '-mssse3' [-Wunused-command-line-argument]
In file included from secp256k1/Int.cpp:18:
secp256k1/Int.h:204:27: error: invalid output constraint '=d' in asm
  __asm__( "mulq  %[b];" :"=d"(rhi),"=a"(rlo) :"1"(a),[b]"rm"(b));
                          ^
secp256k1/Int.h:211:43: error: invalid output constraint '=D' in asm
  __asm__ ("movq %1,%0;shrdq %3,%2,%0;" : "=D"(c) : "r"(a),"r"(b),"c"(n));
                                          ^
secp256k1/Int.h:218:43: error: invalid output constraint '=D' in asm
  __asm__ ("movq %1,%0;shldq %3,%2,%0;" : "=D"(c) : "r"(b),"r"(a),"c"(n));
                                          ^
secp256k1/Int.h:234:7: error: use of undeclared identifier '__builtin_ia32_addcarryx_u64'
  c = _addcarry_u64(c, _umul128(x[1], y, &h), carry, dst + 1); carry = h;
      ^
secp256k1/Int.h:223:32: note: expanded from macro '_addcarry_u64'
#define _addcarry_u64(a,b,c,d) __builtin_ia32_addcarryx_u64(a,b,c,(long long unsigned int*)d);
                               ^
secp256k1/Int.h:235:7: error: use of undeclared identifier '__builtin_ia32_addcarryx_u64'
  c = _addcarry_u64(c, _umul128(x[2], y, &h), carry, dst + 2); carry = h;
      ^
secp256k1/Int.h:223:32: note: expanded from macro '_addcarry_u64'
#define _addcarry_u64(a,b,c,d) __builtin_ia32_addcarryx_u64(a,b,c,(long long unsigned int*)d);
                               ^
secp256k1/Int.h:236:7: error: use of undeclared identifier '__builtin_ia32_addcarryx_u64'
  c = _addcarry_u64(c, _umul128(x[3], y, &h), carry, dst + 3); carry = h;
      ^
secp256k1/Int.h:223:32: note: expanded from macro '_addcarry_u64'
#define _addcarry_u64(a,b,c,d) __builtin_ia32_addcarryx_u64(a,b,c,(long long unsigned int*)d);
                               ^
secp256k1/Int.h:237:7: error: use of undeclared identifier '__builtin_ia32_addcarryx_u64'
  c = _addcarry_u64(c, _umul128(x[4], y, &h), carry, dst + 4); carry = h;
      ^
secp256k1/Int.h:223:32: note: expanded from macro '_addcarry_u64'
#define _addcarry_u64(a,b,c,d) __builtin_ia32_addcarryx_u64(a,b,c,(long long unsigned int*)d);
                               ^
secp256k1/Int.h:253:7: error: use of undeclared identifier '__builtin_ia32_addcarryx_u64'
  c = _addcarry_u64(c, _umul128(x[1], y, &h), carry, dst + 1); carry = h;
      ^
secp256k1/Int.h:223:32: note: expanded from macro '_addcarry_u64'
#define _addcarry_u64(a,b,c,d) __builtin_ia32_addcarryx_u64(a,b,c,(long long unsigned int*)d);
                               ^
secp256k1/Int.h:254:7: error: use of undeclared identifier '__builtin_ia32_addcarryx_u64'
  c = _addcarry_u64(c, _umul128(x[2], y, &h), carry, dst + 2); carry = h;
      ^
secp256k1/Int.h:223:32: note: expanded from macro '_addcarry_u64'
#define _addcarry_u64(a,b,c,d) __builtin_ia32_addcarryx_u64(a,b,c,(long long unsigned int*)d);
                               ^
secp256k1/Int.h:255:7: error: use of undeclared identifier '__builtin_ia32_addcarryx_u64'
  c = _addcarry_u64(c, _umul128(x[3], y, &h), carry, dst + 3); carry = h;
      ^
secp256k1/Int.h:223:32: note: expanded from macro '_addcarry_u64'
#define _addcarry_u64(a,b,c,d) __builtin_ia32_addcarryx_u64(a,b,c,(long long unsigned int*)d);
                               ^
secp256k1/Int.h:262:3: error: use of undeclared identifier '__builtin_ia32_addcarryx_u64'
  _addcarry_u64(c, 0ULL, carry, dst + (NB64BLOCK - 1));
  ^
secp256k1/Int.h:223:32: note: expanded from macro '_addcarry_u64'
#define _addcarry_u64(a,b,c,d) __builtin_ia32_addcarryx_u64(a,b,c,(long long unsigned int*)d);
                               ^
In file included from secp256k1/Int.cpp:24:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/emmintrin.h:13:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/xmmintrin.h:13:
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:33:5: error: use of undeclared identifier '__builtin_ia32_emms'; did you mean '__builtin_isless'?
    __builtin_ia32_emms();
    ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:33:5: note: '__builtin_isless' declared here
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:33:25: error: too few arguments to function call, expected 2, have 0
    __builtin_ia32_emms();
                        ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:50:19: error: use of undeclared identifier '__builtin_ia32_vec_init_v2si'
    return (__m64)__builtin_ia32_vec_init_v2si(__i, 0);
                  ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:67:12: error: use of undeclared identifier '__builtin_ia32_vec_ext_v2si'
    return __builtin_ia32_vec_ext_v2si((__v2si)__m, 0);
           ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:129:19: error: use of undeclared identifier '__builtin_ia32_packsswb'
    return (__m64)__builtin_ia32_packsswb((__v4hi)__m1, (__v4hi)__m2);
                  ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:159:19: error: use of undeclared identifier '__builtin_ia32_packssdw'
    return (__m64)__builtin_ia32_packssdw((__v2si)__m1, (__v2si)__m2);
                  ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:189:19: error: use of undeclared identifier '__builtin_ia32_packuswb'
    return (__m64)__builtin_ia32_packuswb((__v4hi)__m1, (__v4hi)__m2);
                  ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.5/include/mmintrin.h:216:19: error: use of undeclared identifier '__builtin_ia32_punpckhbw'
    return (__m64)__builtin_ia32_punpckhbw((__v8qi)__m1, (__v8qi)__m2);
                  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [default] Error 1

I also added the line as you suggested above:

default:
	gcc -O3 -c bloom/bloom.c -o bloom.o
	g++ -O3 -c sha256/sha256.c -o sha256.o
	gcc -O3 -c base58/base58.c -o base58.o
	gcc -O3 -c rmd160/rmd160.c -o rmd160.o
	gcc -O3 -c sha3/sha3.c -o sha3.o
	gcc -O3 -c xxhash/xxhash.c -o xxhash.o
	g++ -O3 -c util.c -o util.o
	gcc -O3 -c keyhunt.c -o keyhunt.o -lm -I/opt/homebrew/Cellar/gmp/6.2.1/include/ -L/opt/homebrew/Cellar/gmp/6.2.1/lib/
	g++ -m64 -mssse3 -Wno-unused-result -Wno-write-strings -O2 -c secp256k1/Int.cpp -o Int.o
	g++ -m64 -mssse3 -Wno-unused-result -Wno-write-strings -O2 -c secp256k1/Point.cpp -o Point.o
	g++ -m64 -mssse3 -Wno-unused-result -Wno-write-strings -O2 -c secp256k1/SECP256K1.cpp -o SECP256K1.o
	g++ -m64 -mssse3 -Wno-unused-result -Wno-write-strings -O2 -c secp256k1/IntMod.cpp -o IntMod.o
	g++ -m64 -mssse3 -Wno-unused-result -Wno-write-strings -O2 -c secp256k1/Random.cpp -o Random.o
	g++ -m64 -mssse3 -Wno-unused-result -Wno-write-strings -O2 -c secp256k1/IntGroup.cpp -o IntGroup.o
	g++ -o keyhunt keyhunt.c base58.o rmd160.o sha256.o bloom.o xxhash.o util.o Int.o  Point.o SECP256K1.o  IntMod.o  Random.o IntGroup.o -lgmp -lm -lpthread
	#gcc -O3 hexcharstoraw.c -o hexcharstoraw util.o -lm
	g++ -o bPfile bPfile.c util.o -lgmp -lm
clean:
	rm -r *.o

MATICtoPOL avatar Jul 02 '21 10:07 MATICtoPOL

ARM-based system not supported

we-akri avatar Jul 03 '21 13:07 we-akri

For that processor you only can use the libgmp version but that is some outdated to use that you need to do a checkout to a previous version:

git checkout 05482850ed246ce759c77db948dda28f8c570eb9

And the try to make it again.

Regards!

albertobsd avatar Oct 04 '21 15:10 albertobsd

Thanks, i tried this but still getting one error:

keyhunt.c:9:10: fatal error: 'gmp.h' file not found
#include <gmp.h>
         ^~~~~~~
1 error generated.

also,

keyhunt % brew install gmp                                     
Warning: gmp 6.2.1_1 is already installed and up-to-date.

I read in another thread that you are working on a GMP version for mac only - would love to test it out when it is ready, thanks!

MATICtoPOL avatar Nov 18 '21 19:11 MATICtoPOL

maybe the package that you need is gmp-dev or libgmp-dev

By the way i just update the code to compile it with ARM processors

try to compile it with

make legacy

albertobsd avatar May 17 '23 03:05 albertobsd