From dd62635d97eb3d9b335611196c52351cd7aa245a Mon Sep 17 00:00:00 2001 From: Pavel Borzenkov Date: Tue, 4 Oct 2022 18:33:02 +0200 Subject: [PATCH] libnfs: allow building with pthread support libnfs is not thread-safe by default. Making it thread-safe requires building it with pthread support and enabling multi-threading at runtime using nfs_mt_service_thread_start() function. The patch allows to optionally build libnfs with multi-threading support. This is not enabled by default to avoid runtime costs for programs that don't require libnfs to be thread-safe, so a separate top level package 'libnfs-pthread' is added. --- pkgs/development/libraries/libnfs/default.nix | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/libnfs/default.nix b/pkgs/development/libraries/libnfs/default.nix index cbfc06bc81c5..d9beee7933fa 100644 --- a/pkgs/development/libraries/libnfs/default.nix +++ b/pkgs/development/libraries/libnfs/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchFromGitHub, autoreconfHook }: +{ lib, stdenv, fetchFromGitHub, fetchpatch, autoreconfHook }: stdenv.mkDerivation rec { pname = "libnfs"; @@ -13,7 +13,22 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ autoreconfHook ]; - NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=tautological-compare"; + patches = [ + # Fixes 100% CPU usage in multi-threaded mode + (fetchpatch { + url = "https://github.com/sahlberg/libnfs/commit/34d6fe37e986da5b0ced86cd028a88e482537d5a.patch"; + sha256 = "sha256-i7mi+TVdkLb4MztT5Ic/Q8XBIWk9lo8v5bNjHOr6LaI="; + }) + # Fixes deprecation warnings on macOS + (fetchpatch { + url = "https://github.com/sahlberg/libnfs/commit/f6631c54a7b0385988f11357bf96728a6d7345b9.patch"; + sha256 = "sha256-xLRZ9J1vr04n//gNv9ljUBt5LHUGBRRVIXJCMlFbHFI="; + }) + ]; + + configureFlags = [ + "--enable-pthread" + ]; enableParallelBuilding = true;