1{ lib, stdenv, llvm_meta, version
2, monorepoSrc, runCommand
3, cmake
4, ninja
5, python3
6, enableShared ? !stdenv.hostPlatform.isStatic
7}:
8
9stdenv.mkDerivation rec {
10 pname = "libunwind";
11 inherit version;
12
13 # I am not so comfortable giving libc++ and friends the whole monorepo as
14 # requested, so I filter it to what is needed.
15 src = runCommand "${pname}-src-${version}" {} ''
16 mkdir -p "$out"
17 cp -r ${monorepoSrc}/cmake "$out"
18 cp -r ${monorepoSrc}/${pname} "$out"
19 mkdir -p "$out/libcxx"
20 cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
21 cp -r ${monorepoSrc}/libcxx/utils "$out/libcxx"
22 mkdir -p "$out/llvm"
23 cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
24 cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
25 cp -r ${monorepoSrc}/runtimes "$out"
26 '';
27
28 sourceRoot = "${src.name}/runtimes";
29
30 prePatch = ''
31 cd ../${pname}
32 chmod -R u+w .
33 '';
34
35 patches = [
36 ./gnu-install-dirs.patch
37 ];
38
39 postPatch = ''
40 cd ../runtimes
41 '';
42
43 outputs = [ "out" "dev" ];
44
45 nativeBuildInputs = [ cmake ninja python3 ];
46
47 cmakeFlags = [
48 "-DLLVM_ENABLE_RUNTIMES=libunwind"
49 ] ++ lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
50
51 meta = llvm_meta // {
52 # Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
53 homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
54 description = "LLVM's unwinder library";
55 longDescription = ''
56 The unwind library provides a family of _Unwind_* functions implementing
57 the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
58 I). It is a dependency of the C++ ABI library, and sometimes is a
59 dependency of other runtimes.
60 '';
61 };
62}