Merge pull request #230387 from Artturin/llvmsplit1

This commit is contained in:
Artturi 2023-06-20 16:43:41 +03:00 committed by GitHub
commit 289d9cf8a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 242 additions and 1002 deletions

View File

@ -131,8 +131,13 @@ let
inherit llvm_meta; inherit llvm_meta;
}; };
lldb = callPackage ./lldb { lldb = callPackage ../common/lldb.nix {
inherit llvm_meta; 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 # Below, is the LLVM bootstrapping logic. It handles building a

View File

@ -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}";
};
})

View File

@ -146,8 +146,13 @@ let
inherit llvm_meta; inherit llvm_meta;
}; };
lldb = callPackage ./lldb { lldb = callPackage ../common/lldb.nix {
inherit llvm_meta; 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 # Below, is the LLVM bootstrapping logic. It handles building a

View File

@ -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}";
};
})

View File

@ -135,11 +135,23 @@ let
inherit (libraries) libunwind; inherit (libraries) libunwind;
}; };
lldb = callPackage ./lldb { lldb = callPackage ../common/lldb.nix {
inherit llvm_meta; src = fetch "lldb" "0g3pj1m3chafavpr35r9fynm85y2hdyla6klj0h28khxs2613i78";
inherit (darwin) libobjc bootstrap_cmds; patches =
inherit (darwin.apple_sdk.libs) xpc; let
inherit (darwin.apple_sdk.frameworks) Foundation Carbon Cocoa; 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 # Below, is the LLVM bootstrapping logic. It handles building a

View File

@ -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}";
};
})

View File

@ -135,11 +135,36 @@ let
inherit llvm_meta; inherit llvm_meta;
}; };
lldb = callPackage ./lldb { lldb = callPackage ../common/lldb.nix {
inherit llvm_meta; patches =
inherit (darwin) libobjc bootstrap_cmds; let
inherit (darwin.apple_sdk.libs) xpc; resourceDirPatch = callPackage ({ runCommand, libclang }: (runCommand "resource-dir.patch"
inherit (darwin.apple_sdk.frameworks) Foundation Carbon Cocoa; {
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 # Below, is the LLVM bootstrapping logic. It handles building a

View File

@ -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}";
};
})

View File

@ -136,11 +136,36 @@ let
inherit llvm_meta; inherit llvm_meta;
}; };
lldb = callPackage ./lldb { lldb = callPackage ../common/lldb.nix {
inherit llvm_meta; patches =
inherit (darwin) libobjc bootstrap_cmds; let
inherit (darwin.apple_sdk.libs) xpc; resourceDirPatch = callPackage ({ runCommand, libclang }: (runCommand "resource-dir.patch"
inherit (darwin.apple_sdk.frameworks) Foundation Carbon Cocoa; {
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 # Below, is the LLVM bootstrapping logic. It handles building a

View File

@ -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}";
};
})

View File

@ -184,11 +184,36 @@ in let
inherit llvm_meta; inherit llvm_meta;
}; };
lldb = callPackage ./lldb { lldb = callPackage ../common/lldb.nix {
inherit llvm_meta; patches =
inherit (darwin) libobjc bootstrap_cmds; let
inherit (darwin.apple_sdk.libs) xpc; resourceDirPatch = callPackage ({ runCommand, libclang }: (runCommand "resource-dir.patch"
inherit (darwin.apple_sdk.frameworks) Foundation Carbon Cocoa; {
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 # Below, is the LLVM bootstrapping logic. It handles building a

View File

@ -184,11 +184,41 @@ in let
inherit llvm_meta; inherit llvm_meta;
}; };
lldb = callPackage ./lldb { lldb = callPackage ../common/lldb.nix {
inherit llvm_meta; src = callPackage ({ runCommand }: runCommand "lldb-src-${version}" {} ''
inherit (darwin) libobjc bootstrap_cmds; mkdir -p "$out"
inherit (darwin.apple_sdk.libs) xpc; cp -r ${monorepoSrc}/cmake "$out"
inherit (darwin.apple_sdk.frameworks) Foundation Carbon Cocoa; 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 # Below, is the LLVM bootstrapping logic. It handles building a

View File

@ -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
# `<bsm/audit_session.h>` 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}";
};
})

View File

@ -1,8 +1,8 @@
{ lib, stdenv, llvm_meta { lib
, runCommand , stdenv
, monorepoSrc , llvm_meta
, release_version
, cmake , cmake
, ninja
, zlib , zlib
, ncurses , ncurses
, swig , swig
@ -13,64 +13,57 @@
, libclang , libclang
, python3 , python3
, version , version
, libobjc , darwin
, xpc
, Foundation
, bootstrap_cmds
, Carbon
, Cocoa
, lit , lit
, makeWrapper , makeWrapper
, darwin
, enableManpages ? false
, lua5_3 , lua5_3
, ninja
, runCommand
, src ? null
, monorepoSrc ? null
, patches ? [ ]
, enableManpages ? false
}: }:
# TODO: we build the python bindings but don't expose them as a python package let
# TODO: expose the vscode extension? 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 { stdenv.mkDerivation (rec {
passthru.monorepoSrc = monorepoSrc;
pname = "lldb"; pname = "lldb";
inherit version; inherit version;
src = runCommand "${pname}-src-${version}" {} '' src = src';
mkdir -p "$out" inherit patches;
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" ]; outputs = [ "out" "lib" "dev" ];
sourceRoot =
if lib.versionOlder release_version "13" then null
else "${src.name}/${pname}";
nativeBuildInputs = [ nativeBuildInputs = [
cmake ninja python3 which swig lit makeWrapper lua5_3 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 [ ] ++ lib.optionals enableManpages [
python3.pkgs.sphinx python3.pkgs.recommonmark python3.pkgs.sphinx
python3.pkgs.recommonmark
]; ];
buildInputs = [ buildInputs = [
@ -80,12 +73,12 @@ stdenv.mkDerivation (rec {
libxml2 libxml2
libllvm libllvm
] ++ lib.optionals stdenv.isDarwin [ ] ++ lib.optionals stdenv.isDarwin [
libobjc darwin.libobjc
xpc darwin.apple_sdk.libs.xpc
Foundation darwin.apple_sdk.frameworks.Foundation
bootstrap_cmds darwin.bootstrap_cmds
Carbon darwin.apple_sdk.frameworks.Carbon
Cocoa darwin.apple_sdk.frameworks.Cocoa
] ]
# The older libSystem used on x86_64 macOS is missing the # The older libSystem used on x86_64 macOS is missing the
# `<bsm/audit_session.h>` header which `lldb` uses. # `<bsm/audit_session.h>` header which `lldb` uses.
@ -96,7 +89,8 @@ stdenv.mkDerivation (rec {
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
++ lib.optional ( ++ lib.optional (
stdenv.targetPlatform.isDarwin stdenv.targetPlatform.isDarwin
&& !stdenv.targetPlatform.isAarch64 && !stdenv.targetPlatform.isAarch64
&& (lib.versionAtLeast release_version "15")
) ( ) (
runCommand "bsm-audit-session-header" { } '' runCommand "bsm-audit-session-header" { } ''
install -Dm444 \ install -Dm444 \
@ -116,29 +110,45 @@ stdenv.mkDerivation (rec {
"-DLLDB_USE_SYSTEM_DEBUGSERVER=ON" "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON"
] ++ lib.optionals (!stdenv.isDarwin) [ ] ++ lib.optionals (!stdenv.isDarwin) [
"-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
] ++ lib.optionals enableManpages [ ] ++ lib.optionals enableManpages ([
"-DLLVM_ENABLE_SPHINX=ON" "-DLLVM_ENABLE_SPHINX=ON"
"-DSPHINX_OUTPUT_MAN=ON" "-DSPHINX_OUTPUT_MAN=ON"
"-DSPHINX_OUTPUT_HTML=OFF" "-DSPHINX_OUTPUT_HTML=OFF"
] ++ lib.optionals (lib.versionAtLeast release_version "15") [
# docs reference `automodapi` but it's not added to the extensions list when # docs reference `automodapi` but it's not added to the extensions list when
# only building the manpages: # only building the manpages:
# https://github.com/llvm/llvm-project/blob/af6ec9200b09039573d85e349496c4f5b17c3d7f/lldb/docs/conf.py#L54 # https://github.com/llvm/llvm-project/blob/af6ec9200b09039573d85e349496c4f5b17c3d7f/lldb/docs/conf.py#L54
# #
# so, we just ignore the resulting errors # so, we just ignore the resulting errors
"-DSPHINX_WARNINGS_AS_ERRORS=OFF" "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
] ++ lib.optionals doCheck [ ]) ++ lib.optionals doCheck [
"-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" "-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
"-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++" "-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"
]; ];
doCheck = false; doCheck = false;
installCheckPhase = '' # TODO: cleanup with mass-rebuild
if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then installCheckPhase =
return 1; if ((lib.versions.major release_version) == "14") then ''
fi 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 = '' postInstall = ''
wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/
@ -147,7 +157,7 @@ stdenv.mkDerivation (rec {
# vscode: # vscode:
install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json 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 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 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 // { meta = llvm_meta // {
@ -159,13 +169,24 @@ stdenv.mkDerivation (rec {
larger LLVM Project, such as the Clang expression parser and LLVM larger LLVM Project, such as the Clang expression parser and LLVM
disassembler. 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 { } // lib.optionalAttrs enableManpages {
pname = "lldb-manpages"; pname = "lldb-manpages";
ninjaFlags = [ "docs-lldb-man" ]; buildPhase =
if lib.versionOlder release_version "15" then ''
make ${if (lib.versionOlder release_version "12") then "docs-man" else "docs-lldb-man"}
'' else null;
propagatedBuildInputs = []; ninjaFlags = if lib.versionAtLeast release_version "15" then [ "docs-lldb-man" ] else null;
propagatedBuildInputs = [ ];
# manually install lldb man page # manually install lldb man page
installPhase = '' installPhase = ''