Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llvmPackages.lldb: use substituteAll #253533

Merged
merged 4 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkgs/development/compilers/llvm/10/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ let
./lldb/procfs.patch
./lldb/gnu-install-dirs.patch
];
inherit llvm_meta release_version;
inherit llvm_meta;
};

# Below, is the LLVM bootstrapping logic. It handles building a
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/llvm/11/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ let
./lldb/procfs.patch
./lldb/gnu-install-dirs.patch
];
inherit llvm_meta release_version;
inherit llvm_meta;
};

# Below, is the LLVM bootstrapping logic. It handles building a
Expand Down
15 changes: 8 additions & 7 deletions pkgs/development/compilers/llvm/12/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,20 @@ let
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
'')) { };
resourceDirPatch = callPackage
({ substituteAll, libclang }: substituteAll
{
src = ./lldb/resource-dir.patch;
clangLibDir = "${libclang.lib}/lib";
})
{ };
in
[
./lldb/procfs.patch
resourceDirPatch
./lldb/gnu-install-dirs.patch
];
inherit llvm_meta release_version;
inherit llvm_meta;
};

# Below, is the LLVM bootstrapping logic. It handles building a
Expand Down
15 changes: 8 additions & 7 deletions pkgs/development/compilers/llvm/13/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,13 @@ let
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
'')) { };
resourceDirPatch = callPackage
({ substituteAll, libclang }: substituteAll
{
src = ./lldb/resource-dir.patch;
clangLibDir = "${libclang.lib}/lib";
})
{ };
in
[
./lldb/procfs.patch
Expand All @@ -164,7 +165,7 @@ let
&& !stdenv.targetPlatform.isAarch64
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
) ./lldb/cpu_subtype_arm64e_replacement.patch;
inherit llvm_meta release_version;
inherit llvm_meta;
};

# Below, is the LLVM bootstrapping logic. It handles building a
Expand Down
15 changes: 8 additions & 7 deletions pkgs/development/compilers/llvm/14/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,13 @@ let
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
'')) { };
resourceDirPatch = callPackage
({ substituteAll, libclang }: substituteAll
{
src = ./lldb/resource-dir.patch;
clangLibDir = "${libclang.lib}/lib";
})
{ };
in
[
./lldb/procfs.patch
Expand All @@ -165,7 +166,7 @@ let
&& !stdenv.targetPlatform.isAarch64
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
) ./lldb/cpu_subtype_arm64e_replacement.patch;
inherit llvm_meta release_version;
inherit llvm_meta;
};

# Below, is the LLVM bootstrapping logic. It handles building a
Expand Down
15 changes: 8 additions & 7 deletions pkgs/development/compilers/llvm/15/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,13 @@ in let
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
'')) { };
resourceDirPatch = callPackage
({ substituteAll, libclang }: substituteAll
{
src = ./lldb/resource-dir.patch;
clangLibDir = "${libclang.lib}/lib";
})
{ };
in
[
./lldb/procfs.patch
Expand All @@ -213,7 +214,7 @@ in let
&& !stdenv.targetPlatform.isAarch64
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
) ./lldb/cpu_subtype_arm64e_replacement.patch;
inherit llvm_meta release_version;
inherit llvm_meta;
};

# Below, is the LLVM bootstrapping logic. It handles building a
Expand Down
15 changes: 8 additions & 7 deletions pkgs/development/compilers/llvm/16/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,13 @@ in let
'') { };
patches =
let
resourceDirPatch = callPackage ({ runCommand, libclang }: (runCommand "resource-dir.patch"
{
clangLibDir = "${libclang.lib}/lib";
} ''
substitute '${./lldb/resource-dir.patch}' "$out" --subst-var clangLibDir
'')) { };
resourceDirPatch = callPackage
({ substituteAll, libclang }: substituteAll
{
src = ./lldb/resource-dir.patch;
clangLibDir = "${libclang.lib}/lib";
})
{ };
in
[
# FIXME: do we need this? ./procfs.patch
Expand All @@ -218,7 +219,7 @@ in let
&& !stdenv.targetPlatform.isAarch64
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
) ./lldb/cpu_subtype_arm64e_replacement.patch;
inherit llvm_meta release_version;
inherit llvm_meta;
};

# Below, is the LLVM bootstrapping logic. It handles building a
Expand Down
69 changes: 29 additions & 40 deletions pkgs/development/compilers/llvm/common/lldb.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,21 @@ stdenv.mkDerivation (rec {

outputs = [ "out" "lib" "dev" ];

sourceRoot =
if lib.versionOlder release_version "13" then null
else "${src.name}/${pname}";
sourceRoot = lib.optional (lib.versionAtLeast release_version "13") "${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
] ++ lib.optionals (lib.versionAtLeast release_version "14") [
ninja
];

buildInputs = [
Expand All @@ -87,11 +83,13 @@ stdenv.mkDerivation (rec {
#
# See here for context:
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
++ lib.optional (
++ lib.optional
(
stdenv.targetPlatform.isDarwin
&& !stdenv.targetPlatform.isAarch64
&& (lib.versionAtLeast release_version "15")
) (
&& !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" \
Expand All @@ -104,7 +102,7 @@ stdenv.mkDerivation (rec {
cmakeFlags = [
"-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}"
"-DLLVM_ENABLE_RTTI=OFF"
"-DClang_DIR=${libclang.dev}/lib/cmake"
"-DClang_DIR=${lib.getDev libclang}/lib/cmake"
"-DLLVM_EXTERNAL_LIT=${lit}/bin/lit"
] ++ lib.optionals stdenv.isDarwin [
"-DLLDB_USE_SYSTEM_DEBUGSERVER=ON"
Expand All @@ -127,28 +125,21 @@ stdenv.mkDerivation (rec {
];

doCheck = false;
doInstallCheck = lib.versionOlder release_version "15";

# 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
'';
installCheckPhase = ''
if [ ! -e $lib/${python3.sitePackages}/lldb/_lldb*.so ] ; then
echo "ERROR: python files not installed where expected!";
return 1;
fi
'' # Something lua is built on older versions but this file doesn't exist.
+ lib.optionalString (lib.versionAtLeast release_version "14") ''
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}/
Expand All @@ -157,7 +148,7 @@ stdenv.mkDerivation (rec {
# 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
ln -s $out/bin/*-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
'';

meta = llvm_meta // {
Expand All @@ -174,17 +165,15 @@ stdenv.mkDerivation (rec {
(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;
buildPhase = lib.optionalString (lib.versionOlder release_version "15") ''
make ${if (lib.versionOlder release_version "12") then "docs-man" else "docs-lldb-man"}
'';


ninjaFlags = if lib.versionAtLeast release_version "15" then [ "docs-lldb-man" ] else null;
ninjaFlags = lib.optionals (lib.versionAtLeast release_version "15") [ "docs-lldb-man" ];

propagatedBuildInputs = [ ];

Expand Down
25 changes: 21 additions & 4 deletions pkgs/development/compilers/llvm/git/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,28 @@ in let
inherit llvm_meta;
};

lldb = callPackage ./lldb {
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
({ substituteAll, libclang }: substituteAll
{
src = ./lldb/resource-dir.patch;
clangLibDir = "${libclang.lib}/lib";
})
{ };
in
[
./lldb/procfs.patch # FIXME: do we need this?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is commented for llvm 16, git still uses 15

resourceDirPatch
./lldb/gnu-install-dirs.patch
];
inherit llvm_meta;
inherit (darwin) libobjc bootstrap_cmds;
inherit (darwin.apple_sdk.libs) xpc;
inherit (darwin.apple_sdk.frameworks) Foundation Carbon Cocoa;
};

# Below, is the LLVM bootstrapping logic. It handles building a
Expand Down
Loading