diff --git a/pkgs/development/tools/misc/ccache/default.nix b/pkgs/development/tools/misc/ccache/default.nix index d87de2e648ab..3d1c21c25baf 100644 --- a/pkgs/development/tools/misc/ccache/default.nix +++ b/pkgs/development/tools/misc/ccache/default.nix @@ -1,23 +1,64 @@ -{ stdenv, fetchFromGitHub, asciidoc-full, gperf, perl, autoreconfHook, zlib, makeWrapper }: +{ lib +, stdenv +, fetchFromGitHub +, fetchpatch +, substituteAll +, binutils +, asciidoc +, cmake +, perl +, zstd +, xcodebuild +, makeWrapper +}: let ccache = stdenv.mkDerivation rec { pname = "ccache"; - version = "3.7.12"; + version = "4.0"; src = fetchFromGitHub { - owner = "ccache"; - repo = "ccache"; + owner = pname; + repo = pname; rev = "v${version}"; - sha256 = "1xnv4g4n1jk1i98sa53k8w6q7hbwbw62svs30lssppysbrv8x3gz"; + sha256 = "1frcplrv61m2iwc6jwycpbcz1101xl6s4sh8p87prdj98l60lyrx"; }; - nativeBuildInputs = [ asciidoc-full autoreconfHook gperf perl ]; + # TODO: Remove patches from upstream in next release + patches = [ + # Fix badly named man page filename + (fetchpatch { + url = "https://github.com/ccache/ccache/commit/223e706fb24ce86eb0ad86079a97e6f345b9ef40.patch"; + sha256 = "1h7amp3ka45a79zwlxh8qnzx6n371gnfpfgijcqljps7skhl5gjg"; + }) + # Build and install man page by default + (fetchpatch { + url = "https://github.com/ccache/ccache/commit/294ff2face26448afa68e3ef7b68bf4898d6dc77.patch"; + sha256 = "0rx69qn41bgksc4m3p59nk5d6rz72rwnfska9mh5j62pzfm8axja"; + }) + # Fixes use of undeclared identifier 'CLONE_NOOWNERCOPY' on darwin + (fetchpatch { + url = "https://github.com/ccache/ccache/commit/411c010c3a5ee690cd42b23ffcf026ae009e2897.patch"; + sha256 = "062s424d0d0psp6wjhmfnfn1s5dsrz403hdid5drm6l2san0jhq0"; + }) + ] ++ lib.optional stdenv.isDarwin (substituteAll { + src = ./force-objdump-on-darwin.patch; + objdump = "${binutils.bintools}/bin/objdump"; + }); - buildInputs = [ zlib ]; + nativeBuildInputs = [ asciidoc cmake perl ]; + + buildInputs = [ zstd ]; outputs = [ "out" "man" ]; - doCheck = !stdenv.isDarwin; + doCheck = true; + checkInputs = lib.optional stdenv.isDarwin xcodebuild; + checkPhase = '' + export HOME=$(mktemp -d) + ctest --output-on-failure ${lib.optionalString stdenv.isDarwin '' + -E '^(test.nocpp2|test.modules)$' + ''} + ''; passthru = { # A derivation that provides gcc and g++ commands, but that @@ -63,9 +104,10 @@ let ccache = stdenv.mkDerivation rec { meta = with stdenv.lib; { description = "Compiler cache for fast recompilation of C/C++ code"; - homepage = "https://ccache.dev/"; + homepage = "https://ccache.dev"; downloadPage = "https://ccache.dev/download.html"; license = licenses.gpl3Plus; + maintainers = with maintainers; [ metadark r-burns ]; platforms = platforms.unix; }; }; diff --git a/pkgs/development/tools/misc/ccache/force-objdump-on-darwin.patch b/pkgs/development/tools/misc/ccache/force-objdump-on-darwin.patch new file mode 100644 index 000000000000..81a4f27ab736 --- /dev/null +++ b/pkgs/development/tools/misc/ccache/force-objdump-on-darwin.patch @@ -0,0 +1,31 @@ +diff --git a/test/run b/test/run +index 9623e49d..3df1c5a8 100755 +--- a/test/run ++++ b/test/run +@@ -126,23 +126,17 @@ file_size() { + objdump_cmd() { + local file="$1" + +- if $HOST_OS_APPLE; then +- xcrun dwarfdump -r 0 "$file" +- elif $HOST_OS_WINDOWS || $HOST_OS_CYGWIN; then ++ if $HOST_OS_WINDOWS || $HOST_OS_CYGWIN; then + # For some reason objdump only shows the basename of the file, so fall + # back to brute force and ignorance. + strings "$1" + else +- objdump -W "$file" ++ @objdump@ -W "$file" + fi + } + + objdump_grep_cmd() { +- if $HOST_OS_APPLE; then +- fgrep -q "\"$1\"" +- else +- fgrep -q ": $1" +- fi ++ fgrep -q ": $1" + } + + expect_stat() { diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 45bff7bd1890..ad9d4c43f9c7 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10972,7 +10972,9 @@ in cc-tool = callPackage ../development/tools/misc/cc-tool { }; - ccache = callPackage ../development/tools/misc/ccache { }; + ccache = callPackage ../development/tools/misc/ccache { + asciidoc = asciidoc-full; + }; # Wrapper that works as gcc or g++ # It can be used by setting in nixpkgs config like this, for example: @@ -10994,12 +10996,25 @@ in # }; # You can use a different directory, but whichever directory you choose # should be owned by user root, group nixbld with permissions 0770. - ccacheWrapper = makeOverridable ({ extraConfig ? "", cc ? stdenv.cc }: - cc.override { cc = ccache.links { + ccacheWrapper = makeOverridable ({ extraConfig, cc }: + cc.override { + cc = ccache.links { + inherit extraConfig; + unwrappedCC = cc.cc; + }; + }) { + extraConfig = ""; + inherit (stdenv) cc; + }; + + ccacheStdenv = lowPrio (makeOverridable ({ extraConfig, stdenv }: + overrideCC stdenv (buildPackages.ccacheWrapper.override { inherit extraConfig; - unwrappedCC = cc.cc; - }; }) {}; - ccacheStdenv = lowPrio (overrideCC stdenv buildPackages.ccacheWrapper); + inherit (stdenv) cc; + })) { + extraConfig = ""; + inherit stdenv; + }); cccc = callPackage ../development/tools/analysis/cccc { };