2021-01-15 14:45:37 +00:00
|
|
|
{ lib, stdenv, fetchurl, bash, flex, bison, valgrind }:
|
2014-04-01 06:10:28 +00:00
|
|
|
|
2014-04-09 00:21:06 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "lockdep";
|
2014-04-09 00:21:06 +00:00
|
|
|
|
2020-09-16 21:53:19 +00:00
|
|
|
# it would be nice to be able to pick a kernel version in sync with something
|
|
|
|
# else we already ship, but it seems userspace lockdep isn't very well maintained
|
|
|
|
# and appears broken in many kernel releases
|
|
|
|
version = "5.0.21";
|
|
|
|
fullver = "5.0.21";
|
2014-04-09 00:21:06 +00:00
|
|
|
src = fetchurl {
|
2020-09-16 21:53:19 +00:00
|
|
|
url = "mirror://kernel/linux/kernel/v5.x/linux-${version}.tar.xz";
|
|
|
|
sha256 = "1my2m9hvnvdrvzcg0fgqgaga59y2cd5zlpv7xrfj2nn98sjhglwq";
|
2014-04-09 00:21:06 +00:00
|
|
|
};
|
2014-04-01 06:10:28 +00:00
|
|
|
|
2020-09-16 21:53:19 +00:00
|
|
|
# ensure *this* kernel's userspace-headers are picked up before we
|
|
|
|
# fall back to those in glibc, as they will be from a mismatched
|
|
|
|
# kernel version
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace tools/lib/lockdep/Makefile \
|
|
|
|
--replace 'CONFIG_INCLUDES =' $'CONFIG_INCLUDES = -I../../../usr/include\n#'
|
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [ flex bison ];
|
|
|
|
|
2022-05-22 10:04:12 +00:00
|
|
|
# Workaround build failure on -fno-common toolchains like upstream
|
|
|
|
# gcc-10. Otherwise build fails as:
|
|
|
|
# ld: lockdep.o:/build/linux-5.0.21/tools/lib/lockdep/../../include/linux/rcu.h:5: multiple definition of
|
|
|
|
# `rcu_scheduler_active'; common.o:/build/linux-5.0.21/tools/lib/lockdep/../../include/linux/rcu.h:5: first defined here
|
2023-02-19 19:23:32 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = "-fcommon";
|
2022-05-22 10:04:12 +00:00
|
|
|
|
2020-09-16 21:53:19 +00:00
|
|
|
buildPhase = ''
|
|
|
|
make defconfig
|
|
|
|
make headers_install
|
|
|
|
cd tools/lib/lockdep
|
|
|
|
make
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
2023-01-21 12:00:00 +00:00
|
|
|
nativeCheckInputs = [ valgrind ];
|
2020-09-16 21:53:19 +00:00
|
|
|
checkPhase = ''
|
|
|
|
# there are more /bin/bash references than just shebangs
|
|
|
|
for f in lockdep run_tests.sh tests/*.sh; do
|
|
|
|
substituteInPlace $f \
|
|
|
|
--replace '/bin/bash' '${bash}/bin/bash'
|
|
|
|
done
|
|
|
|
|
|
|
|
./run_tests.sh
|
|
|
|
'';
|
|
|
|
|
2014-04-01 06:10:28 +00:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin $out/lib $out/include
|
|
|
|
|
|
|
|
cp -R include/liblockdep $out/include
|
|
|
|
make install DESTDIR=$out prefix=""
|
|
|
|
|
2014-10-09 21:56:09 +00:00
|
|
|
substituteInPlace $out/bin/lockdep --replace "./liblockdep.so" "$out/lib/liblockdep.so.$fullver"
|
2014-04-01 06:10:28 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
2016-06-20 10:53:46 +00:00
|
|
|
description = "Userspace locking validation tool built on the Linux kernel";
|
2024-03-19 02:14:51 +00:00
|
|
|
mainProgram = "lockdep";
|
2014-04-01 06:10:28 +00:00
|
|
|
homepage = "https://kernel.org/";
|
2024-05-26 12:16:07 +00:00
|
|
|
license = lib.licenses.gpl2Only;
|
2021-01-15 14:45:37 +00:00
|
|
|
platforms = lib.platforms.linux;
|
|
|
|
maintainers = [ lib.maintainers.thoughtpolice ];
|
2014-04-01 06:10:28 +00:00
|
|
|
};
|
|
|
|
}
|