nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv, llvm_meta
2, runCommand
3, src
4, cmake
5, zlib
6, ncurses
7, swig
8, which
9, libedit
10, libxml2
11, libllvm
12, libclang
13, python3
14, version
15, libobjc
16, xpc
17, Foundation
18, bootstrap_cmds
19, Carbon
20, Cocoa
21, lit
22, makeWrapper
23, darwin
24, enableManpages ? false
25}:
26
27stdenv.mkDerivation (rec {
28 pname = "lldb";
29 inherit version;
30
31 inherit src;
32 sourceRoot = "source/${pname}";
33
34 patches = [
35 ./procfs.patch
36 (runCommand "resource-dir.patch" {
37 clangLibDir = "${libclang.lib}/lib";
38 } ''
39 substitute '${./resource-dir.patch}' "$out" --subst-var clangLibDir
40 '')
41 ./gnu-install-dirs.patch
42 ]
43 # This is a stopgap solution if/until the macOS SDK used for x86_64 is
44 # updated.
45 #
46 # The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h`
47 # header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use
48 # of this preprocessor symbol in `lldb` with its expansion.
49 #
50 # See here for some context:
51 # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
52 ++ lib.optional (
53 stdenv.targetPlatform.isDarwin
54 && !stdenv.targetPlatform.isAarch64
55 && (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
56 ) ./cpu_subtype_arm64e_replacement.patch;
57
58
59 outputs = [ "out" "lib" "dev" ];
60
61 nativeBuildInputs = [
62 cmake python3 which swig lit makeWrapper
63 ] ++ lib.optionals enableManpages [
64 python3.pkgs.sphinx python3.pkgs.recommonmark
65 ];
66
67 buildInputs = [
68 ncurses
69 zlib
70 libedit
71 libxml2
72 libllvm
73 ] ++ lib.optionals stdenv.isDarwin [
74 libobjc
75 xpc
76 Foundation
77 bootstrap_cmds
78 Carbon
79 Cocoa
80 ];
81
82 hardeningDisable = [ "format" ];
83
84 cmakeFlags = [
85 "-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}"
86 "-DLLVM_ENABLE_RTTI=OFF"
87 "-DClang_DIR=${libclang.dev}/lib/cmake"
88 "-DLLVM_EXTERNAL_LIT=${lit}/bin/lit"
89 ] ++ lib.optionals stdenv.isDarwin [
90 "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON"
91 ] ++ lib.optionals (!stdenv.isDarwin) [
92 "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
93 ] ++ lib.optionals enableManpages [
94 "-DLLVM_ENABLE_SPHINX=ON"
95 "-DSPHINX_OUTPUT_MAN=ON"
96 "-DSPHINX_OUTPUT_HTML=OFF"
97 ] ++ lib.optionals doCheck [
98 "-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
99 "-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"
100 ];
101
102 doCheck = false;
103
104 doInstallCheck = true;
105
106 installCheckPhase = ''
107 if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then
108 echo "ERROR: python files not installed where expected!";
109 return 1;
110 fi
111 '';
112
113 postInstall = ''
114 wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/
115
116 # Editor support
117 # vscode:
118 install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json
119 mkdir -p $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
120 ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
121 '';
122
123 meta = llvm_meta // {
124 homepage = "https://lldb.llvm.org/";
125 description = "A next-generation high-performance debugger";
126 longDescription = ''
127 LLDB is a next generation, high-performance debugger. It is built as a set
128 of reusable components which highly leverage existing libraries in the
129 larger LLVM Project, such as the Clang expression parser and LLVM
130 disassembler.
131 '';
132 };
133} // lib.optionalAttrs enableManpages {
134 pname = "lldb-manpages";
135
136 buildPhase = ''
137 make docs-lldb-man
138 '';
139
140 propagatedBuildInputs = [];
141
142 # manually install lldb man page
143 installPhase = ''
144 mkdir -p $out/share/man/man1
145 install docs/man/lldb.1 -t $out/share/man/man1/
146 '';
147
148 postPatch = null;
149 postInstall = null;
150
151 outputs = [ "out" ];
152
153 doCheck = false;
154
155 meta = llvm_meta // {
156 broken = stdenv.isDarwin;
157 description = "man pages for LLDB ${version}";
158 };
159})