Skip to content

Commit

Permalink
Problem: zstd build fail for mingw64 cross-compiling (#948)
Browse files Browse the repository at this point in the history
* Problem: zstd build fail for mingw64 corss-compiling

Solution:
- apply the fix based on zstd nix expression in release-22.11

* nix fmt
  • Loading branch information
yihuang committed Apr 28, 2023
1 parent 04346d0 commit fcfc3d3
Showing 1 changed file with 15 additions and 24 deletions.
39 changes: 15 additions & 24 deletions nix/zstd.nix
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
{ lib, stdenv, fetchFromGitHub, cmake, bash, gnugrep
{ lib
, stdenv
, fetchFromGitHub
, cmake
, bash
, gnugrep
, fixDarwinDylibNames
, file
, fetchpatch
, legacySupport ? false
, static ? stdenv.hostPlatform.isStatic
# these need to be ran on the host, thus disable when cross-compiling
# these need to be ran on the host, thus disable when cross-compiling
, buildContrib ? stdenv.hostPlatform == stdenv.buildPlatform
, doCheck ? stdenv.hostPlatform == stdenv.buildPlatform
, nix-update-script

# for passthru.tests
, libarchive
, rocksdb
, arrow-cpp
, libzip
, curl
, python3Packages
, haskellPackages
}:

stdenv.mkDerivation rec {
pname = "zstd";
version = "1.5.5";
version = "1.5.2";

src = fetchFromGitHub {
owner = "facebook";
repo = "zstd";
rev = "v${version}";
sha256 = "sha256-tHHHIsQU7vJySrVhJuMKUSq11MzkmC+Pcsj00uFJdnQ=";
sha256 = "sha256-yJvhcysxcbUGuDOqe/TQ3Y5xyM2AUw6r1THSHOqmUy0=";
};

nativeBuildInputs = [ cmake ]
++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
buildInputs = lib.optional stdenv.hostPlatform.isUnix bash;

patches = [
Expand All @@ -53,7 +49,8 @@ stdenv.mkDerivation rec {
LDFLAGS = lib.optionalString stdenv.hostPlatform.isRiscV "-latomic";

cmakeFlags = lib.attrsets.mapAttrsToList
(name: value: "-DZSTD_${name}:BOOL=${if value then "ON" else "OFF"}") {
(name: value: "-DZSTD_${name}:BOOL=${if value then "ON" else "OFF"}")
{
BUILD_SHARED = !static;
BUILD_STATIC = static;
BUILD_CONTRIB = buildContrib;
Expand All @@ -68,7 +65,7 @@ stdenv.mkDerivation rec {
mkdir -p build_ && cd $_
'';

nativeCheckInputs = [ file ];
checkInputs = [ file ];
inherit doCheck;
checkPhase = ''
runHook preCheck
Expand Down Expand Up @@ -99,14 +96,8 @@ stdenv.mkDerivation rec {
++ [ "out" ];

passthru = {
updateScript = nix-update-script { };
tests = {
inherit libarchive rocksdb arrow-cpp;
libzip = libzip.override { withZstd = true; };
curl = curl.override { zstdSupport = true; };
python-zstd = python3Packages.zstd;
haskell-zstd = haskellPackages.zstd;
haskell-hs-zstd = haskellPackages.hs-zstd;
updateScript = nix-update-script {
attrPath = pname;
};
};

Expand Down

0 comments on commit fcfc3d3

Please sign in to comment.