nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv, llvm_meta, version, fetch, fetchpatch, cmake, llvm
2, enableShared ? !stdenv.hostPlatform.isStatic
3}:
4
5stdenv.mkDerivation rec {
6 pname = "libunwind";
7 inherit version;
8
9 src = fetch pname "035dsxs10nyiqd00q07yycvmkjl01yz4jdlrjvmch8klxg4pyjhp";
10
11 postUnpack = ''
12 unpackFile ${llvm.src}
13 cmakeFlagsArray=($cmakeFlagsArray -DLLVM_PATH=$PWD/$(ls -d llvm-*))
14 '';
15
16 patches = [
17 ./gnu-install-dirs.patch
18 ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
19 # removes use of `new` that require libc++
20 (fetchpatch {
21 url = "https://github.com/llvm-mirror/libunwind/commit/34a45c630d4c79af403661d267db42fbe7de1178.patch";
22 sha256 = "0n0pv6jvcky8pn3srhrf9x5kbnd0d2kia9xlx2g590f5q0bgwfhv";
23 })
24 # cleans up remaining libc++ dependencies (mostly header inclusions)
25 (fetchpatch {
26 url = "https://github.com/llvm-mirror/libunwind/commit/e050272d2eb57eb4e56a37b429a61df2ebb8aa3e.patch";
27 sha256 = "170mwmj0wf40iyk1kzdpaiy36rz9n8dpl881h4h7s5da0rh51xya";
28 includes = [ "src/libunwind.cpp" "src/UnwindCursor.hpp" ];
29 })
30 ];
31
32 outputs = [ "out" "dev" ];
33
34 nativeBuildInputs = [ cmake ];
35
36 cmakeFlags = lib.optionals (!enableShared) [
37 "-DLIBUNWIND_ENABLE_SHARED=OFF"
38 ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
39 "-DLLVM_ENABLE_LIBCXX=ON"
40 ];
41
42 meta = llvm_meta // {
43 # Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
44 homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
45 description = "LLVM's unwinder library";
46 longDescription = ''
47 The unwind library provides a family of _Unwind_* functions implementing
48 the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
49 I). It is a dependency of the C++ ABI library, and sometimes is a
50 dependency of other runtimes.
51 '';
52 };
53}