1{ glibc, perl }:
2
3# Small wrapper which only exposes `mtrace(3)` from `glibc`. This can't be placed
4# into `glibc` itself because it depends on Perl which would mean that the final
5# `glibc` inside a stdenv bootstrap has a dependency `glibc -> perl -> bootstrap tools`,
6# so this is now in its own package that isn't used for bootstrapping.
7#
8# `glibc` needs to be overridden here because it's still needed to `./configure` the source in order
9# to have a build environment where we can call the needed make target.
10
11glibc.overrideAttrs (oldAttrs: {
12 pname = "glibc-mtrace";
13
14 buildPhase = ''
15 runHook preBuild
16
17 mkdir malloc
18 make -C ../glibc-${glibc.minorRelease}/malloc objdir=`pwd` `pwd`/malloc/mtrace;
19
20 runHook postBuild
21 '';
22
23 installPhase = ''
24 mkdir -p $out/bin
25 mv malloc/mtrace $out/bin/
26 '';
27
28 # Perl checked during configure
29 nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ perl ];
30 # Perl shebang used for `mtrace`.
31 buildInputs = oldAttrs.buildInputs ++ [ perl ];
32
33 # Reset a few things declared by `pkgs.glibc`.
34 outputs = [ "out" ];
35 separateDebugInfo = false;
36
37 meta = oldAttrs.meta // {
38 description = "Perl script used to interpret and provide human readable output of the trace log contained in the file mtracedata, whose contents were produced by mtrace(3)";
39 mainProgram = "mtrace";
40 };
41})