about summary refs log tree commit diff
path: root/pkgs/development/tools/misc/sysbench/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/tools/misc/sysbench/default.nix')
-rw-r--r--pkgs/development/tools/misc/sysbench/default.nix24
1 files changed, 21 insertions, 3 deletions
diff --git a/pkgs/development/tools/misc/sysbench/default.nix b/pkgs/development/tools/misc/sysbench/default.nix
index 6bba1ebfd6118..fa39c310a269f 100644
--- a/pkgs/development/tools/misc/sysbench/default.nix
+++ b/pkgs/development/tools/misc/sysbench/default.nix
@@ -5,7 +5,6 @@
 , pkg-config
 , libmysqlclient
 , libaio
-, libck
 , luajit
 # For testing:
 , testers
@@ -17,7 +16,7 @@ stdenv.mkDerivation rec {
   version = "1.0.20";
 
   nativeBuildInputs = [ autoreconfHook pkg-config ];
-  buildInputs = [ libmysqlclient luajit libck ] ++ lib.optionals stdenv.isLinux [ libaio ];
+  buildInputs = [ libmysqlclient luajit ] ++ lib.optionals stdenv.isLinux [ libaio ];
   depsBuildBuild = [ pkg-config ];
 
   src = fetchFromGitHub {
@@ -33,11 +32,30 @@ stdenv.mkDerivation rec {
     # The bundled version does not build on aarch64-darwin:
     # https://github.com/akopytov/sysbench/issues/416
     "--with-system-luajit"
-    "--with-system-ck"
     "--with-mysql-includes=${lib.getDev libmysqlclient}/include/mysql"
     "--with-mysql-libs=${libmysqlclient}/lib/mysql"
   ];
 
+  # We cannot use the regular nixpkgs ck here, since it has very
+  # different performance characteristics than the vendored one.
+  # On the downside the vendored libck version require more fixes for cross-compilation.
+  # Sysbench related on statically linked vendored libck.
+  postPatch = ''
+    substituteInPlace \
+      third_party/concurrency_kit/ck/configure \
+        --replace-fail \
+          'COMPILER=`./.1 2> /dev/null`' \
+          "COMPILER=${if stdenv.cc.isGNU then "gcc" else if stdenv.cc.isClang then "clang" else throw "Unsupported compiler"}" \
+        --replace-fail \
+          'PLATFORM=`uname -m 2> /dev/null`' \
+          "PLATFORM=${stdenv.hostPlatform.parsed.cpu.name}"
+    substituteInPlace \
+      third_party/concurrency_kit/ck/src/Makefile.in \
+        --replace-fail \
+          "ar rcs" \
+          "${stdenv.cc.targetPrefix}ar rcs"
+  '';
+
   passthru.tests = {
     versionTest = testers.testVersion {
       package = sysbench;