Merge pull request #173889 from IvarWithoutBones/fix/dotnet-cross

dotnet ecosystem: fix cross compilation
This commit is contained in:
Rick van Schijndel 2022-07-16 12:37:11 +02:00 committed by GitHub
commit e243499338
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 13 deletions

View file

@ -96,9 +96,13 @@ in stdenvNoCC.mkDerivation (args // {
dotnetInstallHook
dotnetFixupHook
dotnet-sdk
cacert
makeWrapper
dotnet-sdk
];
makeWrapperArgs = args.makeWrapperArgs or [ ] ++ [
"--prefix LD_LIBRARY_PATH : ${dotnet-sdk.icu}/lib"
];
# Stripping breaks the executable

View file

@ -56,7 +56,7 @@ in
dotnetFixupHook = callPackage ({ }:
makeSetupHook {
name = "dotnet-fixup-hook";
deps = [ dotnet-runtime makeWrapper ];
deps = [ dotnet-runtime ];
substitutions = {
dotnetRuntime = dotnet-runtime;
runtimeDeps = libraryPath;

View file

@ -1,6 +1,6 @@
declare -a projectFile testProjectFile
# inherit arguments from derivation
# Inherit arguments from derivation
dotnetFlags=( ${dotnetFlags[@]-} )
dotnetRestoreFlags=( ${dotnetRestoreFlags[@]-} )

View file

@ -4,12 +4,14 @@
, icu #passing icu as an argument, because dotnet 3.1 has troubles with icu71
}:
assert builtins.elem type [ "aspnetcore" "runtime" "sdk"];
assert builtins.elem type [ "aspnetcore" "runtime" "sdk" ];
{ lib
, stdenv
, fetchurl
, writeText
, autoPatchelfHook
, makeWrapper
, libunwind
, openssl
, libuuid
@ -19,19 +21,21 @@ assert builtins.elem type [ "aspnetcore" "runtime" "sdk"];
}:
let
pname = if type == "aspnetcore" then
"aspnetcore-runtime"
else if type == "runtime" then
"dotnet-runtime"
else
"dotnet-sdk";
pname =
if type == "aspnetcore" then
"aspnetcore-runtime"
else if type == "runtime" then
"dotnet-runtime"
else
"dotnet-sdk";
descriptions = {
aspnetcore = "ASP.NET Core Runtime ${version}";
runtime = ".NET Runtime ${version}";
sdk = ".NET SDK ${version}";
};
in stdenv.mkDerivation rec {
in
stdenv.mkDerivation rec {
inherit pname version;
# Some of these dependencies are `dlopen()`ed.
@ -47,8 +51,19 @@ in stdenv.mkDerivation rec {
lttng-ust_2_12
]);
src = fetchurl (srcs."${stdenv.hostPlatform.system}" or (throw
"Missing source (url and hash) for host system: ${stdenv.hostPlatform.system}"));
nativeBuildInputs = [
autoPatchelfHook
makeWrapper
];
buildInputs = [
stdenv.cc.cc
];
src = fetchurl (
srcs."${stdenv.hostPlatform.system}" or (throw
"Missing source (url and hash) for host system: ${stdenv.hostPlatform.system}")
);
sourceRoot = ".";
@ -68,10 +83,16 @@ in stdenv.mkDerivation rec {
patchelf --set-rpath "${rpath}" $out/dotnet
find $out -type f -name "*.so" -exec patchelf --set-rpath '$ORIGIN:${rpath}' {} \;
find $out -type f \( -name "apphost" -or -name "createdump" \) -exec patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" --set-rpath '$ORIGIN:${rpath}' {} \;
wrapProgram $out/bin/dotnet \
--prefix LD_LIBRARY_PATH : ${icu}/lib
'';
doInstallCheck = true;
installCheckPhase = ''
# Fixes cross
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
$out/bin/dotnet --info
'';
@ -85,6 +106,10 @@ in stdenv.mkDerivation rec {
export DOTNET_CLI_TELEMETRY_OPTOUT=1
'';
passthru = {
inherit icu;
};
meta = with lib; {
description = builtins.getAttr type descriptions;
homepage = "https://dotnet.github.io/";