about summary refs log tree commit diff
path: root/pkgs/development/tools/misc/netcoredbg
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/tools/misc/netcoredbg')
-rw-r--r--pkgs/development/tools/misc/netcoredbg/arm64.patch26
-rw-r--r--pkgs/development/tools/misc/netcoredbg/darwin.patch17
-rw-r--r--pkgs/development/tools/misc/netcoredbg/default.nix55
-rw-r--r--pkgs/development/tools/misc/netcoredbg/deps.nix13
-rw-r--r--pkgs/development/tools/misc/netcoredbg/limits.patch12
-rwxr-xr-xpkgs/development/tools/misc/netcoredbg/update.sh37
6 files changed, 127 insertions, 33 deletions
diff --git a/pkgs/development/tools/misc/netcoredbg/arm64.patch b/pkgs/development/tools/misc/netcoredbg/arm64.patch
new file mode 100644
index 0000000000000..ac057798c2486
--- /dev/null
+++ b/pkgs/development/tools/misc/netcoredbg/arm64.patch
@@ -0,0 +1,26 @@
+diff --git a/platformdefinitions.cmake b/platformdefinitions.cmake
+index ed3d9f6..6b0628f 100644
+--- a/platformdefinitions.cmake
++++ b/platformdefinitions.cmake
+@@ -7,17 +7,21 @@ if (CLR_CMAKE_PLATFORM_ARCH_AMD64)
+   add_definitions(-DAMD64)
+   add_definitions(-DBIT64=1)          # CoreClr <= 3.x
+   add_definitions(-DHOST_64BIT=1)     # CoreClr > 3.x
++  add_definitions(-DHOST_AMD64)
+ elseif (CLR_CMAKE_PLATFORM_ARCH_I386)
+   add_definitions(-D_X86_)
++  add_definitions(-DHOST_X86)
+ elseif (CLR_CMAKE_PLATFORM_ARCH_ARM)
+   add_definitions(-D_ARM_)
+   add_definitions(-DARM)
++  add_definitions(-DHOST_ARM)
+ elseif (CLR_CMAKE_PLATFORM_ARCH_ARM64)
+   add_definitions(-D_ARM64_)
+   add_definitions(-DARM64)
+   add_definitions(-D_WIN64)
+   add_definitions(-DBIT64=1)          # CoreClr <= 3.x
+   add_definitions(-DHOST_64BIT=1)     # CoreClr > 3.x
++  add_definitions(-DHOST_ARM64)
+ else ()
+   clr_unknown_arch()
+ endif ()
diff --git a/pkgs/development/tools/misc/netcoredbg/darwin.patch b/pkgs/development/tools/misc/netcoredbg/darwin.patch
new file mode 100644
index 0000000000000..ece3e51554f2b
--- /dev/null
+++ b/pkgs/development/tools/misc/netcoredbg/darwin.patch
@@ -0,0 +1,17 @@
+diff --git a/detectplatform.cmake b/detectplatform.cmake
+index 7b93bbf..6fa6e9e 100644
+--- a/detectplatform.cmake
++++ b/detectplatform.cmake
+@@ -56,7 +56,11 @@ endif(CMAKE_SYSTEM_NAME STREQUAL Linux)
+ 
+ if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
+   set(CLR_CMAKE_PLATFORM_UNIX 1)
+-  set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
++  if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
++     set(CLR_CMAKE_PLATFORM_UNIX_ARM64 1)
++   else()
++     set(CLR_CMAKE_PLATFORM_UNIX_AMD64 1)
++   endif()
+   set(CLR_CMAKE_PLATFORM_DARWIN 1)
+   if(CMAKE_VERSION VERSION_LESS "3.4.0")
+     set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} <FLAGS> <DEFINES> -o <OBJECT> -c <SOURCE>")
diff --git a/pkgs/development/tools/misc/netcoredbg/default.nix b/pkgs/development/tools/misc/netcoredbg/default.nix
index 6ea15d74d8cf2..e907bc5c41995 100644
--- a/pkgs/development/tools/misc/netcoredbg/default.nix
+++ b/pkgs/development/tools/misc/netcoredbg/default.nix
@@ -1,45 +1,44 @@
-{ lib, clangStdenv, stdenvNoCC, cmake, fetchFromGitHub, dotnetCorePackages, buildDotnetModule }:
+{ lib, clangStdenv, stdenv, cmake, autoPatchelfHook, fetchFromGitHub, dotnetCorePackages, buildDotnetModule }:
 let
   pname = "netcoredbg";
-  version = "2.0.0-895";
+  version = "2.2.0-961";
+  hash = "0gbjm8x40hzf787kccfxqb2wdgfks81f6hzr6rrmid42s4bfs5w7";
 
-  # according to CMakeLists.txt, this should be 3.1 even when building for .NET 5
-  coreclr-version = "3.1.19";
+  coreclr-version = "release/7.0";
   coreclr-src = fetchFromGitHub {
     owner = "dotnet";
-    repo = "coreclr";
-    rev = "v${coreclr-version}";
-    sha256 = "o1KafmXqNjX9axr6sSxPKrfUX0e+b/4ANiVQt4T2ybw=";
+    repo = "runtime";
+    rev = coreclr-version;
+    sha256 = "sha256-kBYb0Uw1IzDTpsEyd02/5sliVHoLmZdGnpybneV0u7U=";
   };
 
-  dotnet-sdk = dotnetCorePackages.sdk_6_0;
+  dotnet-sdk = dotnetCorePackages.sdk_7_0;
 
   src = fetchFromGitHub {
     owner = "Samsung";
     repo = pname;
     rev = version;
-    sha256 = "sha256-zOfChuNjD6py6KD1AmN5DgCGxD2YNH9gTyageoiN8PU=";
+    sha256 = hash;
   };
 
-  unmanaged = clangStdenv.mkDerivation rec {
+  unmanaged = clangStdenv.mkDerivation {
     inherit src pname version;
 
-    patches = [ ./limits.patch ];
+    # patch for arm from: https://github.com/Samsung/netcoredbg/pull/103#issuecomment-1446375535
+    # needed until https://github.com/dotnet/runtime/issues/78286 is resolved
+    # patch for darwin from: https://github.com/Samsung/netcoredbg/pull/103#issuecomment-1446457522
+    # needed until: ?
+    patches = [ ./arm64.patch ./darwin.patch ];
     nativeBuildInputs = [ cmake dotnet-sdk ];
 
     hardeningDisable = [ "strictoverflow" ];
 
     preConfigure = ''
       export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
-      dotnetVersion="$(${dotnet-sdk}/bin/dotnet --list-runtimes | grep -Po '^Microsoft.NETCore.App \K.*?(?= )')"
-
-      cmakeFlagsArray+=(
-        "-DDBGSHIM_RUNTIME_DIR=${dotnet-sdk}/shared/Microsoft.NETCore.App/$dotnetVersion"
-      )
     '';
 
     cmakeFlags = [
-      "-DCORECLR_DIR=${coreclr-src}"
+      "-DCORECLR_DIR=${coreclr-src}/src/coreclr"
       "-DDOTNET_DIR=${dotnet-sdk}"
       "-DBUILD_MANAGED=0"
     ];
@@ -51,21 +50,35 @@ let
     projectFile = "src/managed/ManagedPart.csproj";
     nugetDeps = ./deps.nix;
 
+    # include platform-specific dbgshim binary in nugetDeps
+    dotnetFlags = [ "-p:UseDbgShimDependency=true" ];
     executables = [ ];
+
+    # this passes RID down to dotnet build command
+    # and forces dotnet to include binary dependencies in the output (libdbgshim)
+    selfContainedBuild = true;
   };
 in
-stdenvNoCC.mkDerivation {
+stdenv.mkDerivation rec {
   inherit pname version;
+  # managed brings external binaries (libdbgshim.*)
+  # include source here so that autoPatchelfHook can do it's job
+  src = managed;
 
-  buildCommand = ''
+  nativeBuildInputs = lib.optionals stdenv.isLinux [ autoPatchelfHook ];
+  buildInputs = lib.optionals stdenv.isLinux [ stdenv.cc.cc.lib ];
+  installPhase = ''
     mkdir -p $out/share/netcoredbg $out/bin
     cp ${unmanaged}/* $out/share/netcoredbg
-    cp ${managed}/lib/netcoredbg/* $out/share/netcoredbg
-    ln -s $out/share/netcoredbg/netcoredbg $out/bin/netcoredbg
+    cp ./lib/netcoredbg/* $out/share/netcoredbg
+    # darwin won't work unless we link all files
+    ln -s $out/share/netcoredbg/* "$out/bin/"
   '';
 
   passthru = {
     inherit (managed) fetch-deps;
+
+    updateScript = [ ./update.sh pname version meta.homepage ];
   };
 
   meta = with lib; {
diff --git a/pkgs/development/tools/misc/netcoredbg/deps.nix b/pkgs/development/tools/misc/netcoredbg/deps.nix
index 8d311ab7f8bd6..a073c98d5d435 100644
--- a/pkgs/development/tools/misc/netcoredbg/deps.nix
+++ b/pkgs/development/tools/misc/netcoredbg/deps.nix
@@ -8,6 +8,19 @@
   (fetchNuGet { pname = "Microsoft.CodeAnalysis.CSharp.Scripting"; version = "2.3.0"; sha256 = "121dhnfjd5jzm410dk79s8xk5jvd09xa0w5q3lbpqc7bs4wxmq4p"; })
   (fetchNuGet { pname = "Microsoft.CodeAnalysis.Scripting.Common"; version = "2.3.0"; sha256 = "11f11kvgrdgs86ykz4104jx1iw78v6af48hpdrhmr7y7h5334ziq"; })
   (fetchNuGet { pname = "Microsoft.CSharp"; version = "4.4.0"; sha256 = "1niyzqqfyhvh4zpxn8bcyyldynqlw0rfr1apwry4b3yrdnjh1hhh"; })
+  (fetchNuGet { pname = "Microsoft.Diagnostics.DbgShim"; version = "7.0.410101"; sha256 = "0az67ay2977gyksh039lamap2a7jcr4c8df4imqrdaqx1ksir993"; })
+  (fetchNuGet { pname = "Microsoft.Diagnostics.DbgShim.linux-arm"; version = "7.0.410101"; sha256 = "1x5iilp2436w2pjp9c29xwj6vlq4z43qhprz35yxvfzhg0vdsg0l"; })
+  (fetchNuGet { pname = "Microsoft.Diagnostics.DbgShim.linux-arm64"; version = "7.0.410101"; sha256 = "1zbrcr5iydbbyb48w2wksbckjgddd74z6xczcsb5b0gvyqra85sn"; })
+  (fetchNuGet { pname = "Microsoft.Diagnostics.DbgShim.linux-musl-arm"; version = "7.0.410101"; sha256 = "179xp33f6aaaf775m673ij1zzrkfk7a07jmm7hcna9nb4ils04yg"; })
+  (fetchNuGet { pname = "Microsoft.Diagnostics.DbgShim.linux-musl-arm64"; version = "7.0.410101"; sha256 = "0gjyw14ppwsy22c0f0ckxj6gan8gq8sk564bm762jgbvpj9w6br2"; })
+  (fetchNuGet { pname = "Microsoft.Diagnostics.DbgShim.linux-musl-x64"; version = "7.0.410101"; sha256 = "00yk3b7pygprgm53nlv9l6grrbykrv6dg27jmhw431dnv978wcqd"; })
+  (fetchNuGet { pname = "Microsoft.Diagnostics.DbgShim.linux-x64"; version = "7.0.410101"; sha256 = "1k3182xh0a6fc8j5vspi0qx75has4gwydcr2hrbrapc2x850xq0z"; })
+  (fetchNuGet { pname = "Microsoft.Diagnostics.DbgShim.osx-arm64"; version = "7.0.410101"; sha256 = "06mqqj2bpvqqaxh0hfa580m6db213zy349k0x8ah34whzp3bgphk"; })
+  (fetchNuGet { pname = "Microsoft.Diagnostics.DbgShim.osx-x64"; version = "7.0.410101"; sha256 = "0yxlb8k935i0yc3cxl996bnk86b4qghlqmmjrv4s8mc5qai351ws"; })
+  (fetchNuGet { pname = "Microsoft.Diagnostics.DbgShim.win-arm"; version = "7.0.410101"; sha256 = "10ad931l9vrz3sc4xjyndak8p3wi5gl92r37yp7smjx8ik09azma"; })
+  (fetchNuGet { pname = "Microsoft.Diagnostics.DbgShim.win-arm64"; version = "7.0.410101"; sha256 = "1xd85r13qbk6awbrnp2q4a5vvcpwl7rw62s404rxrl4ghy2a43xz"; })
+  (fetchNuGet { pname = "Microsoft.Diagnostics.DbgShim.win-x64"; version = "7.0.410101"; sha256 = "1zlamjlv1s4d40sf08bbr6c7157lgchcla9x2g911ac0mnh8qqbf"; })
+  (fetchNuGet { pname = "Microsoft.Diagnostics.DbgShim.win-x86"; version = "7.0.410101"; sha256 = "0sk3akxgb1vw03fkj59m3n90j6v0a5g4px83h2llda8p5q729zbr"; })
   (fetchNuGet { pname = "Microsoft.NETCore.Platforms"; version = "1.1.0"; sha256 = "08vh1r12g6ykjygq5d3vq09zylgb84l63k49jc4v8faw9g93iqqm"; })
   (fetchNuGet { pname = "Microsoft.NETCore.Targets"; version = "1.1.0"; sha256 = "193xwf33fbm0ni3idxzbr5fdq3i2dlfgihsac9jj7whj0gd902nh"; })
   (fetchNuGet { pname = "NETStandard.Library"; version = "2.0.3"; sha256 = "1fn9fxppfcg4jgypp2pmrpr6awl3qz1xmnri0cygpkwvyx27df1y"; })
diff --git a/pkgs/development/tools/misc/netcoredbg/limits.patch b/pkgs/development/tools/misc/netcoredbg/limits.patch
deleted file mode 100644
index 8a2dcced32c5b..0000000000000
--- a/pkgs/development/tools/misc/netcoredbg/limits.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/src/debugger/frames.cpp b/src/debugger/frames.cpp
-index 534936b..21366f9 100644
---- a/src/debugger/frames.cpp
-+++ b/src/debugger/frames.cpp
-@@ -9,6 +9,7 @@
- #include "utils/platform.h"
- #include "utils/logger.h"
- #include "utils/torelease.h"
-+#include <limits>
- 
- namespace netcoredbg
- {
diff --git a/pkgs/development/tools/misc/netcoredbg/update.sh b/pkgs/development/tools/misc/netcoredbg/update.sh
new file mode 100755
index 0000000000000..a4dbb8f0291d4
--- /dev/null
+++ b/pkgs/development/tools/misc/netcoredbg/update.sh
@@ -0,0 +1,37 @@
+#! /usr/bin/env nix-shell
+#! nix-shell -I nixpkgs=./. -i bash -p common-updater-scripts
+# shellcheck shell=bash
+
+set -euo pipefail
+
+pname=$1
+old_version=$2
+url=$3
+
+cd "$(dirname "${BASH_SOURCE[0]}")"
+
+deps_file="$(realpath "./deps.nix")"
+
+new_version="$(list-git-tags --url="$url" | sort --reverse --numeric-sort | head -n 1)"
+
+if [[ "$new_version" == "$old_version" ]]; then
+    echo "Already up to date!"
+    exit 0
+fi
+
+updateVersion() {
+    sed -i "s/version = \"$old_version\";/version = \"$new_version\";/g" default.nix
+}
+
+updateHash() {
+    hashKey="hash"
+    hash=$(nix-prefetch-url --unpack --type sha256 "$url/archive/$new_version.tar.gz")
+    sed -i "s|$hashKey = \"[a-zA-Z0-9\/+-=]*\";|$hashKey = \"$hash\";|g" default.nix
+}
+
+updateVersion
+updateHash
+
+cd ../../../../../
+
+$(nix-build -A "$pname".fetch-deps --no-out-link) "$deps_file"