From d53d5a8b38f8ecbf75388a1582efd4c19e61d5da Mon Sep 17 00:00:00 2001 From: Artturin Date: Sat, 6 May 2023 21:03:17 +0300 Subject: llvmPackages.lldb: deduplicate >10 --- pkgs/development/compilers/llvm/10/default.nix | 9 +- .../development/compilers/llvm/10/lldb/default.nix | 128 ------------- pkgs/development/compilers/llvm/11/default.nix | 9 +- .../development/compilers/llvm/11/lldb/default.nix | 126 ------------- pkgs/development/compilers/llvm/12/default.nix | 22 ++- .../development/compilers/llvm/12/lldb/default.nix | 142 -------------- pkgs/development/compilers/llvm/13/default.nix | 35 +++- .../development/compilers/llvm/13/lldb/default.nix | 159 ---------------- pkgs/development/compilers/llvm/14/default.nix | 35 +++- .../development/compilers/llvm/14/lldb/default.nix | 167 ----------------- pkgs/development/compilers/llvm/15/default.nix | 35 +++- .../development/compilers/llvm/15/lldb/default.nix | 186 ------------------ pkgs/development/compilers/llvm/16/default.nix | 40 +++- .../development/compilers/llvm/16/lldb/default.nix | 186 ------------------ pkgs/development/compilers/llvm/common/lldb.nix | 207 +++++++++++++++++++++ 15 files changed, 363 insertions(+), 1123 deletions(-) delete mode 100644 pkgs/development/compilers/llvm/10/lldb/default.nix delete mode 100644 pkgs/development/compilers/llvm/11/lldb/default.nix delete mode 100644 pkgs/development/compilers/llvm/12/lldb/default.nix delete mode 100644 pkgs/development/compilers/llvm/13/lldb/default.nix delete mode 100644 pkgs/development/compilers/llvm/14/lldb/default.nix delete mode 100644 pkgs/development/compilers/llvm/15/lldb/default.nix delete mode 100644 pkgs/development/compilers/llvm/16/lldb/default.nix create mode 100644 pkgs/development/compilers/llvm/common/lldb.nix (limited to 'pkgs/development') diff --git a/pkgs/development/compilers/llvm/10/default.nix b/pkgs/development/compilers/llvm/10/default.nix index 75985e962479..4ab42ee73be5 100644 --- a/pkgs/development/compilers/llvm/10/default.nix +++ b/pkgs/development/compilers/llvm/10/default.nix @@ -130,8 +130,13 @@ let inherit llvm_meta; }; - lldb = callPackage ./lldb { - inherit llvm_meta; + lldb = callPackage ../common/lldb.nix { + src = fetch "lldb" "051p5b04y6z3g730rmc2n2v71lipbw7k69riww3a6sl74myfiaq7"; + patches = [ + ./lldb/procfs.patch + ./lldb/gnu-install-dirs.patch + ]; + inherit llvm_meta release_version; }; # Below, is the LLVM bootstrapping logic. It handles building a diff --git a/pkgs/development/compilers/llvm/10/lldb/default.nix b/pkgs/development/compilers/llvm/10/lldb/default.nix deleted file mode 100644 index 4a40a931af65..000000000000 --- a/pkgs/development/compilers/llvm/10/lldb/default.nix +++ /dev/null @@ -1,128 +0,0 @@ -{ lib, stdenv, llvm_meta -, fetch -, cmake -, zlib -, ncurses -, swig -, which -, libedit -, libxml2 -, libllvm -, libclang -, python3 -, version -, darwin -, lit -, makeWrapper -, enableManpages ? false -}: - -stdenv.mkDerivation (rec { - pname = "lldb"; - inherit version; - - src = fetch pname "051p5b04y6z3g730rmc2n2v71lipbw7k69riww3a6sl74myfiaq7"; - - patches = [ - ./procfs.patch - ./gnu-install-dirs.patch - ]; - - outputs = [ "out" "lib" "dev" ]; - - nativeBuildInputs = [ - cmake python3 which swig lit makeWrapper - ] ++ lib.optionals enableManpages [ - python3.pkgs.sphinx python3.pkgs.recommonmark - ]; - - buildInputs = [ - ncurses zlib libedit libxml2 libllvm - ] ++ lib.optionals stdenv.isDarwin [ - darwin.libobjc - darwin.apple_sdk.libs.xpc - darwin.apple_sdk.frameworks.Foundation - darwin.bootstrap_cmds - darwin.apple_sdk.frameworks.Carbon - darwin.apple_sdk.frameworks.Cocoa - ]; - - hardeningDisable = [ "format" ]; - - cmakeFlags = [ - "-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}" - "-DLLVM_ENABLE_RTTI=OFF" - "-DClang_DIR=${libclang.dev}/lib/cmake" - "-DLLVM_EXTERNAL_LIT=${lit}/bin/lit" - ] ++ lib.optionals stdenv.isDarwin [ - "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON" - ] ++ lib.optionals (!stdenv.isDarwin) [ - "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic - ] ++ lib.optionals enableManpages [ - "-DLLVM_ENABLE_SPHINX=ON" - "-DSPHINX_OUTPUT_MAN=ON" - "-DSPHINX_OUTPUT_HTML=OFF" - ] ++ lib.optionals doCheck [ - "-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" - "-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++" - ]; - - doCheck = false; - - doInstallCheck = true; - - installCheckPhase = '' - if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then - echo "ERROR: python files not installed where expected!"; - return 1; - fi - ''; - - postInstall = '' - wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ - - # Editor support - # vscode: - install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json - mkdir -p $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin - ln -s $out/bin/llvm-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin - ''; - - meta = llvm_meta // { - homepage = "https://lldb.llvm.org/"; - description = "A next-generation high-performance debugger"; - longDescription = '' - LLDB is a next generation, high-performance debugger. It is built as a set - of reusable components which highly leverage existing libraries in the - larger LLVM Project, such as the Clang expression parser and LLVM - disassembler. - ''; - # never built on aarch64-darwin since first introduction in nixpkgs - broken = stdenv.isDarwin && stdenv.isAarch64; - }; -} // lib.optionalAttrs enableManpages { - pname = "lldb-manpages"; - - buildPhase = '' - make docs-man - ''; - - propagatedBuildInputs = []; - - # manually install lldb man page - installPhase = '' - mkdir -p $out/share/man/man1 - install docs/man/lldb.1 -t $out/share/man/man1/ - ''; - - postPatch = null; - postInstall = null; - - outputs = [ "out" ]; - - doCheck = false; - - meta = llvm_meta // { - description = "man pages for LLDB ${version}"; - }; -}) diff --git a/pkgs/development/compilers/llvm/11/default.nix b/pkgs/development/compilers/llvm/11/default.nix index 6f73f50e3183..dec36abe4321 100644 --- a/pkgs/development/compilers/llvm/11/default.nix +++ b/pkgs/development/compilers/llvm/11/default.nix @@ -145,8 +145,13 @@ let inherit llvm_meta; }; - lldb = callPackage ./lldb { - inherit llvm_meta; + lldb = callPackage ../common/lldb.nix { + src = fetch "lldb" "1vlyg015dyng43xqb8cg2l6r9ix8klibxsajazbfnckdnh54hwxj"; + patches = [ + ./lldb/procfs.patch + ./lldb/gnu-install-dirs.patch + ]; + inherit llvm_meta release_version; }; # Below, is the LLVM bootstrapping logic. It handles building a diff --git a/pkgs/development/compilers/llvm/11/lldb/default.nix b/pkgs/development/compilers/llvm/11/lldb/default.nix deleted file mode 100644 index 5912323608dc..000000000000 --- a/pkgs/development/compilers/llvm/11/lldb/default.nix +++ /dev/null @@ -1,126 +0,0 @@ -{ lib, stdenv, llvm_meta -, fetch -, cmake -, zlib -, ncurses -, swig -, which -, libedit -, libxml2 -, libllvm -, libclang -, python3 -, version -, darwin -, lit -, makeWrapper -, enableManpages ? false -}: - -stdenv.mkDerivation (rec { - pname = "lldb"; - inherit version; - - src = fetch pname "1vlyg015dyng43xqb8cg2l6r9ix8klibxsajazbfnckdnh54hwxj"; - - patches = [ - ./procfs.patch - ./gnu-install-dirs.patch - ]; - - outputs = [ "out" "lib" "dev" ]; - - nativeBuildInputs = [ - cmake python3 which swig lit makeWrapper - ] ++ lib.optionals enableManpages [ - python3.pkgs.sphinx python3.pkgs.recommonmark - ]; - - buildInputs = [ - ncurses zlib libedit libxml2 libllvm - ] ++ lib.optionals stdenv.isDarwin [ - darwin.libobjc - darwin.apple_sdk.libs.xpc - darwin.apple_sdk.frameworks.Foundation - darwin.bootstrap_cmds - darwin.apple_sdk.frameworks.Carbon - darwin.apple_sdk.frameworks.Cocoa - ]; - - hardeningDisable = [ "format" ]; - - cmakeFlags = [ - "-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}" - "-DLLVM_ENABLE_RTTI=OFF" - "-DClang_DIR=${libclang.dev}/lib/cmake" - "-DLLVM_EXTERNAL_LIT=${lit}/bin/lit" - ] ++ lib.optionals stdenv.isDarwin [ - "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON" - ] ++ lib.optionals (!stdenv.isDarwin) [ - "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic - ] ++ lib.optionals enableManpages [ - "-DLLVM_ENABLE_SPHINX=ON" - "-DSPHINX_OUTPUT_MAN=ON" - "-DSPHINX_OUTPUT_HTML=OFF" - ] ++ lib.optionals doCheck [ - "-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" - "-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++" - ]; - - doCheck = false; - - doInstallCheck = true; - - installCheckPhase = '' - if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then - echo "ERROR: python files not installed where expected!"; - return 1; - fi - ''; - - postInstall = '' - wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ - - # Editor support - # vscode: - install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json - mkdir -p $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin - ln -s $out/bin/llvm-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin - ''; - - meta = llvm_meta // { - homepage = "https://lldb.llvm.org/"; - description = "A next-generation high-performance debugger"; - longDescription = '' - LLDB is a next generation, high-performance debugger. It is built as a set - of reusable components which highly leverage existing libraries in the - larger LLVM Project, such as the Clang expression parser and LLVM - disassembler. - ''; - }; -} // lib.optionalAttrs enableManpages { - pname = "lldb-manpages"; - - buildPhase = '' - make docs-man - ''; - - propagatedBuildInputs = []; - - # manually install lldb man page - installPhase = '' - mkdir -p $out/share/man/man1 - install docs/man/lldb.1 -t $out/share/man/man1/ - ''; - - postPatch = null; - postInstall = null; - - outputs = [ "out" ]; - - doCheck = false; - - meta = llvm_meta // { - description = "man pages for LLDB ${version}"; - }; -}) diff --git a/pkgs/development/compilers/llvm/12/default.nix b/pkgs/development/compilers/llvm/12/default.nix index b936b35b155a..7586ca128826 100644 --- a/pkgs/development/compilers/llvm/12/default.nix +++ b/pkgs/development/compilers/llvm/12/default.nix @@ -134,11 +134,23 @@ let inherit (libraries) libunwind; }; - lldb = callPackage ./lldb { - inherit llvm_meta; - inherit (darwin) libobjc bootstrap_cmds; - inherit (darwin.apple_sdk.libs) xpc; - inherit (darwin.apple_sdk.frameworks) Foundation Carbon Cocoa; + lldb = callPackage ../common/lldb.nix { + src = fetch "lldb" "0g3pj1m3chafavpr35r9fynm85y2hdyla6klj0h28khxs2613i78"; + patches = + let + resourceDirPatch = callPackage ({ runCommand, libclang }: (runCommand "resource-dir.patch" + { + clangLibDir = "${libclang.lib}/lib"; + } '' + substitute '${./lldb/resource-dir.patch}' "$out" --subst-var clangLibDir + '')) { }; + in + [ + ./lldb/procfs.patch + resourceDirPatch + ./lldb/gnu-install-dirs.patch + ]; + inherit llvm_meta release_version; }; # Below, is the LLVM bootstrapping logic. It handles building a diff --git a/pkgs/development/compilers/llvm/12/lldb/default.nix b/pkgs/development/compilers/llvm/12/lldb/default.nix deleted file mode 100644 index c75eb255cd75..000000000000 --- a/pkgs/development/compilers/llvm/12/lldb/default.nix +++ /dev/null @@ -1,142 +0,0 @@ -{ lib, stdenv, llvm_meta -, runCommand -, fetch -, cmake -, zlib -, ncurses -, swig -, which -, libedit -, libxml2 -, libllvm -, libclang -, python3 -, version -, libobjc -, xpc -, Foundation -, bootstrap_cmds -, Carbon -, Cocoa -, lit -, makeWrapper -, enableManpages ? false -}: - -stdenv.mkDerivation (rec { - pname = "lldb"; - inherit version; - - src = fetch pname "0g3pj1m3chafavpr35r9fynm85y2hdyla6klj0h28khxs2613i78"; - - patches = [ - ./procfs.patch - (runCommand "resource-dir.patch" { - clangLibDir = "${libclang.lib}/lib"; - } '' - substitute '${./resource-dir.patch}' "$out" --subst-var clangLibDir - '') - ./gnu-install-dirs.patch - ]; - - outputs = [ "out" "lib" "dev" ]; - - nativeBuildInputs = [ - cmake python3 which swig lit makeWrapper - ] ++ lib.optionals enableManpages [ - python3.pkgs.sphinx python3.pkgs.recommonmark - ]; - - buildInputs = [ - ncurses - zlib - libedit - libxml2 - libllvm - ] - ++ lib.optionals stdenv.isDarwin [ - libobjc - xpc - Foundation - bootstrap_cmds - Carbon - Cocoa - ]; - - hardeningDisable = [ "format" ]; - - cmakeFlags = [ - "-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}" - "-DLLVM_ENABLE_RTTI=OFF" - "-DClang_DIR=${libclang.dev}/lib/cmake" - "-DLLVM_EXTERNAL_LIT=${lit}/bin/lit" - ] ++ lib.optionals stdenv.isDarwin [ - "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON" - ] ++ lib.optionals (!stdenv.isDarwin) [ - "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic - ] ++ lib.optionals enableManpages [ - "-DLLVM_ENABLE_SPHINX=ON" - "-DSPHINX_OUTPUT_MAN=ON" - "-DSPHINX_OUTPUT_HTML=OFF" - ] ++ lib.optionals doCheck [ - "-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" - "-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++" - ]; - - doCheck = false; - - doInstallCheck = true; - - installCheckPhase = '' - if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then - echo "ERROR: python files not installed where expected!"; - return 1; - fi - ''; - - postInstall = '' - wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ - - # Editor support - # vscode: - install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json - mkdir -p $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin - ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin - ''; - - meta = llvm_meta // { - homepage = "https://lldb.llvm.org/"; - description = "A next-generation high-performance debugger"; - longDescription = '' - LLDB is a next generation, high-performance debugger. It is built as a set - of reusable components which highly leverage existing libraries in the - larger LLVM Project, such as the Clang expression parser and LLVM - disassembler. - ''; - }; -} // lib.optionalAttrs enableManpages { - pname = "lldb-manpages"; - - buildPhase = '' - make docs-lldb-man - ''; - - propagatedBuildInputs = []; - - # manually install lldb man page - installPhase = '' - mkdir -p $out/share/man/man1 - install docs/man/lldb.1 -t $out/share/man/man1/ - ''; - - postPatch = null; - postInstall = null; - - outputs = [ "out" ]; - - doCheck = false; - - meta = llvm_meta // { - description = "man pages for LLDB ${version}"; - }; -}) diff --git a/pkgs/development/compilers/llvm/13/default.nix b/pkgs/development/compilers/llvm/13/default.nix index 0bc17119125b..1a2d33f4b5b6 100644 --- a/pkgs/development/compilers/llvm/13/default.nix +++ b/pkgs/development/compilers/llvm/13/default.nix @@ -134,11 +134,36 @@ let inherit llvm_meta; }; - lldb = callPackage ./lldb { - inherit llvm_meta; - inherit (darwin) libobjc bootstrap_cmds; - inherit (darwin.apple_sdk.libs) xpc; - inherit (darwin.apple_sdk.frameworks) Foundation Carbon Cocoa; + lldb = callPackage ../common/lldb.nix { + patches = + let + resourceDirPatch = callPackage ({ runCommand, libclang }: (runCommand "resource-dir.patch" + { + clangLibDir = "${libclang.lib}/lib"; + } '' + substitute '${./lldb/resource-dir.patch}' "$out" --subst-var clangLibDir + '')) { }; + in + [ + ./lldb/procfs.patch + resourceDirPatch + ./lldb/gnu-install-dirs.patch + ] + # This is a stopgap solution if/until the macOS SDK used for x86_64 is + # updated. + # + # The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h` + # header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use + # of this preprocessor symbol in `lldb` with its expansion. + # + # See here for some context: + # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 + ++ lib.optional ( + stdenv.targetPlatform.isDarwin + && !stdenv.targetPlatform.isAarch64 + && (lib.versionOlder darwin.apple_sdk.sdk.version "11.0") + ) ./lldb/cpu_subtype_arm64e_replacement.patch; + inherit llvm_meta release_version; }; # Below, is the LLVM bootstrapping logic. It handles building a diff --git a/pkgs/development/compilers/llvm/13/lldb/default.nix b/pkgs/development/compilers/llvm/13/lldb/default.nix deleted file mode 100644 index ca7a17a5e90d..000000000000 --- a/pkgs/development/compilers/llvm/13/lldb/default.nix +++ /dev/null @@ -1,159 +0,0 @@ -{ lib, stdenv, llvm_meta -, runCommand -, src -, cmake -, zlib -, ncurses -, swig -, which -, libedit -, libxml2 -, libllvm -, libclang -, python3 -, version -, libobjc -, xpc -, Foundation -, bootstrap_cmds -, Carbon -, Cocoa -, lit -, makeWrapper -, darwin -, enableManpages ? false -}: - -stdenv.mkDerivation (rec { - pname = "lldb"; - inherit version; - - inherit src; - sourceRoot = "source/${pname}"; - - patches = [ - ./procfs.patch - (runCommand "resource-dir.patch" { - clangLibDir = "${libclang.lib}/lib"; - } '' - substitute '${./resource-dir.patch}' "$out" --subst-var clangLibDir - '') - ./gnu-install-dirs.patch - ] - # This is a stopgap solution if/until the macOS SDK used for x86_64 is - # updated. - # - # The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h` - # header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use - # of this preprocessor symbol in `lldb` with its expansion. - # - # See here for some context: - # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 - ++ lib.optional ( - stdenv.targetPlatform.isDarwin - && !stdenv.targetPlatform.isAarch64 - && (lib.versionOlder darwin.apple_sdk.sdk.version "11.0") - ) ./cpu_subtype_arm64e_replacement.patch; - - - outputs = [ "out" "lib" "dev" ]; - - nativeBuildInputs = [ - cmake python3 which swig lit makeWrapper - ] ++ lib.optionals enableManpages [ - python3.pkgs.sphinx python3.pkgs.recommonmark - ]; - - buildInputs = [ - ncurses - zlib - libedit - libxml2 - libllvm - ] ++ lib.optionals stdenv.isDarwin [ - libobjc - xpc - Foundation - bootstrap_cmds - Carbon - Cocoa - ]; - - hardeningDisable = [ "format" ]; - - cmakeFlags = [ - "-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}" - "-DLLVM_ENABLE_RTTI=OFF" - "-DClang_DIR=${libclang.dev}/lib/cmake" - "-DLLVM_EXTERNAL_LIT=${lit}/bin/lit" - ] ++ lib.optionals stdenv.isDarwin [ - "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON" - ] ++ lib.optionals (!stdenv.isDarwin) [ - "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic - ] ++ lib.optionals enableManpages [ - "-DLLVM_ENABLE_SPHINX=ON" - "-DSPHINX_OUTPUT_MAN=ON" - "-DSPHINX_OUTPUT_HTML=OFF" - ] ++ lib.optionals doCheck [ - "-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" - "-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++" - ]; - - doCheck = false; - - doInstallCheck = true; - - installCheckPhase = '' - if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then - echo "ERROR: python files not installed where expected!"; - return 1; - fi - ''; - - postInstall = '' - wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ - - # Editor support - # vscode: - install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json - mkdir -p $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin - ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin - ''; - - meta = llvm_meta // { - homepage = "https://lldb.llvm.org/"; - description = "A next-generation high-performance debugger"; - longDescription = '' - LLDB is a next generation, high-performance debugger. It is built as a set - of reusable components which highly leverage existing libraries in the - larger LLVM Project, such as the Clang expression parser and LLVM - disassembler. - ''; - }; -} // lib.optionalAttrs enableManpages { - pname = "lldb-manpages"; - - buildPhase = '' - make docs-lldb-man - ''; - - propagatedBuildInputs = []; - - # manually install lldb man page - installPhase = '' - mkdir -p $out/share/man/man1 - install docs/man/lldb.1 -t $out/share/man/man1/ - ''; - - postPatch = null; - postInstall = null; - - outputs = [ "out" ]; - - doCheck = false; - - meta = llvm_meta // { - broken = stdenv.isDarwin; - description = "man pages for LLDB ${version}"; - }; -}) diff --git a/pkgs/development/compilers/llvm/14/default.nix b/pkgs/development/compilers/llvm/14/default.nix index 21dc8088452c..8c42038b2373 100644 --- a/pkgs/development/compilers/llvm/14/default.nix +++ b/pkgs/development/compilers/llvm/14/default.nix @@ -135,11 +135,36 @@ let inherit llvm_meta; }; - lldb = callPackage ./lldb { - inherit llvm_meta; - inherit (darwin) libobjc bootstrap_cmds; - inherit (darwin.apple_sdk.libs) xpc; - inherit (darwin.apple_sdk.frameworks) Foundation Carbon Cocoa; + lldb = callPackage ../common/lldb.nix { + patches = + let + resourceDirPatch = callPackage ({ runCommand, libclang }: (runCommand "resource-dir.patch" + { + clangLibDir = "${libclang.lib}/lib"; + } '' + substitute '${./lldb/resource-dir.patch}' "$out" --subst-var clangLibDir + '')) { }; + in + [ + ./lldb/procfs.patch + resourceDirPatch + ./lldb/gnu-install-dirs.patch + ] + # This is a stopgap solution if/until the macOS SDK used for x86_64 is + # updated. + # + # The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h` + # header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use + # of this preprocessor symbol in `lldb` with its expansion. + # + # See here for some context: + # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 + ++ lib.optional ( + stdenv.targetPlatform.isDarwin + && !stdenv.targetPlatform.isAarch64 + && (lib.versionOlder darwin.apple_sdk.sdk.version "11.0") + ) ./lldb/cpu_subtype_arm64e_replacement.patch; + inherit llvm_meta release_version; }; # Below, is the LLVM bootstrapping logic. It handles building a diff --git a/pkgs/development/compilers/llvm/14/lldb/default.nix b/pkgs/development/compilers/llvm/14/lldb/default.nix deleted file mode 100644 index cd28325a5573..000000000000 --- a/pkgs/development/compilers/llvm/14/lldb/default.nix +++ /dev/null @@ -1,167 +0,0 @@ -{ lib, stdenv, llvm_meta -, runCommand -, monorepoSrc -, cmake -, zlib -, ncurses -, swig -, which -, libedit -, libxml2 -, libllvm -, libclang -, python3 -, version -, libobjc -, xpc -, Foundation -, bootstrap_cmds -, Carbon -, Cocoa -, lit -, makeWrapper -, darwin -, enableManpages ? false -, lua5_3 -}: - -stdenv.mkDerivation (rec { - pname = "lldb"; - inherit version; - - src = runCommand "${pname}-src-${version}" {} '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" - ''; - - sourceRoot = "${src.name}/${pname}"; - - patches = [ - ./procfs.patch - (runCommand "resource-dir.patch" { - clangLibDir = "${libclang.lib}/lib"; - } '' - substitute '${./resource-dir.patch}' "$out" --subst-var clangLibDir - '') - ./gnu-install-dirs.patch - ] - # This is a stopgap solution if/until the macOS SDK used for x86_64 is - # updated. - # - # The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h` - # header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use - # of this preprocessor symbol in `lldb` with its expansion. - # - # See here for some context: - # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 - ++ lib.optional ( - stdenv.targetPlatform.isDarwin - && !stdenv.targetPlatform.isAarch64 - && (lib.versionOlder darwin.apple_sdk.sdk.version "11.0") - ) ./cpu_subtype_arm64e_replacement.patch; - - outputs = [ "out" "lib" "dev" ]; - - nativeBuildInputs = [ - cmake python3 which swig lit makeWrapper lua5_3 - ] ++ lib.optionals enableManpages [ - python3.pkgs.sphinx python3.pkgs.recommonmark - ]; - - buildInputs = [ - ncurses - zlib - libedit - libxml2 - libllvm - ] ++ lib.optionals stdenv.isDarwin [ - libobjc - xpc - Foundation - bootstrap_cmds - Carbon - Cocoa - ]; - - hardeningDisable = [ "format" ]; - - cmakeFlags = [ - "-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}" - "-DLLVM_ENABLE_RTTI=OFF" - "-DClang_DIR=${libclang.dev}/lib/cmake" - "-DLLVM_EXTERNAL_LIT=${lit}/bin/lit" - ] ++ lib.optionals stdenv.isDarwin [ - "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON" - ] ++ lib.optionals (!stdenv.isDarwin) [ - "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic - ] ++ lib.optionals enableManpages [ - "-DLLVM_ENABLE_SPHINX=ON" - "-DSPHINX_OUTPUT_MAN=ON" - "-DSPHINX_OUTPUT_HTML=OFF" - ] ++ lib.optionals doCheck [ - "-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" - "-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++" - ]; - - doCheck = false; - - doInstallCheck = true; - - installCheckPhase = '' - if [ ! -e $lib/${python3.sitePackages}/lldb/_lldb*.so ] ; then - echo "ERROR: python files not installed where expected!"; - return 1; - fi - if [ ! -e "$lib/lib/lua/${lua5_3.luaversion}/lldb.so" ] ; then - echo "ERROR: lua files not installed where expected!"; - return 1; - fi - ''; - - postInstall = '' - wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ - - # Editor support - # vscode: - install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json - mkdir -p $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin - ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin - ''; - - meta = llvm_meta // { - homepage = "https://lldb.llvm.org/"; - description = "A next-generation high-performance debugger"; - longDescription = '' - LLDB is a next generation, high-performance debugger. It is built as a set - of reusable components which highly leverage existing libraries in the - larger LLVM Project, such as the Clang expression parser and LLVM - disassembler. - ''; - }; -} // lib.optionalAttrs enableManpages { - pname = "lldb-manpages"; - - buildPhase = '' - make docs-lldb-man - ''; - - propagatedBuildInputs = []; - - # manually install lldb man page - installPhase = '' - mkdir -p $out/share/man/man1 - install docs/man/lldb.1 -t $out/share/man/man1/ - ''; - - postPatch = null; - postInstall = null; - - outputs = [ "out" ]; - - doCheck = false; - - meta = llvm_meta // { - description = "man pages for LLDB ${version}"; - }; -}) diff --git a/pkgs/development/compilers/llvm/15/default.nix b/pkgs/development/compilers/llvm/15/default.nix index d4fd2d9bec6d..931fb9a6cced 100644 --- a/pkgs/development/compilers/llvm/15/default.nix +++ b/pkgs/development/compilers/llvm/15/default.nix @@ -183,11 +183,36 @@ in let inherit llvm_meta; }; - lldb = callPackage ./lldb { - inherit llvm_meta; - inherit (darwin) libobjc bootstrap_cmds; - inherit (darwin.apple_sdk.libs) xpc; - inherit (darwin.apple_sdk.frameworks) Foundation Carbon Cocoa; + lldb = callPackage ../common/lldb.nix { + patches = + let + resourceDirPatch = callPackage ({ runCommand, libclang }: (runCommand "resource-dir.patch" + { + clangLibDir = "${libclang.lib}/lib"; + } '' + substitute '${./lldb/resource-dir.patch}' "$out" --subst-var clangLibDir + '')) { }; + in + [ + ./lldb/procfs.patch + resourceDirPatch + ./lldb/gnu-install-dirs.patch + ] + # This is a stopgap solution if/until the macOS SDK used for x86_64 is + # updated. + # + # The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h` + # header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use + # of this preprocessor symbol in `lldb` with its expansion. + # + # See here for some context: + # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 + ++ lib.optional ( + stdenv.targetPlatform.isDarwin + && !stdenv.targetPlatform.isAarch64 + && (lib.versionOlder darwin.apple_sdk.sdk.version "11.0") + ) ./lldb/cpu_subtype_arm64e_replacement.patch; + inherit llvm_meta release_version; }; # Below, is the LLVM bootstrapping logic. It handles building a diff --git a/pkgs/development/compilers/llvm/15/lldb/default.nix b/pkgs/development/compilers/llvm/15/lldb/default.nix deleted file mode 100644 index 4b50b79cf613..000000000000 --- a/pkgs/development/compilers/llvm/15/lldb/default.nix +++ /dev/null @@ -1,186 +0,0 @@ -{ lib, stdenv, llvm_meta -, runCommand -, monorepoSrc -, cmake -, ninja -, zlib -, ncurses -, swig -, which -, libedit -, libxml2 -, libllvm -, libclang -, python3 -, version -, libobjc -, xpc -, Foundation -, bootstrap_cmds -, Carbon -, Cocoa -, lit -, makeWrapper -, darwin -, enableManpages ? false -, lua5_3 -}: - -# TODO: we build the python bindings but don't expose them as a python package -# TODO: expose the vscode extension? - -stdenv.mkDerivation (rec { - pname = "lldb"; - inherit version; - - src = runCommand "${pname}-src-${version}" {} '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" - ''; - - sourceRoot = "${src.name}/${pname}"; - - patches = [ - ./procfs.patch - (runCommand "resource-dir.patch" { - clangLibDir = "${libclang.lib}/lib"; - } '' - substitute '${./resource-dir.patch}' "$out" --subst-var clangLibDir - '') - ./gnu-install-dirs.patch - ] - # This is a stopgap solution if/until the macOS SDK used for x86_64 is - # updated. - # - # The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h` - # header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use - # of this preprocessor symbol in `lldb` with its expansion. - # - # See here for some context: - # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 - ++ lib.optional ( - stdenv.targetPlatform.isDarwin - && !stdenv.targetPlatform.isAarch64 - && (lib.versionOlder darwin.apple_sdk.sdk.version "11.0") - ) ./cpu_subtype_arm64e_replacement.patch; - - outputs = [ "out" "lib" "dev" ]; - - nativeBuildInputs = [ - cmake ninja python3 which swig lit makeWrapper lua5_3 - ] ++ lib.optionals enableManpages [ - python3.pkgs.sphinx python3.pkgs.recommonmark - ]; - - buildInputs = [ - ncurses - zlib - libedit - libxml2 - libllvm - ] ++ lib.optionals stdenv.isDarwin [ - libobjc - xpc - Foundation - bootstrap_cmds - Carbon - Cocoa - ] - # The older libSystem used on x86_64 macOS is missing the - # `` header which `lldb` uses. - # - # We copy this header over from macOS 10.12 SDK. - # - # See here for context: - # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 - ++ lib.optional ( - stdenv.targetPlatform.isDarwin - && !stdenv.targetPlatform.isAarch64 - ) ( - runCommand "bsm-audit-session-header" { } '' - install -Dm444 \ - "${lib.getDev darwin.apple_sdk.sdk}/include/bsm/audit_session.h" \ - "$out/include/bsm/audit_session.h" - '' - ); - - hardeningDisable = [ "format" ]; - - cmakeFlags = [ - "-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}" - "-DLLVM_ENABLE_RTTI=OFF" - "-DClang_DIR=${libclang.dev}/lib/cmake" - "-DLLVM_EXTERNAL_LIT=${lit}/bin/lit" - ] ++ lib.optionals stdenv.isDarwin [ - "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON" - ] ++ lib.optionals (!stdenv.isDarwin) [ - "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic - ] ++ lib.optionals enableManpages [ - "-DLLVM_ENABLE_SPHINX=ON" - "-DSPHINX_OUTPUT_MAN=ON" - "-DSPHINX_OUTPUT_HTML=OFF" - - # docs reference `automodapi` but it's not added to the extensions list when - # only building the manpages: - # https://github.com/llvm/llvm-project/blob/af6ec9200b09039573d85e349496c4f5b17c3d7f/lldb/docs/conf.py#L54 - # - # so, we just ignore the resulting errors - "-DSPHINX_WARNINGS_AS_ERRORS=OFF" - ] ++ lib.optionals doCheck [ - "-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" - "-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++" - ]; - - doCheck = false; - - installCheckPhase = '' - if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then - return 1; - fi - ''; - - postInstall = '' - wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ - - # Editor support - # vscode: - install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json - mkdir -p $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin - ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin - ''; - - meta = llvm_meta // { - homepage = "https://lldb.llvm.org/"; - description = "A next-generation high-performance debugger"; - longDescription = '' - LLDB is a next generation, high-performance debugger. It is built as a set - of reusable components which highly leverage existing libraries in the - larger LLVM Project, such as the Clang expression parser and LLVM - disassembler. - ''; - }; -} // lib.optionalAttrs enableManpages { - pname = "lldb-manpages"; - - ninjaFlags = [ "docs-lldb-man" ]; - - propagatedBuildInputs = []; - - # manually install lldb man page - installPhase = '' - mkdir -p $out/share/man/man1 - install docs/man/lldb.1 -t $out/share/man/man1/ - ''; - - postPatch = null; - postInstall = null; - - outputs = [ "out" ]; - - doCheck = false; - - meta = llvm_meta // { - description = "man pages for LLDB ${version}"; - }; -}) diff --git a/pkgs/development/compilers/llvm/16/default.nix b/pkgs/development/compilers/llvm/16/default.nix index 1304ef2bdbc0..2a85d900c8a8 100644 --- a/pkgs/development/compilers/llvm/16/default.nix +++ b/pkgs/development/compilers/llvm/16/default.nix @@ -184,11 +184,41 @@ in let inherit llvm_meta; }; - lldb = callPackage ./lldb { - inherit llvm_meta; - inherit (darwin) libobjc bootstrap_cmds; - inherit (darwin.apple_sdk.libs) xpc; - inherit (darwin.apple_sdk.frameworks) Foundation Carbon Cocoa; + lldb = callPackage ../common/lldb.nix { + src = callPackage ({ runCommand }: runCommand "lldb-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/lldb "$out" + '') { }; + patches = + let + resourceDirPatch = callPackage ({ runCommand, libclang }: (runCommand "resource-dir.patch" + { + clangLibDir = "${libclang.lib}/lib"; + } '' + substitute '${./lldb/resource-dir.patch}' "$out" --subst-var clangLibDir + '')) { }; + in + [ + # FIXME: do we need this? ./procfs.patch + resourceDirPatch + ./lldb/gnu-install-dirs.patch + ] + # This is a stopgap solution if/until the macOS SDK used for x86_64 is + # updated. + # + # The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h` + # header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use + # of this preprocessor symbol in `lldb` with its expansion. + # + # See here for some context: + # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 + ++ lib.optional ( + stdenv.targetPlatform.isDarwin + && !stdenv.targetPlatform.isAarch64 + && (lib.versionOlder darwin.apple_sdk.sdk.version "11.0") + ) ./lldb/cpu_subtype_arm64e_replacement.patch; + inherit llvm_meta release_version; }; # Below, is the LLVM bootstrapping logic. It handles building a diff --git a/pkgs/development/compilers/llvm/16/lldb/default.nix b/pkgs/development/compilers/llvm/16/lldb/default.nix deleted file mode 100644 index 062867394cc8..000000000000 --- a/pkgs/development/compilers/llvm/16/lldb/default.nix +++ /dev/null @@ -1,186 +0,0 @@ -{ lib, stdenv, llvm_meta -, runCommand -, monorepoSrc -, cmake -, ninja -, zlib -, ncurses -, swig -, which -, libedit -, libxml2 -, libllvm -, libclang -, python3 -, version -, libobjc -, xpc -, Foundation -, bootstrap_cmds -, Carbon -, Cocoa -, lit -, makeWrapper -, darwin -, enableManpages ? false -, lua5_3 -}: - -# TODO: we build the python bindings but don't expose them as a python package -# TODO: expose the vscode extension? - -stdenv.mkDerivation (rec { - pname = "lldb"; - inherit version; - - src = runCommand "${pname}-src-${version}" {} '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" - ''; - - sourceRoot = "${src.name}/${pname}"; - - patches = [ - # FIXME: do we need this? ./procfs.patch - (runCommand "resource-dir.patch" { - clangLibDir = "${libclang.lib}/lib"; - } '' - substitute '${./resource-dir.patch}' "$out" --subst-var clangLibDir - '') - ./gnu-install-dirs.patch - ] - # This is a stopgap solution if/until the macOS SDK used for x86_64 is - # updated. - # - # The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h` - # header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use - # of this preprocessor symbol in `lldb` with its expansion. - # - # See here for some context: - # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 - ++ lib.optional ( - stdenv.targetPlatform.isDarwin - && !stdenv.targetPlatform.isAarch64 - && (lib.versionOlder darwin.apple_sdk.sdk.version "11.0") - ) ./cpu_subtype_arm64e_replacement.patch; - - outputs = [ "out" "lib" "dev" ]; - - nativeBuildInputs = [ - cmake ninja python3 which swig lit makeWrapper lua5_3 - ] ++ lib.optionals enableManpages [ - python3.pkgs.sphinx python3.pkgs.recommonmark - ]; - - buildInputs = [ - ncurses - zlib - libedit - libxml2 - libllvm - ] ++ lib.optionals stdenv.isDarwin [ - libobjc - xpc - Foundation - bootstrap_cmds - Carbon - Cocoa - ] - # The older libSystem used on x86_64 macOS is missing the - # `` header which `lldb` uses. - # - # We copy this header over from macOS 10.12 SDK. - # - # See here for context: - # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 - ++ lib.optional ( - stdenv.targetPlatform.isDarwin - && !stdenv.targetPlatform.isAarch64 - ) ( - runCommand "bsm-audit-session-header" { } '' - install -Dm444 \ - "${lib.getDev darwin.apple_sdk.sdk}/include/bsm/audit_session.h" \ - "$out/include/bsm/audit_session.h" - '' - ); - - hardeningDisable = [ "format" ]; - - cmakeFlags = [ - "-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}" - "-DLLVM_ENABLE_RTTI=OFF" - "-DClang_DIR=${libclang.dev}/lib/cmake" - "-DLLVM_EXTERNAL_LIT=${lit}/bin/lit" - ] ++ lib.optionals stdenv.isDarwin [ - "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON" - ] ++ lib.optionals (!stdenv.isDarwin) [ - "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic - ] ++ lib.optionals enableManpages [ - "-DLLVM_ENABLE_SPHINX=ON" - "-DSPHINX_OUTPUT_MAN=ON" - "-DSPHINX_OUTPUT_HTML=OFF" - - # docs reference `automodapi` but it's not added to the extensions list when - # only building the manpages: - # https://github.com/llvm/llvm-project/blob/af6ec9200b09039573d85e349496c4f5b17c3d7f/lldb/docs/conf.py#L54 - # - # so, we just ignore the resulting errors - "-DSPHINX_WARNINGS_AS_ERRORS=OFF" - ] ++ lib.optionals doCheck [ - "-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" - "-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++" - ]; - - doCheck = false; - - installCheckPhase = '' - if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then - return 1; - fi - ''; - - postInstall = '' - wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ - - # Editor support - # vscode: - install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json - mkdir -p $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin - ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin - ''; - - meta = llvm_meta // { - homepage = "https://lldb.llvm.org/"; - description = "A next-generation high-performance debugger"; - longDescription = '' - LLDB is a next generation, high-performance debugger. It is built as a set - of reusable components which highly leverage existing libraries in the - larger LLVM Project, such as the Clang expression parser and LLVM - disassembler. - ''; - }; -} // lib.optionalAttrs enableManpages { - pname = "lldb-manpages"; - - ninjaFlags = [ "docs-lldb-man" ]; - - propagatedBuildInputs = []; - - # manually install lldb man page - installPhase = '' - mkdir -p $out/share/man/man1 - install docs/man/lldb.1 -t $out/share/man/man1/ - ''; - - postPatch = null; - postInstall = null; - - outputs = [ "out" ]; - - doCheck = false; - - meta = llvm_meta // { - description = "man pages for LLDB ${version}"; - }; -}) diff --git a/pkgs/development/compilers/llvm/common/lldb.nix b/pkgs/development/compilers/llvm/common/lldb.nix new file mode 100644 index 000000000000..82ad9c304ea6 --- /dev/null +++ b/pkgs/development/compilers/llvm/common/lldb.nix @@ -0,0 +1,207 @@ +{ lib +, stdenv +, llvm_meta +, release_version +, cmake +, zlib +, ncurses +, swig +, which +, libedit +, libxml2 +, libllvm +, libclang +, python3 +, version +, darwin +, lit +, makeWrapper +, lua5_3 +, ninja +, runCommand +, src ? null +, monorepoSrc ? null +, patches ? [ ] +, enableManpages ? false +}: + +let + src' = + if monorepoSrc != null then + runCommand "lldb-src-${version}" { } '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/lldb "$out" + '' else src; +in + +stdenv.mkDerivation (rec { + passthru.monorepoSrc = monorepoSrc; + pname = "lldb"; + inherit version; + + src = src'; + inherit patches; + + outputs = [ "out" "lib" "dev" ]; + + sourceRoot = + if lib.versionOlder release_version "13" then null + else "${src.name}/${pname}"; + + nativeBuildInputs = [ + cmake + ] ++ lib.optionals (lib.versionAtLeast release_version "15") [ + ninja + ] ++ [ + python3 + which + swig + lit + makeWrapper + ] ++ lib.optionals (lib.versionAtLeast release_version "14") [ + lua5_3 + ] ++ lib.optionals enableManpages [ + python3.pkgs.sphinx + python3.pkgs.recommonmark + ]; + + buildInputs = [ + ncurses + zlib + libedit + libxml2 + libllvm + ] ++ lib.optionals stdenv.isDarwin [ + darwin.libobjc + darwin.apple_sdk.libs.xpc + darwin.apple_sdk.frameworks.Foundation + darwin.bootstrap_cmds + darwin.apple_sdk.frameworks.Carbon + darwin.apple_sdk.frameworks.Cocoa + ] + # The older libSystem used on x86_64 macOS is missing the + # `` header which `lldb` uses. + # + # We copy this header over from macOS 10.12 SDK. + # + # See here for context: + # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 + ++ lib.optional ( + stdenv.targetPlatform.isDarwin + && !stdenv.targetPlatform.isAarch64 + && (lib.versionAtLeast release_version "15") + ) ( + runCommand "bsm-audit-session-header" { } '' + install -Dm444 \ + "${lib.getDev darwin.apple_sdk.sdk}/include/bsm/audit_session.h" \ + "$out/include/bsm/audit_session.h" + '' + ); + + hardeningDisable = [ "format" ]; + + cmakeFlags = [ + "-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}" + "-DLLVM_ENABLE_RTTI=OFF" + "-DClang_DIR=${libclang.dev}/lib/cmake" + "-DLLVM_EXTERNAL_LIT=${lit}/bin/lit" + ] ++ lib.optionals stdenv.isDarwin [ + "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON" + ] ++ lib.optionals (!stdenv.isDarwin) [ + "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic + ] ++ lib.optionals enableManpages ([ + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + ] ++ lib.optionals (lib.versionAtLeast release_version "15") [ + # docs reference `automodapi` but it's not added to the extensions list when + # only building the manpages: + # https://github.com/llvm/llvm-project/blob/af6ec9200b09039573d85e349496c4f5b17c3d7f/lldb/docs/conf.py#L54 + # + # so, we just ignore the resulting errors + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + ]) ++ lib.optionals doCheck [ + "-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" + "-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++" + ]; + + doCheck = false; + + # TODO: cleanup with mass-rebuild + installCheckPhase = + if ((lib.versions.major release_version) == "14") then '' + if [ ! -e $lib/${python3.sitePackages}/lldb/_lldb*.so ] ; then + echo "ERROR: python files not installed where expected!"; + return 1; + fi + if [ ! -e "$lib/lib/lua/${lua5_3.luaversion}/lldb.so" ] ; then + echo "ERROR: lua files not installed where expected!"; + return 1; + fi + '' else if (((lib.versions.major release_version) == "15") || (lib.versions.major release_version) == "16") then '' + if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then + return 1; + fi + '' else '' + if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then + echo "ERROR: python files not installed where expected!"; + return 1; + fi + ''; + + postInstall = '' + wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ + + # Editor support + # vscode: + install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json + mkdir -p $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin + ln -s $out/bin/${if (lib.versionOlder release_version "12") then "llvm-vscode" else "lldb-vscode"} $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin + ''; + + meta = llvm_meta // { + homepage = "https://lldb.llvm.org/"; + description = "A next-generation high-performance debugger"; + longDescription = '' + LLDB is a next generation, high-performance debugger. It is built as a set + of reusable components which highly leverage existing libraries in the + larger LLVM Project, such as the Clang expression parser and LLVM + disassembler. + ''; + # llvm <10 never built on aarch64-darwin since first introduction in nixpkgs + broken = + (lib.versionOlder release_version "11" && stdenv.isDarwin && stdenv.isAarch64) + || (((lib.versions.major release_version) == "13") && stdenv.isDarwin); + }; +} // lib.optionalAttrs (lib.versionOlder release_version "15") { + doInstallCheck = true; +} // lib.optionalAttrs enableManpages { + pname = "lldb-manpages"; + + buildPhase = + if lib.versionOlder release_version "15" then '' + make ${if (lib.versionOlder release_version "12") then "docs-man" else "docs-lldb-man"} + '' else null; + + ninjaFlags = if lib.versionAtLeast release_version "15" then [ "docs-lldb-man" ] else null; + + propagatedBuildInputs = [ ]; + + # manually install lldb man page + installPhase = '' + mkdir -p $out/share/man/man1 + install docs/man/lldb.1 -t $out/share/man/man1/ + ''; + + postPatch = null; + postInstall = null; + + outputs = [ "out" ]; + + doCheck = false; + + meta = llvm_meta // { + description = "man pages for LLDB ${version}"; + }; +}) -- cgit 1.4.1