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