at 24.05-pre 1.9 kB view raw
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 postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) '' 44 # libcxxabi wants to link to libunwind_shared.so (?). 45 ln -s $out/lib/libunwind.so $out/lib/libunwind_shared.so 46 ''; 47 48 outputs = [ "out" "dev" ]; 49 50 nativeBuildInputs = [ cmake ninja python3 ]; 51 52 cmakeFlags = [ 53 "-DLLVM_ENABLE_RUNTIMES=libunwind" 54 ] ++ lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF"; 55 56 meta = llvm_meta // { 57 # Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst 58 homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library"; 59 description = "LLVM's unwinder library"; 60 longDescription = '' 61 The unwind library provides a family of _Unwind_* functions implementing 62 the language-neutral stack unwinding portion of the Itanium C++ ABI (Level 63 I). It is a dependency of the C++ ABI library, and sometimes is a 64 dependency of other runtimes. 65 ''; 66 }; 67}