1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 autoreconfHook,
6 buildPackages,
7 xz,
8 testers,
9}:
10
11stdenv.mkDerivation (finalAttrs: {
12 pname = "libunwind";
13 version = "1.8.2";
14
15 src = fetchFromGitHub {
16 owner = "libunwind";
17 repo = "libunwind";
18 rev = "v${finalAttrs.version}";
19 hash = "sha256-MsUReXFHlj15SgEZHOYhdSfAbSeVVl8LCi4NnUwvhpw=";
20 };
21
22 postPatch =
23 if (stdenv.cc.isClang || stdenv.hostPlatform.isStatic) then
24 ''
25 substituteInPlace configure.ac --replace "-lgcc_s" ""
26 ''
27 else
28 lib.optionalString stdenv.hostPlatform.isMusl ''
29 substituteInPlace configure.ac --replace "-lgcc_s" "-lgcc_eh"
30 '';
31
32 nativeBuildInputs = [ autoreconfHook ];
33
34 outputs = [
35 "out"
36 "dev"
37 "devman"
38 ];
39
40 configureFlags = [
41 # Starting from 1.8.1 libunwind installs testsuite by default.
42 # As we don't run the tests we disable it (this also fixes circular
43 # reference install failure).
44 "--disable-tests"
45 # Without latex2man, no man pages are installed despite being
46 # prebuilt in the source tarball.
47 "LATEX2MAN=${buildPackages.coreutils}/bin/true"
48 ];
49
50 propagatedBuildInputs = [ xz ];
51
52 enableParallelBuilding = true;
53
54 postInstall = ''
55 find $out -name \*.la | while read file; do
56 sed -i 's,-llzma,${xz.out}/lib/liblzma.la,' $file
57 done
58 '';
59
60 doCheck = false; # fails
61
62 passthru.tests.pkg-config = testers.hasPkgConfigModules {
63 package = finalAttrs.finalPackage;
64 versionCheck = true;
65 };
66
67 meta = with lib; {
68 homepage = "https://www.nongnu.org/libunwind";
69 description = "Portable and efficient API to determine the call-chain of a program";
70 maintainers = with maintainers; [ orivej ];
71 pkgConfigModules = [
72 "libunwind"
73 "libunwind-coredump"
74 "libunwind-generic"
75 "libunwind-ptrace"
76 "libunwind-setjmp"
77 ];
78 # https://github.com/libunwind/libunwind#libunwind
79 platforms = [
80 "aarch64-linux"
81 "armv5tel-linux"
82 "armv6l-linux"
83 "armv7a-linux"
84 "armv7l-linux"
85 "i686-freebsd"
86 "i686-linux"
87 "loongarch64-linux"
88 "mips64el-linux"
89 "mipsel-linux"
90 "powerpc-linux"
91 "powerpc64-linux"
92 "powerpc64le-linux"
93 "riscv64-linux"
94 "s390x-linux"
95 "x86_64-freebsd"
96 "x86_64-linux"
97 "x86_64-solaris"
98 ];
99 license = licenses.mit;
100 };
101})