libsnark: init at 9e6b19ff
This commit is contained in:
parent
db56407a97
commit
b81c65ce0a
3 changed files with 75 additions and 0 deletions
|
@ -0,0 +1,41 @@
|
|||
Adapted from https://github.com/zcash/libsnark/pull/10
|
||||
|
||||
diff --git a/depends/libff/libff/common/profiling.cpp b/depends/libff/libff/common/profiling.cpp
|
||||
index f2a1985..319149c 100755
|
||||
--- a/depends/libff/libff/common/profiling.cpp
|
||||
+++ b/depends/libff/libff/common/profiling.cpp
|
||||
@@ -27,6 +27,13 @@
|
||||
#include <proc/readproc.h>
|
||||
#endif
|
||||
|
||||
+#ifdef __MACH__
|
||||
+#include <time.h>
|
||||
+#include <sys/time.h>
|
||||
+#include <mach/clock.h>
|
||||
+#include <mach/mach.h>
|
||||
+#endif
|
||||
+
|
||||
namespace libff {
|
||||
|
||||
long long get_nsec_time()
|
||||
@@ -42,10 +49,20 @@ long long get_nsec_cpu_time()
|
||||
return 0;
|
||||
#else
|
||||
::timespec ts;
|
||||
+#ifdef __MACH__
|
||||
+ clock_serv_t cclock;
|
||||
+ mach_timespec_t mts;
|
||||
+ host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
||||
+ clock_get_time(cclock, &mts);
|
||||
+ mach_port_deallocate(mach_task_self(), cclock);
|
||||
+ ts.tv_sec = mts.tv_sec;
|
||||
+ ts.tv_nsec = mts.tv_nsec;
|
||||
+#else
|
||||
if ( ::clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) )
|
||||
throw ::std::runtime_error("clock_gettime(CLOCK_PROCESS_CPUTIME_ID) failed");
|
||||
// If we expected this to work, don't silently ignore failures, because that would hide the problem and incur an unnecessarily system-call overhead. So if we ever observe this exception, we should probably add a suitable #ifdef .
|
||||
//TODO: clock_gettime(CLOCK_PROCESS_CPUTIME_ID) is not supported by native Windows. What about Cygwin? Should we #ifdef on CLOCK_PROCESS_CPUTIME_ID or on __linux__?
|
||||
+#endif
|
||||
return ts.tv_sec * 1000000000ll + ts.tv_nsec;
|
||||
#endif
|
||||
}
|
32
pkgs/development/libraries/libsnark/default.nix
Normal file
32
pkgs/development/libraries/libsnark/default.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
{ stdenv, fetchFromGitHub, cmake, pkgconfig, openssl, boost, gmp, procps, fetchpatch, patchutils }:
|
||||
|
||||
let
|
||||
rev = "9e6b19ff15bc19fba5da1707ba18e7f160e5ed07";
|
||||
inherit (stdenv) lib;
|
||||
in stdenv.mkDerivation rec {
|
||||
name = "libsnark-pre${version}";
|
||||
version = stdenv.lib.substring 0 8 rev;
|
||||
|
||||
buildInputs = [ cmake pkgconfig openssl boost gmp ] ++ lib.optional stdenv.hostPlatform.isLinux procps;
|
||||
|
||||
cmakeFlags = lib.optionals stdenv.hostPlatform.isDarwin [ "-DWITH_PROCPS=OFF" "-DWITH_SUPERCOP=OFF" ];
|
||||
|
||||
src = fetchFromGitHub {
|
||||
inherit rev;
|
||||
owner = "scipr-lab";
|
||||
repo = "libsnark";
|
||||
sha256 = "13f02qp2fmfhvxlp4xi69m0l8r5nq913l2f0zwdk7hl46lprfdca";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
patches = [ ./darwin-fix-clock-gettime.patch ];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "C++ library for zkSNARKs";
|
||||
homepage = https://github.com/scipr-lab/libsnark;
|
||||
license = licenses.mit;
|
||||
platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
|
||||
};
|
||||
}
|
|
@ -9869,6 +9869,8 @@ with pkgs;
|
|||
inherit (darwin.apple_sdk.frameworks) Carbon AudioToolbox;
|
||||
};
|
||||
|
||||
libsnark = callPackage ../development/libraries/libsnark { };
|
||||
|
||||
libsodium = callPackage ../development/libraries/libsodium { };
|
||||
|
||||
libsoup = callPackage ../development/libraries/libsoup { };
|
||||
|
|
Loading…
Reference in a new issue