diff options
author | Alyssa Ross <hi@alyssa.is> | 2019-01-07 02:18:36 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2019-01-07 02:18:47 +0000 |
commit | 36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2 (patch) | |
tree | b3faaf573407b32aa645237a4d16b82778a39a92 /nixpkgs/pkgs/development/libraries/libsnark | |
parent | 4e31070265257dc67d120c27e0f75c2344fdfa9a (diff) | |
parent | abf060725d7614bd3b9f96764262dfbc2f9c2199 (diff) | |
download | nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.gz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.bz2 nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.lz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.xz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.zst nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.zip |
Add 'nixpkgs/' from commit 'abf060725d7614bd3b9f96764262dfbc2f9c2199'
git-subtree-dir: nixpkgs git-subtree-mainline: 4e31070265257dc67d120c27e0f75c2344fdfa9a git-subtree-split: abf060725d7614bd3b9f96764262dfbc2f9c2199
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/libsnark')
-rw-r--r-- | nixpkgs/pkgs/development/libraries/libsnark/darwin-fix-clock-gettime.patch | 41 | ||||
-rw-r--r-- | nixpkgs/pkgs/development/libraries/libsnark/default.nix | 32 |
2 files changed, 73 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/libsnark/darwin-fix-clock-gettime.patch b/nixpkgs/pkgs/development/libraries/libsnark/darwin-fix-clock-gettime.patch new file mode 100644 index 000000000000..2eee84d1c4b8 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/libsnark/darwin-fix-clock-gettime.patch @@ -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 + } diff --git a/nixpkgs/pkgs/development/libraries/libsnark/default.nix b/nixpkgs/pkgs/development/libraries/libsnark/default.nix new file mode 100644 index 000000000000..4ea2209160f8 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/libsnark/default.nix @@ -0,0 +1,32 @@ +{ stdenv, fetchFromGitHub, cmake, pkgconfig, openssl, boost, gmp, procps }: + +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; + }; +} |