From 3bcd30df05c627eaaaa1ec76bfc0d22748ea9918 Mon Sep 17 00:00:00 2001 From: qiaopengcheng Date: Thu, 16 Dec 2021 13:10:37 +0800 Subject: [PATCH 01/11] [LoongArch64] add coreclr-libraries directory. (#59561) --- .../System.Private.CoreLib.csproj | 4 + .../System/Reflection/AssemblyName.CoreCLR.cs | 4 + .../Interop.ProcessorArchitecture.cs | 3 +- .../src/runtime.compatibility.json | 444 ++++++++++++++++++ .../src/runtime.json | 11 + .../src/runtimeGroups.props | 4 +- .../src/Internal/Padding.cs | 2 +- .../src/System/Buffer.Unix.cs | 2 +- .../src/System/Buffer.cs | 2 +- .../src/System/Reflection/AssemblyName.cs | 4 +- .../src/System/SpanHelpers.cs | 2 +- .../PortableThreadPool.WorkerThread.cs | 2 +- .../ref/System.Reflection.Metadata.cs | 1 + .../Reflection/PortableExecutable/Machine.cs | 5 + .../PortableExecutable/ManagedTextSection.cs | 2 +- .../PortableExecutable/PEHeaderBuilder.cs | 2 +- ...stem.Reflection.MetadataLoadContext.csproj | 5 + .../Assemblies/Ecma/EcmaAssembly.GetName.cs | 4 + .../tests/src/Tests/Module/ModuleTests.cs | 18 + ...time.InteropServices.RuntimeInformation.cs | 1 + .../RuntimeInformation/Architecture.cs | 3 +- .../RuntimeInformation.Unix.cs | 2 + .../tests/CheckArchitectureTests.cs | 4 + .../System.Runtime/ref/System.Runtime.cs | 2 + src/native/corehost/bundle/reader.h | 2 + src/native/corehost/hostmisc/utils.cpp | 2 + src/native/eventpipe/ep-event-source.c | 2 + .../System.Native/pal_runtimeinformation.c | 12 +- .../System.Native/pal_runtimeinformation.h | 3 +- 29 files changed, 538 insertions(+), 16 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj index fd9a326b31de4c..19cb0498ff6c78 100644 --- a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -77,6 +77,10 @@ AnyCPU $(DefineConstants);TARGET_ARM64 + + AnyCPU + $(DefineConstants);TARGET_LOONGARCH64 + diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/AssemblyName.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/AssemblyName.CoreCLR.cs index f45b3837abdd93..bd973661de2811 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/AssemblyName.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/AssemblyName.CoreCLR.cs @@ -103,6 +103,10 @@ internal static ProcessorArchitecture CalculateProcArchIndex(PortableExecutableK { return ProcessorArchitecture.Arm; } + if (ifm == ImageFileMachine.LOONGARCH64) + { + return ProcessorArchitecture.LoongArch64; + } } return ProcessorArchitecture.None; } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ProcessorArchitecture.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ProcessorArchitecture.cs index 8b1ad552e7ddd6..9bc1348234c1bd 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ProcessorArchitecture.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ProcessorArchitecture.cs @@ -15,7 +15,8 @@ internal enum ProcessorArchitecture ARM, ARM64, WASM, - S390x + S390x, + LOONGARCH64 } } } diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json index 8d9a5386431a9c..989a909be89939 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json @@ -1984,6 +1984,18 @@ "any", "base" ], + "centos-loongarch64": [ + "centos-loongarch64", + "centos", + "rhel-loongarch64", + "rhel", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "centos.7": [ "centos.7", "centos", @@ -2052,6 +2064,22 @@ "any", "base" ], + "centos.8-loongarch64": [ + "centos.8-loongarch64", + "centos.8", + "centos-loongarch64", + "rhel.8-loongarch64", + "centos", + "rhel.8", + "rhel-loongarch64", + "rhel", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "centos.9": [ "centos.9", "centos", @@ -2094,6 +2122,22 @@ "any", "base" ], + "centos.9-loongarch64": [ + "centos.9-loongarch64", + "centos.9", + "centos-loongarch64", + "rhel.9-loongarch64", + "centos", + "rhel.9", + "rhel-loongarch64", + "rhel", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "debian": [ "debian", "linux", @@ -2151,6 +2195,16 @@ "any", "base" ], + "debian-loongarch64": [ + "debian-loongarch64", + "debian", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "debian.10": [ "debian.10", "debian", @@ -2219,6 +2273,18 @@ "any", "base" ], + "debian.10-loongarch64": [ + "debian.10-loongarch64", + "debian.10", + "debian-loongarch64", + "debian", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "debian.11": [ "debian.11", "debian", @@ -2287,6 +2353,18 @@ "any", "base" ], + "debian.11-loongarch64": [ + "debian.11-loongarch64", + "debian.11", + "debian-loongarch64", + "debian", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "debian.8": [ "debian.8", "debian", @@ -2467,6 +2545,16 @@ "any", "base" ], + "fedora-loongarch64": [ + "fedora-loongarch64", + "fedora", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "fedora.23": [ "fedora.23", "fedora", @@ -2499,6 +2587,18 @@ "any", "base" ], + "fedora.23-loongarch64": [ + "fedora.23-loongarch64", + "fedora.23", + "fedora-loongarch64", + "fedora", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "fedora.24": [ "fedora.24", "fedora", @@ -2531,6 +2631,18 @@ "any", "base" ], + "fedora.24-loongarch64": [ + "fedora.24-loongarch64", + "fedora.24", + "fedora-loongarch64", + "fedora", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "fedora.25": [ "fedora.25", "fedora", @@ -2563,6 +2675,18 @@ "any", "base" ], + "fedora.25-loongarch64": [ + "fedora.25-loongarch64", + "fedora.25", + "fedora-loongarch64", + "fedora", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "fedora.26": [ "fedora.26", "fedora", @@ -2595,6 +2719,18 @@ "any", "base" ], + "fedora.26-loongarch64": [ + "fedora.26-loongarch64", + "fedora.26", + "fedora-loongarch64", + "fedora", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "fedora.27": [ "fedora.27", "fedora", @@ -2627,6 +2763,18 @@ "any", "base" ], + "fedora.27-loongarch64": [ + "fedora.27-loongarch64", + "fedora.27", + "fedora-loongarch64", + "fedora", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "fedora.28": [ "fedora.28", "fedora", @@ -2659,6 +2807,18 @@ "any", "base" ], + "fedora.28-loongarch64": [ + "fedora.28-loongarch64", + "fedora.28", + "fedora-loongarch64", + "fedora", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "fedora.29": [ "fedora.29", "fedora", @@ -2691,6 +2851,18 @@ "any", "base" ], + "fedora.29-loongarch64": [ + "fedora.29-loongarch64", + "fedora.29", + "fedora-loongarch64", + "fedora", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "fedora.30": [ "fedora.30", "fedora", @@ -2723,6 +2895,18 @@ "any", "base" ], + "fedora.30-loongarch64": [ + "fedora.30-loongarch64", + "fedora.30", + "fedora-loongarch64", + "fedora", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "fedora.31": [ "fedora.31", "fedora", @@ -2755,6 +2939,18 @@ "any", "base" ], + "fedora.31-loongarch64": [ + "fedora.31-loongarch64", + "fedora.31", + "fedora-loongarch64", + "fedora", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "fedora.32": [ "fedora.32", "fedora", @@ -2787,6 +2983,18 @@ "any", "base" ], + "fedora.32-loongarch64": [ + "fedora.32-loongarch64", + "fedora.32", + "fedora-loongarch64", + "fedora", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "fedora.33": [ "fedora.33", "fedora", @@ -2819,6 +3027,18 @@ "any", "base" ], + "fedora.33-loongarch64": [ + "fedora.33-loongarch64", + "fedora.33", + "fedora-loongarch64", + "fedora", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "fedora.34": [ "fedora.34", "fedora", @@ -2851,6 +3071,18 @@ "any", "base" ], + "fedora.34-loongarch64": [ + "fedora.34-loongarch64", + "fedora.34", + "fedora-loongarch64", + "fedora", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "fedora.35": [ "fedora.35", "fedora", @@ -2883,6 +3115,18 @@ "any", "base" ], + "fedora.35-loongarch64": [ + "fedora.35-loongarch64", + "fedora.35", + "fedora-loongarch64", + "fedora", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "fedora.36": [ "fedora.36", "fedora", @@ -2915,6 +3159,18 @@ "any", "base" ], + "fedora.36-loongarch64": [ + "fedora.36-loongarch64", + "fedora.36", + "fedora-loongarch64", + "fedora", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "freebsd": [ "freebsd", "unix", @@ -3638,6 +3894,14 @@ "any", "base" ], + "linux-loongarch64": [ + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "linux-mips64": [ "linux-mips64", "linux", @@ -5323,6 +5587,16 @@ "any", "base" ], + "rhel-loongarch64": [ + "rhel-loongarch64", + "rhel", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "rhel.6": [ "rhel.6", "rhel", @@ -5619,6 +5893,18 @@ "any", "base" ], + "rhel.8-loongarch64": [ + "rhel.8-loongarch64", + "rhel.8", + "rhel-loongarch64", + "rhel", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "rhel.8.0": [ "rhel.8.0", "rhel.8", @@ -5656,6 +5942,20 @@ "any", "base" ], + "rhel.8.0-loongarch64": [ + "rhel.8.0-loongarch64", + "rhel.8.0", + "rhel.8-loongarch64", + "rhel.8", + "rhel-loongarch64", + "rhel", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "rhel.8.1": [ "rhel.8.1", "rhel.8.0", @@ -5698,6 +5998,22 @@ "any", "base" ], + "rhel.8.1-loongarch64": [ + "rhel.8.1-loongarch64", + "rhel.8.1", + "rhel.8.0-loongarch64", + "rhel.8.0", + "rhel.8-loongarch64", + "rhel.8", + "rhel-loongarch64", + "rhel", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "rhel.9": [ "rhel.9", "rhel", @@ -5730,6 +6046,18 @@ "any", "base" ], + "rhel.9-loongarch64": [ + "rhel.9-loongarch64", + "rhel.9", + "rhel-loongarch64", + "rhel", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "rocky": [ "rocky", "rhel", @@ -7093,6 +7421,18 @@ "any", "base" ], + "ubuntu-loongarch64": [ + "ubuntu-loongarch64", + "ubuntu", + "debian-loongarch64", + "debian", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "ubuntu.14.04": [ "ubuntu.14.04", "ubuntu", @@ -7687,6 +8027,20 @@ "any", "base" ], + "ubuntu.18.10-loongarch64": [ + "ubuntu.18.10-loongarch64", + "ubuntu.18.10", + "ubuntu-loongarch64", + "ubuntu", + "debian-loongarch64", + "debian", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "ubuntu.19.04": [ "ubuntu.19.04", "ubuntu", @@ -7752,6 +8106,20 @@ "any", "base" ], + "ubuntu.19.04-loongarch64": [ + "ubuntu.19.04-loongarch64", + "ubuntu.19.04", + "ubuntu-loongarch64", + "ubuntu", + "debian-loongarch64", + "debian", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "ubuntu.19.10": [ "ubuntu.19.10", "ubuntu", @@ -7817,6 +8185,20 @@ "any", "base" ], + "ubuntu.19.10-loongarch64": [ + "ubuntu.19.10-loongarch64", + "ubuntu.19.10", + "ubuntu-loongarch64", + "ubuntu", + "debian-loongarch64", + "debian", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "ubuntu.20.04": [ "ubuntu.20.04", "ubuntu", @@ -7882,6 +8264,20 @@ "any", "base" ], + "ubuntu.20.04-loongarch64": [ + "ubuntu.20.04-loongarch64", + "ubuntu.20.04", + "ubuntu-loongarch64", + "ubuntu", + "debian-loongarch64", + "debian", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "ubuntu.20.10": [ "ubuntu.20.10", "ubuntu", @@ -7947,6 +8343,20 @@ "any", "base" ], + "ubuntu.20.10-loongarch64": [ + "ubuntu.20.10-loongarch64", + "ubuntu.20.10", + "ubuntu-loongarch64", + "ubuntu", + "debian-loongarch64", + "debian", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "ubuntu.21.04": [ "ubuntu.21.04", "ubuntu", @@ -8012,6 +8422,20 @@ "any", "base" ], + "ubuntu.21.04-loongarch64": [ + "ubuntu.21.04-loongarch64", + "ubuntu.21.04", + "ubuntu-loongarch64", + "ubuntu", + "debian-loongarch64", + "debian", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "ubuntu.21.10": [ "ubuntu.21.10", "ubuntu", @@ -8077,6 +8501,20 @@ "any", "base" ], + "ubuntu.21.10-loongarch64": [ + "ubuntu.21.10-loongarch64", + "ubuntu.21.10", + "ubuntu-loongarch64", + "ubuntu", + "debian-loongarch64", + "debian", + "linux-loongarch64", + "linux", + "unix-loongarch64", + "unix", + "any", + "base" + ], "unix": [ "unix", "any", @@ -8100,6 +8538,12 @@ "any", "base" ], + "unix-loongarch64": [ + "unix-loongarch64", + "unix", + "any", + "base" + ], "unix-mips64": [ "unix-mips64", "unix", diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json index 39ca7bdb933c3e..24ded362047ec1 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json @@ -1475,6 +1475,12 @@ "unix-armel" ] }, + "linux-loongarch64": { + "#import": [ + "linux", + "unix-loongarch64" + ] + }, "linux-mips64": { "#import": [ "linux", @@ -3419,6 +3425,11 @@ "unix" ] }, + "unix-loongarch64": { + "#import": [ + "unix" + ] + }, "win": { "#import": [ "any" diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props b/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props index bc7832c33b61fc..b8345349409ecb 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props @@ -3,11 +3,11 @@ any - x64;x86;arm;armel;arm64;mips64;s390x + x64;x86;arm;armel;arm64;loongarch64;mips64;s390x unix - x64;x86;arm;armel;arm64;mips64;s390x + x64;x86;arm;armel;arm64;loongarch64;mips64;s390x linux diff --git a/src/libraries/System.Private.CoreLib/src/Internal/Padding.cs b/src/libraries/System.Private.CoreLib/src/Internal/Padding.cs index 17f3643be3e469..5f846ce3f8b985 100644 --- a/src/libraries/System.Private.CoreLib/src/Internal/Padding.cs +++ b/src/libraries/System.Private.CoreLib/src/Internal/Padding.cs @@ -9,7 +9,7 @@ namespace Internal internal static class PaddingHelpers { /// A size greater than or equal to the size of the most common CPU cache lines. -#if TARGET_ARM64 +#if TARGET_ARM64 || TARGET_LOONGARCH64 internal const int CACHE_LINE_SIZE = 128; #else internal const int CACHE_LINE_SIZE = 64; diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffer.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Buffer.Unix.cs index 4d0c18ca9d7108..008bc9310a2417 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffer.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffer.Unix.cs @@ -5,7 +5,7 @@ namespace System { public static partial class Buffer { -#if TARGET_ARM64 +#if TARGET_ARM64 || TARGET_LOONGARCH64 // Managed code is currently faster than glibc unoptimized memmove // TODO-ARM64-UNIX-OPT revisit when glibc optimized memmove is in Linux distros // https://github.com/dotnet/runtime/issues/8897 diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffer.cs b/src/libraries/System.Private.CoreLib/src/System/Buffer.cs index 64bd6fca168e33..027c138d1ac6aa 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffer.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffer.cs @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if TARGET_AMD64 || TARGET_ARM64 || (TARGET_32BIT && !TARGET_ARM) +#if TARGET_AMD64 || TARGET_ARM64 || (TARGET_32BIT && !TARGET_ARM) || TARGET_LOONGARCH64 #define HAS_CUSTOM_BLOCKS #endif diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs index 198c6804b7e4f2..2c1f72124ae9ce 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs @@ -83,14 +83,14 @@ public ProcessorArchitecture ProcessorArchitecture get { int x = (((int)_flags) & 0x70) >> 4; - if (x > 5) + if (x > 6) x = 0; return (ProcessorArchitecture)x; } set { int x = ((int)value) & 0x07; - if (x <= 5) + if (x <= 6) { _flags = (AssemblyNameFlags)((int)_flags & 0xFFFFFF0F); _flags |= (AssemblyNameFlags)(x << 4); diff --git a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.cs b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.cs index a7f99e440bfc4b..9cc75163f097f3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.cs @@ -14,7 +14,7 @@ public static unsafe void ClearWithoutReferences(ref byte b, nuint byteLength) if (byteLength == 0) return; -#if TARGET_AMD64 || TARGET_ARM64 +#if TARGET_AMD64 || TARGET_ARM64 || TARGET_LOONGARCH64 // The exact matrix on when ZeroMemory is faster than InitBlockUnaligned is very complex. The factors to consider include // type of hardware and memory alignment. This threshold was chosen as a good balance across different configurations. if (byteLength > 768) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.cs index 796c0e505a5e21..7a79c9980447c8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.cs @@ -13,7 +13,7 @@ internal sealed partial class PortableThreadPool private static class WorkerThread { private const int SemaphoreSpinCountDefaultBaseline = 70; -#if !TARGET_ARM64 && !TARGET_ARM +#if !TARGET_ARM64 && !TARGET_ARM && !TARGET_LOONGARCH64 private const int SemaphoreSpinCountDefault = SemaphoreSpinCountDefaultBaseline; #else // On systems with ARM processors, more spin-waiting seems to be necessary to avoid perf regressions from incurring diff --git a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs index fee9b78b71fa02..cafdc1b090757f 100644 --- a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs +++ b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs @@ -3271,6 +3271,7 @@ public enum Machine : ushort Amd64 = (ushort)34404, M32R = (ushort)36929, Arm64 = (ushort)43620, + LoongArch64 = (ushort)25188, } public partial class ManagedPEBuilder : System.Reflection.PortableExecutable.PEBuilder { diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs index 2d1dc8ed54afce..a52f0b91e334ec 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs @@ -129,5 +129,10 @@ public enum Machine : ushort /// ARM64 /// Arm64 = 0xAA64, + + /// + /// LOONGARCH64 + /// + LoongArch64 = 0x6264, } } diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/ManagedTextSection.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/ManagedTextSection.cs index 33bd80dec21f75..c754d0b59577f7 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/ManagedTextSection.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/ManagedTextSection.cs @@ -90,7 +90,7 @@ public ManagedTextSection( /// If set, the module contains instructions that assume a 64 bit instruction set. For example it may depend on an address being 64 bits. /// This may be true even if the module contains only IL instructions because of PlatformInvoke and COM interop. /// - internal bool Requires64bits => Machine == Machine.Amd64 || Machine == Machine.IA64 || Machine == Machine.Arm64; + internal bool Requires64bits => Machine == Machine.Amd64 || Machine == Machine.IA64 || Machine == Machine.Arm64 || Machine == Machine.LoongArch64; public bool Is32Bit => !Requires64bits; diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEHeaderBuilder.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEHeaderBuilder.cs index bd7f249b32e900..86d394532d10e3 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEHeaderBuilder.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEHeaderBuilder.cs @@ -105,7 +105,7 @@ public static PEHeaderBuilder CreateLibraryHeader() return new PEHeaderBuilder(imageCharacteristics: Characteristics.ExecutableImage | Characteristics.Dll); } - internal bool Is32Bit => Machine != Machine.Amd64 && Machine != Machine.IA64 && Machine != Machine.Arm64; + internal bool Is32Bit => Machine != Machine.Amd64 && Machine != Machine.IA64 && Machine != Machine.Arm64 && Machine != Machine.LoongArch64; internal int ComputeSizeOfPEHeaders(int sectionCount) => PEBuilder.DosHeaderSize + diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System.Reflection.MetadataLoadContext.csproj b/src/libraries/System.Reflection.MetadataLoadContext/src/System.Reflection.MetadataLoadContext.csproj index c440191179e41b..a1840ae55d6213 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System.Reflection.MetadataLoadContext.csproj +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System.Reflection.MetadataLoadContext.csproj @@ -12,6 +12,11 @@ Commonly Used Types: System.Reflection.MetadataLoadContext System.Reflection.MetadataAssemblyResolver + + + DotNetBuildFromSource;$(DefineConstants) + + diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/Ecma/EcmaAssembly.GetName.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/Ecma/EcmaAssembly.GetName.cs index 8d89f0baeedb4f..eeaed46dd38d69 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/Ecma/EcmaAssembly.GetName.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/Ecma/EcmaAssembly.GetName.cs @@ -53,6 +53,10 @@ protected sealed override AssemblyNameData ComputeNameData() data.ProcessorArchitecture = ProcessorArchitecture.Arm; break; + case ImageFileMachine.LOONGARCH64: + data.ProcessorArchitecture = ProcessorArchitecture.LoongArch64; + break; + case ImageFileMachine.IA64: data.ProcessorArchitecture = ProcessorArchitecture.IA64; break; diff --git a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Module/ModuleTests.cs b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Module/ModuleTests.cs index 224f7082b374de..e40f19220ea87b 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Module/ModuleTests.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Module/ModuleTests.cs @@ -233,5 +233,23 @@ public static void GetPEKindArm() Assert.Equal(ProcessorArchitecture.Arm, pa); } } + + [Fact] + public static void GetPEKindLoongArch64() + { + using (MetadataLoadContext lc = new MetadataLoadContext(new EmptyCoreMetadataAssemblyResolver())) + { + Assembly a = lc.LoadFromByteArray(TestData.s_PlatformLoongArch64); + Module m = a.ManifestModule; + + m.GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine); + Assert.Equal(PortableExecutableKinds.ILOnly, peKind); + Assert.Equal(ImageFileMachine.LOONGARCH64, machine); + + AssemblyName an = a.GetName(copiedName: false); + ProcessorArchitecture pa = an.ProcessorArchitecture; + Assert.Equal(ProcessorArchitecture.LoongArch64, pa); + } + } } } diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/ref/System.Runtime.InteropServices.RuntimeInformation.cs b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/ref/System.Runtime.InteropServices.RuntimeInformation.cs index 576f7b08f9493e..626a0b9fc7a006 100644 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/ref/System.Runtime.InteropServices.RuntimeInformation.cs +++ b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/ref/System.Runtime.InteropServices.RuntimeInformation.cs @@ -14,6 +14,7 @@ public enum Architecture Arm64 = 3, Wasm = 4, S390x = 5, + LoongArch64 = 6, } public readonly partial struct OSPlatform : System.IEquatable { diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/Architecture.cs b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/Architecture.cs index 2c52a9b8ea433c..225fec28c763ac 100644 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/Architecture.cs +++ b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/Architecture.cs @@ -10,6 +10,7 @@ public enum Architecture Arm, Arm64, Wasm, - S390x + S390x, + LoongArch64 } } diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Unix.cs b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Unix.cs index 46b1a85d763c26..eefbf3b3184515 100644 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Unix.cs +++ b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Unix.cs @@ -29,6 +29,8 @@ private static Architecture Map(Interop.Sys.ProcessorArchitecture arch) return Architecture.Wasm; case Interop.Sys.ProcessorArchitecture.S390x: return Architecture.S390x; + case Interop.Sys.ProcessorArchitecture.LOONGARCH64: + return Architecture.LoongArch64; case Interop.Sys.ProcessorArchitecture.x86: default: Debug.Assert(arch == Interop.Sys.ProcessorArchitecture.x86, "Unidentified Architecture"); diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/tests/CheckArchitectureTests.cs b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/tests/CheckArchitectureTests.cs index 50c52fa853158f..6f1b289fd00eea 100644 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/tests/CheckArchitectureTests.cs +++ b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/tests/CheckArchitectureTests.cs @@ -40,6 +40,10 @@ public void VerifyArchitecture() Assert.Equal(Architecture.S390x, processArch); break; + case Architecture.LoongArch64: + Assert.Equal(Architecture.LoongArch64, processArch); + break; + default: Assert.False(true, "Unexpected Architecture."); break; diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index f9462613a698b3..1bdb06344f5496 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -11809,6 +11809,7 @@ public enum ImageFileMachine ARM = 452, IA64 = 512, AMD64 = 34404, + LOONGARCH64 = 25188, } public partial struct InterfaceMapping { @@ -12237,6 +12238,7 @@ public enum ProcessorArchitecture IA64 = 3, Amd64 = 4, Arm = 5, + LoongArch64 = 6, } [System.FlagsAttribute] public enum PropertyAttributes diff --git a/src/native/corehost/bundle/reader.h b/src/native/corehost/bundle/reader.h index 576ecd04c8e0fe..b96934e537f011 100644 --- a/src/native/corehost/bundle/reader.h +++ b/src/native/corehost/bundle/reader.h @@ -17,6 +17,8 @@ #if defined(TARGET_ARM64) #define TARGET_CPU_TYPE CPU_TYPE_ARM64 +#elif defined(TARGET_LOONGARCH64) +#define TARGET_CPU_TYPE CPU_TYPE_LOONGARCH64 #else #define TARGET_CPU_TYPE CPU_TYPE_X86_64 #endif diff --git a/src/native/corehost/hostmisc/utils.cpp b/src/native/corehost/hostmisc/utils.cpp index 21cc7e9c9b49ef..7f5fdbca40ab03 100644 --- a/src/native/corehost/hostmisc/utils.cpp +++ b/src/native/corehost/hostmisc/utils.cpp @@ -195,6 +195,8 @@ const pal::char_t* get_arch() return _X("arm"); #elif defined(TARGET_ARM64) return _X("arm64"); +#elif defined(TARGET_LOONGARCH64) + return _X("loongarch64"); #elif defined(TARGET_S390X) return _X("s390x"); #else diff --git a/src/native/eventpipe/ep-event-source.c b/src/native/eventpipe/ep-event-source.c index 36eac2dcbbfc45..78d1c4852b991c 100644 --- a/src/native/eventpipe/ep-event-source.c +++ b/src/native/eventpipe/ep-event-source.c @@ -40,6 +40,8 @@ const ep_char8_t* _ep_arch_info = "arm32"; const ep_char8_t* _ep_arch_info = "arm64"; #elif defined(TARGET_S390X) const ep_char8_t* _ep_arch_info = "s390x"; +#elif defined(TARGET_LOONGARCH64) +const ep_char8_t* _ep_arch_info = "loongarch64"; #else const ep_char8_t* _ep_arch_info = "Unknown"; #endif diff --git a/src/native/libs/System.Native/pal_runtimeinformation.c b/src/native/libs/System.Native/pal_runtimeinformation.c index c7b7073adfafd1..a469d1b1374419 100644 --- a/src/native/libs/System.Native/pal_runtimeinformation.c +++ b/src/native/libs/System.Native/pal_runtimeinformation.c @@ -58,7 +58,9 @@ int32_t SystemNative_GetUnixVersion(char* version, int* capacity) 1 - x64 2 - ARM 3 - ARM64 - 4 - WASM */ + 4 - WASM + 5 - S390X + 6 - LOONGARCH64 */ int32_t SystemNative_GetOSArchitecture() { #if defined(TARGET_ARM) @@ -73,6 +75,8 @@ int32_t SystemNative_GetOSArchitecture() return ARCH_WASM; #elif defined(TARGET_S390X) return ARCH_S390X; +#elif defined(TARGET_LOONGARCH64) + return ARCH_LOONGARCH64; #else #error Unidentified Architecture #endif @@ -83,7 +87,9 @@ int32_t SystemNative_GetOSArchitecture() 1 - x64 2 - ARM 3 - ARM64 -4 - WASM */ +4 - WASM +5 - S390X +6 - LOONGARCH64 */ int32_t SystemNative_GetProcessArchitecture() { #if defined(TARGET_ARM) @@ -98,6 +104,8 @@ int32_t SystemNative_GetProcessArchitecture() return ARCH_WASM; #elif defined(TARGET_S390X) return ARCH_S390X; +#elif defined(TARGET_LOONGARCH64) + return ARCH_LOONGARCH64; #else #error Unidentified Architecture #endif diff --git a/src/native/libs/System.Native/pal_runtimeinformation.h b/src/native/libs/System.Native/pal_runtimeinformation.h index ff7e91d7dad1da..dc47f0f2d9e898 100644 --- a/src/native/libs/System.Native/pal_runtimeinformation.h +++ b/src/native/libs/System.Native/pal_runtimeinformation.h @@ -23,5 +23,6 @@ enum ARCH_ARM, ARCH_ARM64, ARCH_WASM, - ARCH_S390X + ARCH_S390X, + ARCH_LOONGARCH64 }; From 9cf0420edb177dfb80c668f6db412b1c1097cceb Mon Sep 17 00:00:00 2001 From: qiaopengcheng Date: Fri, 17 Dec 2021 09:46:30 +0800 Subject: [PATCH 02/11] [LoongArch64] reset some LoongArch64 within the coreclr-libraries Reflection. (#59561) --- .../src/System/Reflection/AssemblyName.CoreCLR.cs | 4 ---- .../src/System/Reflection/AssemblyName.cs | 4 ++-- .../src/System/Reflection/PortableExecutable/Machine.cs | 5 ----- src/libraries/System.Runtime/ref/System.Runtime.cs | 2 -- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/AssemblyName.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/AssemblyName.CoreCLR.cs index bd973661de2811..f45b3837abdd93 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/AssemblyName.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/AssemblyName.CoreCLR.cs @@ -103,10 +103,6 @@ internal static ProcessorArchitecture CalculateProcArchIndex(PortableExecutableK { return ProcessorArchitecture.Arm; } - if (ifm == ImageFileMachine.LOONGARCH64) - { - return ProcessorArchitecture.LoongArch64; - } } return ProcessorArchitecture.None; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs index 2c1f72124ae9ce..198c6804b7e4f2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs @@ -83,14 +83,14 @@ public ProcessorArchitecture ProcessorArchitecture get { int x = (((int)_flags) & 0x70) >> 4; - if (x > 6) + if (x > 5) x = 0; return (ProcessorArchitecture)x; } set { int x = ((int)value) & 0x07; - if (x <= 6) + if (x <= 5) { _flags = (AssemblyNameFlags)((int)_flags & 0xFFFFFF0F); _flags |= (AssemblyNameFlags)(x << 4); diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs index a52f0b91e334ec..2d1dc8ed54afce 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs @@ -129,10 +129,5 @@ public enum Machine : ushort /// ARM64 /// Arm64 = 0xAA64, - - /// - /// LOONGARCH64 - /// - LoongArch64 = 0x6264, } } diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 1bdb06344f5496..f9462613a698b3 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -11809,7 +11809,6 @@ public enum ImageFileMachine ARM = 452, IA64 = 512, AMD64 = 34404, - LOONGARCH64 = 25188, } public partial struct InterfaceMapping { @@ -12238,7 +12237,6 @@ public enum ProcessorArchitecture IA64 = 3, Amd64 = 4, Arm = 5, - LoongArch64 = 6, } [System.FlagsAttribute] public enum PropertyAttributes From 0b1677ee268d43dffdea13d276ecad3cdcb1add3 Mon Sep 17 00:00:00 2001 From: qiaopengcheng Date: Fri, 17 Dec 2021 12:46:49 +0800 Subject: [PATCH 03/11] [LoongArch64] Add LoongArch64/32 for PE machine. --- .../System/Reflection/PortableExecutable/Machine.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs index 2d1dc8ed54afce..c4d3e336616ad6 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/Machine.cs @@ -129,5 +129,15 @@ public enum Machine : ushort /// ARM64 /// Arm64 = 0xAA64, + + /// + /// LOONGARCH32 + /// + LoongArch32 = 0x6232, + + /// + /// LOONGARCH64 + /// + LoongArch64 = 0x6264, } } From 80e5b7a5c8aff8db5b431de0d61f5b117a960cb9 Mon Sep 17 00:00:00 2001 From: qiaopengcheng Date: Wed, 22 Dec 2021 13:00:23 +0800 Subject: [PATCH 04/11] [LoongArch64] revert some files within libraries. --- .../ref/System.Reflection.Metadata.cs | 1 + ...ystem.Reflection.MetadataLoadContext.csproj | 5 ----- .../tests/src/Tests/Module/ModuleTests.cs | 18 ------------------ 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs index cafdc1b090757f..db86c83fe7350a 100644 --- a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs +++ b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs @@ -3271,6 +3271,7 @@ public enum Machine : ushort Amd64 = (ushort)34404, M32R = (ushort)36929, Arm64 = (ushort)43620, + LoongArch32 = (ushort)25138, LoongArch64 = (ushort)25188, } public partial class ManagedPEBuilder : System.Reflection.PortableExecutable.PEBuilder diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System.Reflection.MetadataLoadContext.csproj b/src/libraries/System.Reflection.MetadataLoadContext/src/System.Reflection.MetadataLoadContext.csproj index a1840ae55d6213..c440191179e41b 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System.Reflection.MetadataLoadContext.csproj +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System.Reflection.MetadataLoadContext.csproj @@ -12,11 +12,6 @@ Commonly Used Types: System.Reflection.MetadataLoadContext System.Reflection.MetadataAssemblyResolver - - - DotNetBuildFromSource;$(DefineConstants) - - diff --git a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Module/ModuleTests.cs b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Module/ModuleTests.cs index e40f19220ea87b..224f7082b374de 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Module/ModuleTests.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Module/ModuleTests.cs @@ -233,23 +233,5 @@ public static void GetPEKindArm() Assert.Equal(ProcessorArchitecture.Arm, pa); } } - - [Fact] - public static void GetPEKindLoongArch64() - { - using (MetadataLoadContext lc = new MetadataLoadContext(new EmptyCoreMetadataAssemblyResolver())) - { - Assembly a = lc.LoadFromByteArray(TestData.s_PlatformLoongArch64); - Module m = a.ManifestModule; - - m.GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine); - Assert.Equal(PortableExecutableKinds.ILOnly, peKind); - Assert.Equal(ImageFileMachine.LOONGARCH64, machine); - - AssemblyName an = a.GetName(copiedName: false); - ProcessorArchitecture pa = an.ProcessorArchitecture; - Assert.Equal(ProcessorArchitecture.LoongArch64, pa); - } - } } } From 2bf77bdfbdb4715d8a4cdca285c131a63df0d423 Mon Sep 17 00:00:00 2001 From: qiaopengcheng Date: Thu, 23 Dec 2021 08:59:19 +0800 Subject: [PATCH 05/11] [LoongArch64] revert the file `EcmaAssembly.GetName.cs`. --- .../TypeLoading/Assemblies/Ecma/EcmaAssembly.GetName.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/Ecma/EcmaAssembly.GetName.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/Ecma/EcmaAssembly.GetName.cs index eeaed46dd38d69..8d89f0baeedb4f 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/Ecma/EcmaAssembly.GetName.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/Ecma/EcmaAssembly.GetName.cs @@ -53,10 +53,6 @@ protected sealed override AssemblyNameData ComputeNameData() data.ProcessorArchitecture = ProcessorArchitecture.Arm; break; - case ImageFileMachine.LOONGARCH64: - data.ProcessorArchitecture = ProcessorArchitecture.LoongArch64; - break; - case ImageFileMachine.IA64: data.ProcessorArchitecture = ProcessorArchitecture.IA64; break; From 357867ad338c3a0152e71a7712d7ed79b9d8ca8e Mon Sep 17 00:00:00 2001 From: qiaopengcheng Date: Wed, 5 Jan 2022 09:05:52 +0800 Subject: [PATCH 06/11] [LoongArch64] revert the `PEHeaderBuilder.cs` which is not needed. --- .../src/System/Reflection/PortableExecutable/PEHeaderBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEHeaderBuilder.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEHeaderBuilder.cs index 86d394532d10e3..bd7f249b32e900 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEHeaderBuilder.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEHeaderBuilder.cs @@ -105,7 +105,7 @@ public static PEHeaderBuilder CreateLibraryHeader() return new PEHeaderBuilder(imageCharacteristics: Characteristics.ExecutableImage | Characteristics.Dll); } - internal bool Is32Bit => Machine != Machine.Amd64 && Machine != Machine.IA64 && Machine != Machine.Arm64 && Machine != Machine.LoongArch64; + internal bool Is32Bit => Machine != Machine.Amd64 && Machine != Machine.IA64 && Machine != Machine.Arm64; internal int ComputeSizeOfPEHeaders(int sectionCount) => PEBuilder.DosHeaderSize + From bc71db6167ff94608483223defc11d8b677eef66 Mon Sep 17 00:00:00 2001 From: qiaopengcheng Date: Wed, 5 Jan 2022 12:06:47 +0800 Subject: [PATCH 07/11] [LoongArch64] add supporting for LoongArch64. --- .../InteropServices/RuntimeInformation.ProcessArchitecture.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.ProcessArchitecture.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.ProcessArchitecture.cs index 298d0395042990..0da595b95e0746 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.ProcessArchitecture.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.ProcessArchitecture.cs @@ -18,6 +18,8 @@ public static Architecture ProcessArchitecture => Architecture.Wasm; #elif TARGET_S390X => Architecture.S390x; +#elif TARGET_LOONGARCH64 + => Architecture.LoongArch64; #else #error Unknown Architecture #endif From 56ee7a80b39d2c55dc82bc2c477dd02ed5ebb203 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Tue, 4 Jan 2022 20:47:28 -0800 Subject: [PATCH 08/11] Update src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/ManagedTextSection.cs --- .../System/Reflection/PortableExecutable/ManagedTextSection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/ManagedTextSection.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/ManagedTextSection.cs index c754d0b59577f7..33bd80dec21f75 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/ManagedTextSection.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/ManagedTextSection.cs @@ -90,7 +90,7 @@ public ManagedTextSection( /// If set, the module contains instructions that assume a 64 bit instruction set. For example it may depend on an address being 64 bits. /// This may be true even if the module contains only IL instructions because of PlatformInvoke and COM interop. /// - internal bool Requires64bits => Machine == Machine.Amd64 || Machine == Machine.IA64 || Machine == Machine.Arm64 || Machine == Machine.LoongArch64; + internal bool Requires64bits => Machine == Machine.Amd64 || Machine == Machine.IA64 || Machine == Machine.Arm64; public bool Is32Bit => !Requires64bits; From 7bc8c3f0efeda6b21bfc9c3f0cb8c034376725e7 Mon Sep 17 00:00:00 2001 From: qiaopengcheng Date: Wed, 5 Jan 2022 13:45:04 +0800 Subject: [PATCH 09/11] [LoongArch64] add LoongArch64 within `Architecture`. --- src/libraries/System.Runtime/ref/System.Runtime.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 840ecbdff7ce8a..41c562ff9d5fef 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -13431,6 +13431,7 @@ public enum Architecture Arm64 = 3, Wasm = 4, S390x = 5, + LoongArch64 = 6, } public enum CharSet { From 1b06b8cb16bcd730825c38a2ac8ed86c8ae5701d Mon Sep 17 00:00:00 2001 From: qiaopengcheng Date: Wed, 5 Jan 2022 15:49:10 +0800 Subject: [PATCH 10/11] [LoongArch64] add loongarch64 for `Is6464Bit` within the `System.Private.CoreLib.Shared.projitems`. --- .../src/System.Private.CoreLib.Shared.projitems | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 24b049b1df2ff1..3fb7dafbb308b5 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -17,7 +17,7 @@ true $(MSBuildThisFileDirectory)ILLink\ true - true + true true From 712e19f07ede0657a495cd71bd6e4eaa489093ab Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Thu, 6 Jan 2022 17:31:02 -0800 Subject: [PATCH 11/11] Run /p:UpdateRuntimeFiles=true cd src/libraries/Microsoft.NETCore.Platforms/src dotnet build -c Release Microsoft.NETCore.Platforms.csproj /p:UpdateRuntimeFiles=true /t:UpdateRuntimeJson --- .../src/runtime.compatibility.json | 432 +----------------- .../src/runtime.json | 12 +- 2 files changed, 7 insertions(+), 437 deletions(-) diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json index 989a909be89939..3d7f5a57eeeb85 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json @@ -1984,18 +1984,6 @@ "any", "base" ], - "centos-loongarch64": [ - "centos-loongarch64", - "centos", - "rhel-loongarch64", - "rhel", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "centos.7": [ "centos.7", "centos", @@ -2064,22 +2052,6 @@ "any", "base" ], - "centos.8-loongarch64": [ - "centos.8-loongarch64", - "centos.8", - "centos-loongarch64", - "rhel.8-loongarch64", - "centos", - "rhel.8", - "rhel-loongarch64", - "rhel", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "centos.9": [ "centos.9", "centos", @@ -2122,22 +2094,6 @@ "any", "base" ], - "centos.9-loongarch64": [ - "centos.9-loongarch64", - "centos.9", - "centos-loongarch64", - "rhel.9-loongarch64", - "centos", - "rhel.9", - "rhel-loongarch64", - "rhel", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "debian": [ "debian", "linux", @@ -2195,16 +2151,6 @@ "any", "base" ], - "debian-loongarch64": [ - "debian-loongarch64", - "debian", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "debian.10": [ "debian.10", "debian", @@ -2273,18 +2219,6 @@ "any", "base" ], - "debian.10-loongarch64": [ - "debian.10-loongarch64", - "debian.10", - "debian-loongarch64", - "debian", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "debian.11": [ "debian.11", "debian", @@ -2353,18 +2287,6 @@ "any", "base" ], - "debian.11-loongarch64": [ - "debian.11-loongarch64", - "debian.11", - "debian-loongarch64", - "debian", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "debian.8": [ "debian.8", "debian", @@ -2545,16 +2467,6 @@ "any", "base" ], - "fedora-loongarch64": [ - "fedora-loongarch64", - "fedora", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "fedora.23": [ "fedora.23", "fedora", @@ -2587,18 +2499,6 @@ "any", "base" ], - "fedora.23-loongarch64": [ - "fedora.23-loongarch64", - "fedora.23", - "fedora-loongarch64", - "fedora", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "fedora.24": [ "fedora.24", "fedora", @@ -2631,18 +2531,6 @@ "any", "base" ], - "fedora.24-loongarch64": [ - "fedora.24-loongarch64", - "fedora.24", - "fedora-loongarch64", - "fedora", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "fedora.25": [ "fedora.25", "fedora", @@ -2675,18 +2563,6 @@ "any", "base" ], - "fedora.25-loongarch64": [ - "fedora.25-loongarch64", - "fedora.25", - "fedora-loongarch64", - "fedora", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "fedora.26": [ "fedora.26", "fedora", @@ -2719,18 +2595,6 @@ "any", "base" ], - "fedora.26-loongarch64": [ - "fedora.26-loongarch64", - "fedora.26", - "fedora-loongarch64", - "fedora", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "fedora.27": [ "fedora.27", "fedora", @@ -2763,18 +2627,6 @@ "any", "base" ], - "fedora.27-loongarch64": [ - "fedora.27-loongarch64", - "fedora.27", - "fedora-loongarch64", - "fedora", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "fedora.28": [ "fedora.28", "fedora", @@ -2807,18 +2659,6 @@ "any", "base" ], - "fedora.28-loongarch64": [ - "fedora.28-loongarch64", - "fedora.28", - "fedora-loongarch64", - "fedora", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "fedora.29": [ "fedora.29", "fedora", @@ -2851,18 +2691,6 @@ "any", "base" ], - "fedora.29-loongarch64": [ - "fedora.29-loongarch64", - "fedora.29", - "fedora-loongarch64", - "fedora", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "fedora.30": [ "fedora.30", "fedora", @@ -2895,18 +2723,6 @@ "any", "base" ], - "fedora.30-loongarch64": [ - "fedora.30-loongarch64", - "fedora.30", - "fedora-loongarch64", - "fedora", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "fedora.31": [ "fedora.31", "fedora", @@ -2939,18 +2755,6 @@ "any", "base" ], - "fedora.31-loongarch64": [ - "fedora.31-loongarch64", - "fedora.31", - "fedora-loongarch64", - "fedora", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "fedora.32": [ "fedora.32", "fedora", @@ -2983,18 +2787,6 @@ "any", "base" ], - "fedora.32-loongarch64": [ - "fedora.32-loongarch64", - "fedora.32", - "fedora-loongarch64", - "fedora", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "fedora.33": [ "fedora.33", "fedora", @@ -3027,18 +2819,6 @@ "any", "base" ], - "fedora.33-loongarch64": [ - "fedora.33-loongarch64", - "fedora.33", - "fedora-loongarch64", - "fedora", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "fedora.34": [ "fedora.34", "fedora", @@ -3071,18 +2851,6 @@ "any", "base" ], - "fedora.34-loongarch64": [ - "fedora.34-loongarch64", - "fedora.34", - "fedora-loongarch64", - "fedora", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "fedora.35": [ "fedora.35", "fedora", @@ -3115,18 +2883,6 @@ "any", "base" ], - "fedora.35-loongarch64": [ - "fedora.35-loongarch64", - "fedora.35", - "fedora-loongarch64", - "fedora", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "fedora.36": [ "fedora.36", "fedora", @@ -3159,18 +2915,6 @@ "any", "base" ], - "fedora.36-loongarch64": [ - "fedora.36-loongarch64", - "fedora.36", - "fedora-loongarch64", - "fedora", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "freebsd": [ "freebsd", "unix", @@ -5587,16 +5331,6 @@ "any", "base" ], - "rhel-loongarch64": [ - "rhel-loongarch64", - "rhel", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "rhel.6": [ "rhel.6", "rhel", @@ -5893,18 +5627,6 @@ "any", "base" ], - "rhel.8-loongarch64": [ - "rhel.8-loongarch64", - "rhel.8", - "rhel-loongarch64", - "rhel", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "rhel.8.0": [ "rhel.8.0", "rhel.8", @@ -5942,20 +5664,6 @@ "any", "base" ], - "rhel.8.0-loongarch64": [ - "rhel.8.0-loongarch64", - "rhel.8.0", - "rhel.8-loongarch64", - "rhel.8", - "rhel-loongarch64", - "rhel", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "rhel.8.1": [ "rhel.8.1", "rhel.8.0", @@ -5998,22 +5706,6 @@ "any", "base" ], - "rhel.8.1-loongarch64": [ - "rhel.8.1-loongarch64", - "rhel.8.1", - "rhel.8.0-loongarch64", - "rhel.8.0", - "rhel.8-loongarch64", - "rhel.8", - "rhel-loongarch64", - "rhel", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "rhel.9": [ "rhel.9", "rhel", @@ -6046,18 +5738,6 @@ "any", "base" ], - "rhel.9-loongarch64": [ - "rhel.9-loongarch64", - "rhel.9", - "rhel-loongarch64", - "rhel", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "rocky": [ "rocky", "rhel", @@ -7421,18 +7101,6 @@ "any", "base" ], - "ubuntu-loongarch64": [ - "ubuntu-loongarch64", - "ubuntu", - "debian-loongarch64", - "debian", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "ubuntu.14.04": [ "ubuntu.14.04", "ubuntu", @@ -8027,20 +7695,6 @@ "any", "base" ], - "ubuntu.18.10-loongarch64": [ - "ubuntu.18.10-loongarch64", - "ubuntu.18.10", - "ubuntu-loongarch64", - "ubuntu", - "debian-loongarch64", - "debian", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "ubuntu.19.04": [ "ubuntu.19.04", "ubuntu", @@ -8106,20 +7760,6 @@ "any", "base" ], - "ubuntu.19.04-loongarch64": [ - "ubuntu.19.04-loongarch64", - "ubuntu.19.04", - "ubuntu-loongarch64", - "ubuntu", - "debian-loongarch64", - "debian", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "ubuntu.19.10": [ "ubuntu.19.10", "ubuntu", @@ -8185,20 +7825,6 @@ "any", "base" ], - "ubuntu.19.10-loongarch64": [ - "ubuntu.19.10-loongarch64", - "ubuntu.19.10", - "ubuntu-loongarch64", - "ubuntu", - "debian-loongarch64", - "debian", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "ubuntu.20.04": [ "ubuntu.20.04", "ubuntu", @@ -8264,20 +7890,6 @@ "any", "base" ], - "ubuntu.20.04-loongarch64": [ - "ubuntu.20.04-loongarch64", - "ubuntu.20.04", - "ubuntu-loongarch64", - "ubuntu", - "debian-loongarch64", - "debian", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "ubuntu.20.10": [ "ubuntu.20.10", "ubuntu", @@ -8343,20 +7955,6 @@ "any", "base" ], - "ubuntu.20.10-loongarch64": [ - "ubuntu.20.10-loongarch64", - "ubuntu.20.10", - "ubuntu-loongarch64", - "ubuntu", - "debian-loongarch64", - "debian", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "ubuntu.21.04": [ "ubuntu.21.04", "ubuntu", @@ -8422,20 +8020,6 @@ "any", "base" ], - "ubuntu.21.04-loongarch64": [ - "ubuntu.21.04-loongarch64", - "ubuntu.21.04", - "ubuntu-loongarch64", - "ubuntu", - "debian-loongarch64", - "debian", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "ubuntu.21.10": [ "ubuntu.21.10", "ubuntu", @@ -8501,20 +8085,6 @@ "any", "base" ], - "ubuntu.21.10-loongarch64": [ - "ubuntu.21.10-loongarch64", - "ubuntu.21.10", - "ubuntu-loongarch64", - "ubuntu", - "debian-loongarch64", - "debian", - "linux-loongarch64", - "linux", - "unix-loongarch64", - "unix", - "any", - "base" - ], "unix": [ "unix", "any", @@ -9198,4 +8768,4 @@ "any", "base" ] -} +} \ No newline at end of file diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json index 24ded362047ec1..76d454fc536c3a 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json @@ -3405,27 +3405,27 @@ "unix" ] }, - "unix-mips64": { + "unix-loongarch64": { "#import": [ "unix" ] }, - "unix-s390x": { + "unix-mips64": { "#import": [ "unix" ] }, - "unix-x64": { + "unix-s390x": { "#import": [ "unix" ] }, - "unix-x86": { + "unix-x64": { "#import": [ "unix" ] }, - "unix-loongarch64": { + "unix-x86": { "#import": [ "unix" ] @@ -3754,4 +3754,4 @@ ] } } -} +} \ No newline at end of file