From 3e800aed3a8d36b3b9f72f7517ab3806e3cfd348 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 16 Oct 2023 13:32:40 -0400 Subject: [PATCH] Update to .NET 8 RC 2 Resolves: RHEL-13838 --- .gitignore | 1 + dotnet8.0.spec | 40 +-- fix-mono-typeloadexception.patch | 23 -- release.json | 10 +- ...e-91008-mono-var-opcode-OP_REGOFFSET.patch | 29 -- runtime-91865-arm64-page-size.patch | 39 --- runtime-92441-s390x-host-le.patch | 290 ------------------ sdk-35600-skip-windows-gui.patch | 32 -- sources | 2 +- 9 files changed, 24 insertions(+), 442 deletions(-) delete mode 100644 fix-mono-typeloadexception.patch delete mode 100644 runtime-91008-mono-var-opcode-OP_REGOFFSET.patch delete mode 100644 runtime-91865-arm64-page-size.patch delete mode 100644 runtime-92441-s390x-host-le.patch delete mode 100644 sdk-35600-skip-windows-gui.patch diff --git a/.gitignore b/.gitignore index 0fff16b..f11619d 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ /dotnet-prebuilts-8.0.100-rc.1.23410.12-ppc64le.tar.gz /dotnet-prebuilts-8.0.100-rc.1.23410.12-s390x.tar.gz /dotnet-v8.0.0-rc.1.23419.4.tar.gz +/dotnet-v8.0.0-rc.2.23479.6.tar.gz diff --git a/dotnet8.0.spec b/dotnet8.0.spec index ba75852..a2cf55a 100644 --- a/dotnet8.0.spec +++ b/dotnet8.0.spec @@ -8,22 +8,22 @@ %global dotnetver 8.0 -%global host_version 8.0.0-rc.1.23419.4 -%global runtime_version 8.0.0-rc.1.23419.4 -%global aspnetcore_runtime_version 8.0.0-rc.1.23421.29 -%global sdk_version 8.0.100-rc.1.23455.1 +%global host_version 8.0.0-rc.2.23475.17 +%global runtime_version 8.0.0-rc.2.23475.17 +%global aspnetcore_runtime_version 8.0.0-rc.2.23480.2 +%global sdk_version 8.0.100-rc.2.23502.1 %global sdk_feature_band_version %(echo %{sdk_version} | cut -d '-' -f 1 | sed -e 's|[[:digit:]][[:digit:]]$|00|') -%global templates_version 8.0.0-rc.1.23421.29 +%global templates_version 8.0.0-rc.2.23480.2 #%%global templates_version %%(echo %%{runtime_version} | awk 'BEGIN { FS="."; OFS="." } {print $1, $2, $3+1 }') # upstream can produce releases with a different tag than the SDK version -%global upstream_tag v8.0.0-rc.1.23419.4 +%global upstream_tag v8.0.0-rc.2.23479.6 %global upstream_tag_without_v %(echo %{upstream_tag} | sed -e 's|^v||') -%global host_rpm_version 8.0.0~rc.1 -%global runtime_rpm_version 8.0.0~rc.1 -%global aspnetcore_runtime_rpm_version 8.0.0~rc.1 -%global sdk_rpm_version 8.0.100~rc.1 +%global host_rpm_version 8.0.0~rc.2 +%global runtime_rpm_version 8.0.0~rc.2 +%global aspnetcore_runtime_rpm_version 8.0.0~rc.2 +%global sdk_rpm_version 8.0.100~rc.2 %if 0%{?fedora} || 0%{?rhel} < 8 %global use_bundled_libunwind 0 @@ -54,7 +54,7 @@ Name: dotnet%{dotnetver} Version: %{sdk_rpm_version} -Release: 0.5%{?dist} +Release: 0.1%{?dist} Summary: .NET Runtime and SDK License: 0BSD AND Apache-2.0 AND (Apache-2.0 WITH LLVM-exception) AND APSL-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause AND BSL-1.0 AND bzip2-1.0.6 AND CC0-1.0 AND CC-BY-3.0 AND CC-BY-4.0 AND CC-PDDC AND CNRI-Python AND EPL-1.0 AND GPL-2.0-only AND (GPL-2.0-only WITH GCC-exception-2.0) AND GPL-2.0-or-later AND GPL-3.0-only AND ICU AND ISC AND LGPL-2.1-only AND LGPL-2.1-or-later AND LicenseRef-Fedora-Public-Domain AND LicenseRef-ISO-8879 AND MIT AND MIT-Wu AND MS-PL AND MS-RL AND NCSA AND OFL-1.1 AND OpenSSL AND Unicode-DFS-2015 AND Unicode-DFS-2016 AND W3C-19980720 AND X11 AND Zlib @@ -90,18 +90,8 @@ Source21: dotnet.sh.in Patch1: roslyn-analyzers-ppc64le-apphost.patch # https://github.com/dotnet/source-build/discussions/3481 Patch2: vstest-intent-net8.0.patch -# https://github.com/dotnet/source-build/issues/3571 -Patch3: fix-mono-typeloadexception.patch -# https://github.com/dotnet/runtime/pull/91008 -Patch4: runtime-91008-mono-var-opcode-OP_REGOFFSET.patch -# https://github.com/dotnet/runtime/pull/91865 -Patch5: runtime-91865-arm64-page-size.patch # https://github.com/dotnet/runtime/pull/92274 -Patch6: runtime-92274-webcil-s390x.patch -# https://github.com/dotnet/runtime/pull/92441 -Patch7: runtime-92441-s390x-host-le.patch -# https://github.com/dotnet/sdk/pull/35600 -Patch8: sdk-35600-skip-windows-gui.patch +Patch3: runtime-92274-webcil-s390x.patch %if 0%{?fedora} || 0%{?rhel} >= 8 @@ -386,7 +376,7 @@ if [[ ${release_json_tag} != %{upstream_tag} ]]; then fi %if %{without bootstrap_dotnet} -%setup -q -n dotnet-%{upstream_tag} +%setup -q -n dotnet-%{upstream_tag_without_v} # Remove all prebuilts find -iname '*.dll' -type f -delete @@ -671,6 +661,10 @@ export COMPlus_LTTng=0 %changelog +* Mon Oct 16 2023 Omair Majid - 8.0.100~rc.2-0.1 +- Update to .NET 8 RC 2 +- Resolves: RHEL-13838 + * Fri Sep 29 2023 Omair Majid - 8.0.100~rc.1-0.5 - Disable bootstrap - Related: RHEL-2958 diff --git a/fix-mono-typeloadexception.patch b/fix-mono-typeloadexception.patch deleted file mode 100644 index 08b0917..0000000 --- a/fix-mono-typeloadexception.patch +++ /dev/null @@ -1,23 +0,0 @@ -From 02f6303d86672997ec2e6b79b16d5ddbf52118a0 Mon Sep 17 00:00:00 2001 -From: Tom Deseyn -Date: Tue, 22 Aug 2023 14:52:36 +0200 -Subject: [PATCH] Avoid loading System.Security.Permissions. - -source-built Mono fails to load types from this assembly. ---- - src/msbuild/src/Shared/ExceptionHandling.cs | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/msbuild/src/Shared/ExceptionHandling.cs b/src/msbuild/src/Shared/ExceptionHandling.cs -index a7ef74e873..3dce645df1 100644 ---- a/src/msbuild/src/Shared/ExceptionHandling.cs -+++ b/src/msbuild/src/Shared/ExceptionHandling.cs -@@ -167,7 +167,7 @@ internal static bool IsIoRelatedException(Exception e) - internal static bool IsXmlException(Exception e) - { - return e is XmlException -- || e is XmlSyntaxException -+ // || e is XmlSyntaxException - || e is XmlSchemaException - || e is UriFormatException; // XmlTextReader for example uses this under the covers - } diff --git a/release.json b/release.json index 0e58494..c2cfe24 100644 --- a/release.json +++ b/release.json @@ -1,9 +1,9 @@ { - "release": "8.0.0-rc.1", + "release": "8.0.0-rc.2", "channel": "8.0", - "tag": "v8.0.0-rc.1.23419.4", - "sdkVersion": "8.0.100-rc.1.23455.8", - "runtimeVersion": "8.0.0-rc.1.23419.4", + "tag": "v8.0.0-rc.2.23479.6", + "sdkVersion": "8.0.100-rc.2.23502.2", + "runtimeVersion": "8.0.0-rc.2.23479.6", "sourceRepository": "https://github.com/dotnet/dotnet", - "sourceVersion": "113d797bc90104bb4f1cc51e1a462cf3d4ef18fc" + "sourceVersion": "1e872358329855089d8d14cec1f06d5b075824b5" } diff --git a/runtime-91008-mono-var-opcode-OP_REGOFFSET.patch b/runtime-91008-mono-var-opcode-OP_REGOFFSET.patch deleted file mode 100644 index ac6eb6b..0000000 --- a/runtime-91008-mono-var-opcode-OP_REGOFFSET.patch +++ /dev/null @@ -1,29 +0,0 @@ -From a73b8bacfcc5819926bc05173ab2f7850eb00da3 Mon Sep 17 00:00:00 2001 -From: Ulrich Weigand -Date: Wed, 23 Aug 2023 21:11:37 +0200 -Subject: [PATCH] [mono] Handle enum return type when inlining CreateInstance - -Use underlying base type when deciding how to inline a -CreateInstance invocation in mini_emit_inst_for_method. - -Fixes https://github.com/dotnet/runtime/issues/90292 -(Mono abort causing .NET 8 msbuild regression). ---- - src/mono/mono/mini/intrinsics.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/src/runtime/src/mono/mono/mini/intrinsics.c b/src/runtime/src/mono/mono/mini/intrinsics.c -index b1e5e76723147..ef77b7dc89f2e 100644 ---- a/src/runtime/src/mono/mono/mini/intrinsics.c -+++ b//src/runtimesrc/mono/mono/mini/intrinsics.c -@@ -2079,7 +2079,9 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign - MonoType *t = method_context->method_inst->type_argv [0]; - MonoClass *arg0 = mono_class_from_mono_type_internal (t); - if (m_class_is_valuetype (arg0) && !mono_class_has_default_constructor (arg0, FALSE)) { -- if (m_class_is_primitive (arg0)) { -+ if (m_class_is_primitive (arg0) || m_class_is_enumtype (arg0)) { -+ if (m_class_is_enumtype (arg0)) -+ t = mono_class_enum_basetype_internal (arg0); - int dreg = alloc_dreg (cfg, mini_type_to_stack_type (cfg, t)); - mini_emit_init_rvar (cfg, dreg, t); - ins = cfg->cbb->last_ins; diff --git a/runtime-91865-arm64-page-size.patch b/runtime-91865-arm64-page-size.patch deleted file mode 100644 index 11b86b8..0000000 --- a/runtime-91865-arm64-page-size.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 7d3b041c09aa1d6cf532e64d24b75a7e5bd4d106 Mon Sep 17 00:00:00 2001 -From: Tom Deseyn -Date: Tue, 12 Sep 2023 07:43:45 +0200 -Subject: [PATCH] Limit special diagnostics size region to 4KiB. - -This fixes out-of-bounds access when trying to write the -diagnostics info on platforms where the PAGE_SIZE is larger -than the DumpWriter's 16KiB m_tempBuffer. ---- - src/coreclr/debug/createdump/crashinfo.cpp | 2 +- - src/coreclr/debug/createdump/specialdiaginfo.h | 2 ++ - 2 files changed, 3 insertions(+), 1 deletion(-) - -diff --git a/src/runtime/src/coreclr/debug/createdump/crashinfo.cpp b/src/runtime/src/coreclr/debug/createdump/crashinfo.cpp -index ef903767ba027..8af6ec4a54f5b 100644 ---- a/src/runtime/src/coreclr/debug/createdump/crashinfo.cpp -+++ b/src/runtime/src/coreclr/debug/createdump/crashinfo.cpp -@@ -195,7 +195,7 @@ CrashInfo::GatherCrashInfo(DumpType dumpType) - return false; - } - // Add the special (fake) memory region for the special diagnostics info -- MemoryRegion special(PF_R, SpecialDiagInfoAddress, SpecialDiagInfoAddress + PAGE_SIZE); -+ MemoryRegion special(PF_R, SpecialDiagInfoAddress, SpecialDiagInfoAddress + SpecialDiagInfoSize); - m_memoryRegions.insert(special); - #ifdef __APPLE__ - InitializeOtherMappings(); -diff --git a/src/runtime/src/coreclr/debug/createdump/specialdiaginfo.h b/src/runtime/src/coreclr/debug/createdump/specialdiaginfo.h -index 3a04a9f551e6d..a857129c9c91f 100644 ---- a/src/runtime/src/coreclr/debug/createdump/specialdiaginfo.h -+++ b/src/runtime/src/coreclr/debug/createdump/specialdiaginfo.h -@@ -24,6 +24,8 @@ const uint64_t SpecialDiagInfoAddress = 0x7fff1000; - #endif - #endif - -+const uint64_t SpecialDiagInfoSize = 0x1000; -+ - struct SpecialDiagInfoHeader - { - char Signature[16]; diff --git a/runtime-92441-s390x-host-le.patch b/runtime-92441-s390x-host-le.patch deleted file mode 100644 index acbc28f..0000000 --- a/runtime-92441-s390x-host-le.patch +++ /dev/null @@ -1,290 +0,0 @@ -From 0566e7dd9a7a8e5dec119d0ba715623beeba4c90 Mon Sep 17 00:00:00 2001 -From: Elinor Fung -Date: Wed, 20 Sep 2023 17:27:40 -0700 -Subject: [PATCH 1/2] Make HostModel PEUtils always read/write little endian - ---- - .../AppHost/PEUtils.cs | 26 ++++++++++++------- - 1 file changed, 16 insertions(+), 10 deletions(-) - -diff --git a/src/runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs b/src/runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs -index 0d0b33ed55569..e6142aba26e3e 100644 ---- a/src/runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs -+++ b/src/runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs -@@ -1,6 +1,8 @@ - // Licensed to the .NET Foundation under one or more agreements. - // The .NET Foundation licenses this file to you under the MIT license. - -+using System; -+using System.Buffers.Binary; - using System.IO; - using System.IO.MemoryMappedFiles; - -@@ -24,7 +26,9 @@ internal static unsafe bool IsPEImage(MemoryMappedViewAccessor accessor) - - // https://en.wikipedia.org/wiki/Portable_Executable - // Validate that we're looking at Windows PE file -- if (((ushort*)bytes)[0] != PEOffsets.DosImageSignature -+ ReadOnlySpan signatureBytes = new(bytes, sizeof(ushort)); -+ ushort signature = BinaryPrimitives.ReadUInt16LittleEndian(signatureBytes); -+ if (signature != PEOffsets.DosImageSignature - || accessor.Capacity < PEOffsets.DosStub.PESignatureOffset + sizeof(uint)) - { - return false; -@@ -68,24 +72,26 @@ internal static unsafe void SetWindowsGraphicalUserInterfaceBit(MemoryMappedView - byte* bytes = pointer + accessor.PointerOffset; - - // https://en.wikipedia.org/wiki/Portable_Executable -- uint peHeaderOffset = ((uint*)(bytes + PEOffsets.DosStub.PESignatureOffset))[0]; -+ ReadOnlySpan peHeaderOffsetBytes = new(bytes + PEOffsets.DosStub.PESignatureOffset, sizeof(uint)); -+ uint peHeaderOffset = BinaryPrimitives.ReadUInt32LittleEndian(peHeaderOffsetBytes); - - if (accessor.Capacity < peHeaderOffset + PEOffsets.PEHeader.Subsystem + sizeof(ushort)) - { - throw new AppHostNotPEFileException("Subsystem offset out of file range."); - } - -- ushort* subsystem = ((ushort*)(bytes + peHeaderOffset + PEOffsets.PEHeader.Subsystem)); -+ Span subsystemBytes = new(bytes + peHeaderOffset + PEOffsets.PEHeader.Subsystem, sizeof(ushort)); -+ ushort subsystem = BinaryPrimitives.ReadUInt16LittleEndian(subsystemBytes); - - // https://docs.microsoft.com/en-us/windows/desktop/Debug/pe-format#windows-subsystem - // The subsystem of the prebuilt apphost should be set to CUI -- if (subsystem[0] != (ushort)PEOffsets.Subsystem.WindowsCui) -+ if (subsystem != (ushort)PEOffsets.Subsystem.WindowsCui) - { -- throw new AppHostNotCUIException(subsystem[0]); -+ throw new AppHostNotCUIException(subsystem); - } - - // Set the subsystem to GUI -- subsystem[0] = (ushort)PEOffsets.Subsystem.WindowsGui; -+ BinaryPrimitives.WriteUInt16LittleEndian(subsystemBytes, (ushort)PEOffsets.Subsystem.WindowsGui); - } - finally - { -@@ -121,16 +127,16 @@ internal static unsafe ushort GetWindowsGraphicalUserInterfaceBit(MemoryMappedVi - byte* bytes = pointer + accessor.PointerOffset; - - // https://en.wikipedia.org/wiki/Portable_Executable -- uint peHeaderOffset = ((uint*)(bytes + PEOffsets.DosStub.PESignatureOffset))[0]; -+ ReadOnlySpan peHeaderOffsetBytes = new(bytes + PEOffsets.DosStub.PESignatureOffset, sizeof(uint)); -+ uint peHeaderOffset = BinaryPrimitives.ReadUInt32LittleEndian(peHeaderOffsetBytes); - - if (accessor.Capacity < peHeaderOffset + PEOffsets.PEHeader.Subsystem + sizeof(ushort)) - { - throw new AppHostNotPEFileException("Subsystem offset out of file range."); - } - -- ushort* subsystem = ((ushort*)(bytes + peHeaderOffset + PEOffsets.PEHeader.Subsystem)); -- -- return subsystem[0]; -+ ReadOnlySpan subsystemBytes = new(bytes + peHeaderOffset + PEOffsets.PEHeader.Subsystem, sizeof(ushort)); -+ return BinaryPrimitives.ReadUInt16LittleEndian(subsystemBytes); - } - finally - { - -From d39f18ecd6671748cc6baf57f141f94668cb5f9e Mon Sep 17 00:00:00 2001 -From: Elinor Fung -Date: Thu, 21 Sep 2023 10:45:36 -0700 -Subject: [PATCH 2/2] PR feeback - helper methods - ---- - .../AppHost/PEUtils.cs | 123 ++++++------------ - .../AppHostUpdateTests.cs | 6 +- - 2 files changed, 42 insertions(+), 87 deletions(-) - -diff --git a/src/runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs b/src/runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs -index e6142aba26e3e..1bfc80fcfca49 100644 ---- a/src/runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs -+++ b/src/runtime/src/installer/managed/Microsoft.NET.HostModel/AppHost/PEUtils.cs -@@ -5,6 +5,7 @@ - using System.Buffers.Binary; - using System.IO; - using System.IO.MemoryMappedFiles; -+using System.Reflection.PortableExecutable; - - namespace Microsoft.NET.HostModel.AppHost - { -@@ -17,31 +18,13 @@ public static class PEUtils - /// true if the accessor represents a PE image, false otherwise. - internal static unsafe bool IsPEImage(MemoryMappedViewAccessor accessor) - { -- byte* pointer = null; -+ if (accessor.Capacity < PEOffsets.DosStub.PESignatureOffset + sizeof(uint)) -+ return false; - -- try -- { -- accessor.SafeMemoryMappedViewHandle.AcquirePointer(ref pointer); -- byte* bytes = pointer + accessor.PointerOffset; -- -- // https://en.wikipedia.org/wiki/Portable_Executable -- // Validate that we're looking at Windows PE file -- ReadOnlySpan signatureBytes = new(bytes, sizeof(ushort)); -- ushort signature = BinaryPrimitives.ReadUInt16LittleEndian(signatureBytes); -- if (signature != PEOffsets.DosImageSignature -- || accessor.Capacity < PEOffsets.DosStub.PESignatureOffset + sizeof(uint)) -- { -- return false; -- } -- return true; -- } -- finally -- { -- if (pointer != null) -- { -- accessor.SafeMemoryMappedViewHandle.ReleasePointer(); -- } -- } -+ // https://en.wikipedia.org/wiki/Portable_Executable -+ // Validate that we're looking at Windows PE file -+ ushort signature = AsLittleEndian(accessor.ReadUInt16(0)); -+ return signature == PEOffsets.DosImageSignature; - } - - public static bool IsPEImage(string filePath) -@@ -64,42 +47,15 @@ public static bool IsPEImage(string filePath) - /// The memory accessor which has the apphost file opened. - internal static unsafe void SetWindowsGraphicalUserInterfaceBit(MemoryMappedViewAccessor accessor) - { -- byte* pointer = null; -- -- try -- { -- accessor.SafeMemoryMappedViewHandle.AcquirePointer(ref pointer); -- byte* bytes = pointer + accessor.PointerOffset; -- -- // https://en.wikipedia.org/wiki/Portable_Executable -- ReadOnlySpan peHeaderOffsetBytes = new(bytes + PEOffsets.DosStub.PESignatureOffset, sizeof(uint)); -- uint peHeaderOffset = BinaryPrimitives.ReadUInt32LittleEndian(peHeaderOffsetBytes); -- -- if (accessor.Capacity < peHeaderOffset + PEOffsets.PEHeader.Subsystem + sizeof(ushort)) -- { -- throw new AppHostNotPEFileException("Subsystem offset out of file range."); -- } -- -- Span subsystemBytes = new(bytes + peHeaderOffset + PEOffsets.PEHeader.Subsystem, sizeof(ushort)); -- ushort subsystem = BinaryPrimitives.ReadUInt16LittleEndian(subsystemBytes); -- -- // https://docs.microsoft.com/en-us/windows/desktop/Debug/pe-format#windows-subsystem -- // The subsystem of the prebuilt apphost should be set to CUI -- if (subsystem != (ushort)PEOffsets.Subsystem.WindowsCui) -- { -- throw new AppHostNotCUIException(subsystem); -- } -- -- // Set the subsystem to GUI -- BinaryPrimitives.WriteUInt16LittleEndian(subsystemBytes, (ushort)PEOffsets.Subsystem.WindowsGui); -- } -- finally -- { -- if (pointer != null) -- { -- accessor.SafeMemoryMappedViewHandle.ReleasePointer(); -- } -- } -+ // https://learn.microsoft.com/windows/win32/debug/pe-format#windows-subsystem -+ // The subsystem of the prebuilt apphost should be set to CUI -+ uint peHeaderOffset; -+ ushort subsystem = GetWindowsSubsystem(accessor, out peHeaderOffset); -+ if (subsystem != (ushort)Subsystem.WindowsCui) -+ throw new AppHostNotCUIException(subsystem); -+ -+ // Set the subsystem to GUI -+ accessor.Write(peHeaderOffset + PEOffsets.PEHeader.Subsystem, AsLittleEndian((ushort)Subsystem.WindowsGui)); - } - - public static unsafe void SetWindowsGraphicalUserInterfaceBit(string filePath) -@@ -119,32 +75,7 @@ public static unsafe void SetWindowsGraphicalUserInterfaceBit(string filePath) - /// The memory accessor which has the apphost file opened. - internal static unsafe ushort GetWindowsGraphicalUserInterfaceBit(MemoryMappedViewAccessor accessor) - { -- byte* pointer = null; -- -- try -- { -- accessor.SafeMemoryMappedViewHandle.AcquirePointer(ref pointer); -- byte* bytes = pointer + accessor.PointerOffset; -- -- // https://en.wikipedia.org/wiki/Portable_Executable -- ReadOnlySpan peHeaderOffsetBytes = new(bytes + PEOffsets.DosStub.PESignatureOffset, sizeof(uint)); -- uint peHeaderOffset = BinaryPrimitives.ReadUInt32LittleEndian(peHeaderOffsetBytes); -- -- if (accessor.Capacity < peHeaderOffset + PEOffsets.PEHeader.Subsystem + sizeof(ushort)) -- { -- throw new AppHostNotPEFileException("Subsystem offset out of file range."); -- } -- -- ReadOnlySpan subsystemBytes = new(bytes + peHeaderOffset + PEOffsets.PEHeader.Subsystem, sizeof(ushort)); -- return BinaryPrimitives.ReadUInt16LittleEndian(subsystemBytes); -- } -- finally -- { -- if (pointer != null) -- { -- accessor.SafeMemoryMappedViewHandle.ReleasePointer(); -- } -- } -+ return GetWindowsSubsystem(accessor, out _); - } - - public static unsafe ushort GetWindowsGraphicalUserInterfaceBit(string filePath) -@@ -157,5 +88,25 @@ public static unsafe ushort GetWindowsGraphicalUserInterfaceBit(string filePath) - } - } - } -+ -+ private static ushort GetWindowsSubsystem(MemoryMappedViewAccessor accessor, out uint peHeaderOffset) -+ { -+ // https://en.wikipedia.org/wiki/Portable_Executable -+ if (accessor.Capacity < PEOffsets.DosStub.PESignatureOffset + sizeof(uint)) -+ throw new AppHostNotPEFileException("PESignature offset out of file range."); -+ -+ peHeaderOffset = AsLittleEndian(accessor.ReadUInt32(PEOffsets.DosStub.PESignatureOffset)); -+ if (accessor.Capacity < peHeaderOffset + PEOffsets.PEHeader.Subsystem + sizeof(ushort)) -+ throw new AppHostNotPEFileException("Subsystem offset out of file range."); -+ -+ // https://learn.microsoft.com/windows/win32/debug/pe-format#windows-subsystem -+ return AsLittleEndian(accessor.ReadUInt16(peHeaderOffset + PEOffsets.PEHeader.Subsystem)); -+ } -+ -+ private static ushort AsLittleEndian(ushort value) -+ => BitConverter.IsLittleEndian ? value : BinaryPrimitives.ReverseEndianness(value); -+ -+ private static uint AsLittleEndian(uint value) -+ => BitConverter.IsLittleEndian ? value : BinaryPrimitives.ReverseEndianness(value); - } - } -diff --git a/src/runtime/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.AppHost.Tests/AppHostUpdateTests.cs b/src/runtime/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.AppHost.Tests/AppHostUpdateTests.cs -index 232410be8f259..b4d038b99b5ce 100644 ---- a/src/runtime/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.AppHost.Tests/AppHostUpdateTests.cs -+++ b/src/runtime/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.AppHost.Tests/AppHostUpdateTests.cs -@@ -11,6 +11,7 @@ - using Microsoft.NET.HostModel.AppHost; - using Microsoft.DotNet.CoreSetup.Test; - using System.Diagnostics; -+using System.Reflection.PortableExecutable; - - namespace Microsoft.NET.HostModel.Tests - { -@@ -111,7 +112,9 @@ public void ItCanSetWindowsGUISubsystem() - BitConverter - .ToUInt16(File.ReadAllBytes(destinationFilePath), SubsystemOffset) - .Should() -- .Be(2); -+ .Be((ushort)Subsystem.WindowsGui); -+ -+ Assert.Equal((ushort)Subsystem.WindowsGui, PEUtils.GetWindowsGraphicalUserInterfaceBit(destinationFilePath)); - } - } - -@@ -153,6 +156,7 @@ public void ItFailsToSetGUISubsystemWithWrongDefault() - string destinationFilePath = Path.Combine(testDirectory.Path, "DestinationAppHost.exe.mock"); - string appBinaryFilePath = "Test/App/Binary/Path.dll"; - -+ Assert.Equal(42, PEUtils.GetWindowsGraphicalUserInterfaceBit(sourceAppHostMock)); - Assert.Throws(() => - HostWriter.CreateAppHost( - sourceAppHostMock, diff --git a/sdk-35600-skip-windows-gui.patch b/sdk-35600-skip-windows-gui.patch deleted file mode 100644 index 279ba8a..0000000 --- a/sdk-35600-skip-windows-gui.patch +++ /dev/null @@ -1,32 +0,0 @@ -From eaa9d8ebefb59cb289e147223b242d77e69f0861 Mon Sep 17 00:00:00 2001 -From: Elinor Fung -Date: Wed, 20 Sep 2023 15:55:32 -0700 -Subject: [PATCH] Skip getting Windows GUI bit on non-Windows in - AppHostShellShimMaker - ---- - src/Cli/dotnet/ShellShim/AppHostShimMaker.cs | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/src/sdk/src/Cli/dotnet/ShellShim/AppHostShimMaker.cs b/src/sdk/src/Cli/dotnet/ShellShim/AppHostShimMaker.cs -index eb9a1332299..7240150e06d 100644 ---- a/src/sdk/src/Cli/dotnet/ShellShim/AppHostShimMaker.cs -+++ b/src/sdk/src/Cli/dotnet/ShellShim/AppHostShimMaker.cs -@@ -40,14 +40,14 @@ public void CreateApphostShellShim(FilePath entryPoint, FilePath shimPath) - string entryPointFullPath = Path.GetFullPath(entryPoint.Value); - var appBinaryFilePath = Path.GetRelativePath(Path.GetDirectoryName(appHostDestinationFilePath), entryPointFullPath); - -- - if (ResourceUpdater.IsSupportedOS()) - { -- var windowsGraphicalUserInterfaceBit = PEUtils.GetWindowsGraphicalUserInterfaceBit(entryPointFullPath); -+ bool windowsGraphicalUserInterface = OperatingSystem.IsWindows() -+ && PEUtils.GetWindowsGraphicalUserInterfaceBit(entryPointFullPath) == WindowsGUISubsystem; - HostWriter.CreateAppHost(appHostSourceFilePath: appHostSourcePath, - appHostDestinationFilePath: appHostDestinationFilePath, - appBinaryFilePath: appBinaryFilePath, -- windowsGraphicalUserInterface: (windowsGraphicalUserInterfaceBit == WindowsGUISubsystem) && OperatingSystem.IsWindows(), -+ windowsGraphicalUserInterface: windowsGraphicalUserInterface, - assemblyToCopyResourcesFrom: entryPointFullPath, - enableMacOSCodeSign: OperatingSystem.IsMacOS()); - } diff --git a/sources b/sources index d5dffbf..4876193 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (dotnet-v8.0.0-rc.1.23419.4.tar.gz) = 6a3f7e20adce8e76e10b235427f16a8b6bbc928be0cec5cb168722d497ac01cce8b6a16b6f12066b422ef33c2c39ad620f9bed24c247e7b75a2b998332f09873 +SHA512 (dotnet-v8.0.0-rc.2.23479.6.tar.gz) = 604220e91cfb3b0909b5127ed6b53b0a661f6258dd87068e5eb2f589729fb7b634ce934967e821075f027e0d2e12d15595a2fff57099efba036f760c6eb79493