From 86412523f5fa23646f82647bd6e2b9f3d72d4863 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Mon, 23 Sep 2024 19:24:00 -0400 Subject: [PATCH] dotnetCorePackages.dotnet_{8,9}: ensure build can find the Swift overlay Clang should find the Swift overlay, but clang in nixpkgs does not include any path under `/usr` in its search paths unless that path is added manually as a normal search path (as done here). --- pkgs/development/compilers/dotnet/patch-nupkgs.nix | 1 + pkgs/development/compilers/dotnet/vmr.nix | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/pkgs/development/compilers/dotnet/patch-nupkgs.nix b/pkgs/development/compilers/dotnet/patch-nupkgs.nix index 6885d8df71f3..09fd8342368a 100644 --- a/pkgs/development/compilers/dotnet/patch-nupkgs.nix +++ b/pkgs/development/compilers/dotnet/patch-nupkgs.nix @@ -85,6 +85,7 @@ writeShellScriptBin "patch-nupkgs" ( pushd "$x" sed -i 's: -no_code_signature_warning::g' build/Microsoft.NETCore.Native.targets sed -i 's:Include="-ld_classic"::g' build/Microsoft.NETCore.Native.Unix.targets + sed -i 's:-L/usr/lib/swift:-L$(SDKROOT)/usr/lib/swift:g' build/Microsoft.NETCore.Native.Unix.targets touch .nix-patched-ilcompiler popd done diff --git a/pkgs/development/compilers/dotnet/vmr.nix b/pkgs/development/compilers/dotnet/vmr.nix index 2c95d7d6ee6b..d1385b4c3cac 100644 --- a/pkgs/development/compilers/dotnet/vmr.nix +++ b/pkgs/development/compilers/dotnet/vmr.nix @@ -293,6 +293,15 @@ stdenv.mkDerivation rec { -s \$prev -t elem -n SkipInstallerBuild -v true \ src/runtime/Directory.Build.props + # Make sure .NET uses the Swift overlay for the SDK active in the build environment. + substituteInPlace \ + src/runtime/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets \ + --replace-fail '-L/usr/lib/swift' '-L$(SDKROOT)/usr/lib/swift' + + substituteInPlace \ + src/runtime/src/native/libs/System.Security.Cryptography.Native.Apple/extra_libs.cmake \ + --replace-fail '-L/usr/lib/swift' '-L''${CMAKE_OSX_SYSROOT}/usr/lib/swift' + # stop passing -sdk without a path # stop using xcrun # add -module-cache-path to fix swift errors, see sandboxProfile