about summary refs log tree commit diff
path: root/pkgs/tools/compression/zstd
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2019-11-12 20:49:47 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2019-11-15 23:21:47 +0000
commitca764362981931a128c9ec5cb37c8327f134dbbf (patch)
treea1e846984b5f383b349e3e5d4fe9cf8ec94b1486 /pkgs/tools/compression/zstd
parent774e88cd86c2682f2482ee7a611c8cde517df803 (diff)
downloadnixlib-ca764362981931a128c9ec5cb37c8327f134dbbf.tar
nixlib-ca764362981931a128c9ec5cb37c8327f134dbbf.tar.gz
nixlib-ca764362981931a128c9ec5cb37c8327f134dbbf.tar.bz2
nixlib-ca764362981931a128c9ec5cb37c8327f134dbbf.tar.lz
nixlib-ca764362981931a128c9ec5cb37c8327f134dbbf.tar.xz
nixlib-ca764362981931a128c9ec5cb37c8327f134dbbf.tar.zst
nixlib-ca764362981931a128c9ec5cb37c8327f134dbbf.zip
zstd: Fix MinGW build
Diffstat (limited to 'pkgs/tools/compression/zstd')
-rw-r--r--pkgs/tools/compression/zstd/default.nix30
-rw-r--r--pkgs/tools/compression/zstd/mcfgthreads-no-pthread.patch13
2 files changed, 39 insertions, 4 deletions
diff --git a/pkgs/tools/compression/zstd/default.nix b/pkgs/tools/compression/zstd/default.nix
index 5a153393ccdb..8230d6ea3647 100644
--- a/pkgs/tools/compression/zstd/default.nix
+++ b/pkgs/tools/compression/zstd/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, gnugrep
+{ stdenv, fetchFromGitHub, fetchpatch, gnugrep
 , fixDarwinDylibNames
 , file
 , legacySupport ? false }:
@@ -14,11 +14,33 @@ stdenv.mkDerivation rec {
     owner = "facebook";
   };
 
-  buildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
+  patches = [
+    # All 3 from https://github.com/facebook/zstd/pull/1883
+    (fetchpatch {
+      url = "https://github.com/facebook/zstd/commit/106278e7e5fafaea3b7deb4147bdc8071562d2f0.diff";
+      sha256 = "13z7id1qbc05cv1rmak7c8xrchp7jh1i623bq5pwcihg57wzcyr8";
+    })
+    (fetchpatch {
+      url = "https://github.com/facebook/zstd/commit/0ede342acc2c26f87ae962fa88e158904d4198c4.diff";
+      sha256 = "12l5xbvnzkvr76mvl1ls767paqfwbd9q1pzq44ckacfpz4f6iaap";
+      excludes = [
+        # I think line endings are causing problems, or something like that
+        "programs/windres/generate_res.bat"
+      ];
+    })
+    (fetchpatch {
+      url = "https://github.com/facebook/zstd/commit/10552eaffef84c011f67af0e04f0780b50a5ab26.diff";
+      sha256 = "1s27ravar3rn7q8abybp9733jhpsfcaci51k04da94ahahvxwiqw";
+    })
+  ] # This I didn't upstream because if you use posix threads with MinGW it will
+    # work find, and I'm not sure how to write the condition.
+    ++ stdenv.lib.optional stdenv.hostPlatform.isWindows ./mcfgthreads-no-pthread.patch;
+
+  nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
   makeFlags = [
     "ZSTD_LEGACY_SUPPORT=${if legacySupport then "1" else "0"}"
-  ];
+  ] ++ stdenv.lib.optional stdenv.hostPlatform.isWindows "OS=Windows";
 
   checkInputs = [ file ];
   doCheck = true;
@@ -56,7 +78,7 @@ stdenv.mkDerivation rec {
     homepage = https://facebook.github.io/zstd/;
     license = with licenses; [ bsd3 ]; # Or, at your opinion, GPL-2.0-only.
 
-    platforms = platforms.unix;
+    platforms = platforms.all;
     maintainers = with maintainers; [ orivej ];
   };
 }
diff --git a/pkgs/tools/compression/zstd/mcfgthreads-no-pthread.patch b/pkgs/tools/compression/zstd/mcfgthreads-no-pthread.patch
new file mode 100644
index 000000000000..69921c0c7bad
--- /dev/null
+++ b/pkgs/tools/compression/zstd/mcfgthreads-no-pthread.patch
@@ -0,0 +1,13 @@
+diff --git a/programs/Makefile b/programs/Makefile
+index 7882fe8c..1e8237bb 100644
+--- a/programs/Makefile
++++ b/programs/Makefile
+@@ -107,7 +107,7 @@ HAVE_THREAD := $(shell [ "$(HAVE_PTHREAD)" -eq "1" -o -n "$(filter Windows%,$(OS
+ ifeq ($(HAVE_THREAD), 1)
+ THREAD_MSG := ==> building with threading support
+ THREAD_CPP := -DZSTD_MULTITHREAD
+-THREAD_LD := -pthread
++THREAD_LD :=
+ else
+ THREAD_MSG := $(NO_THREAD_MSG)
+ endif