nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv, llvm_meta
2, fetch
3, cmake
4, zlib
5, ncurses
6, swig
7, which
8, libedit
9, libxml2
10, libllvm
11, libclang
12, perl
13, python3
14, version
15, darwin
16}:
17
18stdenv.mkDerivation rec {
19 pname = "lldb";
20 inherit version;
21
22 src = fetch "lldb" "0klsscg1sczc4nw2l53xggi969k361cng2sjjrfp3bv4g5x14s4v";
23
24 patches = [
25 ./gnu-install-dirs.patch
26 ];
27
28 postPatch = ''
29 # Fix up various paths that assume llvm and clang are installed in the same place
30 sed -i 's,".*ClangConfig.cmake","${libclang.dev}/lib/cmake/clang/ClangConfig.cmake",' \
31 cmake/modules/LLDBStandalone.cmake
32 sed -i 's,".*tools/clang/include","${libclang.dev}/include",' \
33 cmake/modules/LLDBStandalone.cmake
34 sed -i 's,"$.LLVM_LIBRARY_DIR.",${libllvm.lib}/lib ${libclang.lib}/lib,' \
35 cmake/modules/LLDBStandalone.cmake
36 sed -i -e 's,message(SEND_ERROR "Cannot find debugserver on system."),,' \
37 -e 's,string(STRIP ''${XCODE_DEV_DIR} XCODE_DEV_DIR),,' \
38 tools/debugserver/source/CMakeLists.txt
39
40 # Fix /usr/bin references for sandboxed builds.
41 patchShebangs scripts
42 '';
43
44 outputs = [ "out" "lib" "dev" ];
45
46 nativeBuildInputs = [
47 cmake perl python3 which swig
48 ];
49
50 buildInputs = [
51 ncurses zlib libedit libxml2 libllvm
52 ] ++ lib.optionals stdenv.isDarwin [
53 darwin.libobjc
54 darwin.apple_sdk.libs.xpc
55 darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa
56 ];
57
58 CXXFLAGS = "-fno-rtti";
59 hardeningDisable = [ "format" ];
60
61 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-I${libxml2.dev}/include/libxml2";
62
63 cmakeFlags = [
64 "-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}"
65 "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
66 "-DSKIP_DEBUGSERVER=ON"
67 ] ++ lib.optionals doCheck [
68 "-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
69 "-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"
70 ];
71
72 doCheck = false;
73
74 postInstall = ''
75 mkdir -p $out/share/man/man1
76 cp ../docs/lldb.1 $out/share/man/man1/
77 '';
78
79 meta = llvm_meta // {
80 homepage = "https://lldb.llvm.org/";
81 description = "A next-generation high-performance debugger";
82 longDescription = ''
83 LLDB is a next generation, high-performance debugger. It is built as a set
84 of reusable components which highly leverage existing libraries in the
85 larger LLVM Project, such as the Clang expression parser and LLVM
86 disassembler.
87 '';
88 # never built on aarch64-darwin since first introduction in nixpkgs
89 broken = stdenv.isDarwin && stdenv.isAarch64;
90 };
91}