@@ -1,5 +1,6 @@
11{ stdenv, fetchFromGitHub, pkgconfig
22, libelf, zlib
3+, fetchpatch
34}:
45
56with builtins;
@@ -15,6 +16,21 @@ stdenv.mkDerivation rec {
1516 sha256 = "1wi3a795jq0smqg1c5ml2ghai47n1m5ijmch017wscybx4jdlynv";
1617 };
1718
19+ patches = [
20+ (fetchpatch { # included upstream for > 0.1.0
21+ name = "link-zlib.patch";
22+ url = "https://github.com/libbpf/libbpf/commit/8b14cb43ff837.diff";
23+ sha256 = "17mvjrs7s727drz013a8qlyj0345ldi2kph6pazcmxv6kl1qrz2z";
24+ })
25+ ];
26+ patchFlags = "-p2";
27+ # https://github.com/libbpf/libbpf/pull/201#issuecomment-689174740
28+ postPatch = ''
29+ substituteInPlace ../scripts/check-reallocarray.sh \
30+ --replace 'mktemp /tmp/' 'mktemp ' \
31+ --replace '/bin/rm' 'rm'
32+ '';
33+
1834 nativeBuildInputs = [ pkgconfig ];
1935 buildInputs = [ libelf zlib ];
2036
@@ -22,14 +38,6 @@ stdenv.mkDerivation rec {
2238 enableParallelBuilding = true;
2339 makeFlags = [ "PREFIX=$(out)" ];
2440
25− patchPhase = ''
26− substituteInPlace ../scripts/check-reallocarray.sh \
27− --replace '/bin/rm' 'rm'
28− # Without patching this the config-test program will be refused by our CC wrapper.
29− chmod +w ../scripts
30− sed -e '2a NIX_ENFORCE_PURITY=0' -i ../scripts/check-reallocarray.sh
31− '';
32−
3341 # FIXME: Multi-output requires some fixes to the way the pkgconfig file is
3442 # constructed (it gets put in $out instead of $dev for some reason, with
3543 # improper paths embedded). Don't enable it for now.