From 7758a1b267ae915e9dca1d22b0c2570456fc89c9 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 14 Nov 2024 18:48:10 -0800 Subject: [PATCH 1/8] [net11.0] Enable CoreCLR for all platforms. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🚧 This is a work in progress: currently it doesn't even build, because we don't have CoreCLR runtime packs for these platforms 🚧 We'll probably have to bring a few more of the changes here: https://github.com/xamarin/xamarin-macios/compare/net8.0...filipnavara:xamarin-macios:net8.0-coreclr-ioslike?expand=1 (but until we have runtime packs to unblock is, I can't confirm). --- Make.config | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Make.config b/Make.config index 701b297e8dd..8ae5e595a9f 100644 --- a/Make.config +++ b/Make.config @@ -433,6 +433,7 @@ DOTNET_PLATFORMS= ifdef INCLUDE_IOS DOTNET_PLATFORMS+=iOS +DOTNET_CORECLR_PLATFORMS+=iOS DOTNET_MONOVM_PLATFORMS+=iOS DOTNET_NATIVEAOT_PLATFORMS+=iOS DOTNET_IOS_RUNTIME_IDENTIFIERS_NO_ARCH=ios @@ -458,6 +459,7 @@ endif # INCLUDE_IOS ifdef INCLUDE_TVOS DOTNET_PLATFORMS+=tvOS +DOTNET_CORECLR_PLATFORMS+=tvOS DOTNET_MONOVM_PLATFORMS+=tvOS DOTNET_NATIVEAOT_PLATFORMS+=tvOS DOTNET_TVOS_RUNTIME_IDENTIFIERS_NO_ARCH=tvos @@ -483,6 +485,7 @@ endif ifdef INCLUDE_MACCATALYST DOTNET_PLATFORMS+=MacCatalyst +DOTNET_CORECLR_PLATFORMS+=MacCatalyst DOTNET_MONOVM_PLATFORMS+=MacCatalyst DOTNET_NATIVEAOT_PLATFORMS+=MacCatalyst DOTNET_MACCATALYST_RUNTIME_IDENTIFIERS_NO_ARCH=maccatalyst From b82dc531473c1f4353737df7fe014d7c0ffe9280 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 10 Nov 2025 16:49:37 +0100 Subject: [PATCH 2/8] [dotnet] Set _Lib[Mono|Xamarin]LinkMode to 'dylib' when using CoreCLR. --- dotnet/targets/Xamarin.Shared.Sdk.targets | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index c545cadcee6..413aad81c91 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -1199,9 +1199,11 @@ <_IsDedupEnabled Condition="'$(_IsDedupEnabled)' == '' And '$(_RunAotCompiler)' == 'true' And '$(IsMacEnabled)' == 'true' And '$(TargetArchitectures)' == 'ARM64' And '$(MtouchInterpreter)' != 'all'">true <_DedupAssembly Condition="'$(_IsDedupEnabled)' == 'true'">$(IntermediateOutputPath)aot-instances.dll + + <_LibMonoLinkMode Condition="'$(_LibMonoLinkMode)' == '' And '$(UseMonoRuntime)' == 'false'">dylib <_LibMonoLinkMode Condition="'$(_LibMonoLinkMode)' == '' And '$(_PlatformName)' == 'MacCatalyst'">static - <_LibMonoLinkMode Condition="'$(_LibMonoLinkMode)' == '' And ('$(ComputedPlatform)' != 'iPhone' Or '$(_PlatformName)' == 'macOS')">dylib + <_LibMonoLinkMode Condition="'$(_LibMonoLinkMode)' == '' And '$(ComputedPlatform)' != 'iPhone'">dylib <_LibMonoLinkMode Condition="'$(_LibMonoLinkMode)' == ''">static <_LibMonoExtension Condition="'$(_LibMonoLinkMode)' == 'dylib'">dylib <_LibMonoExtension Condition="'$(_LibMonoLinkMode)' == 'static'">a From 6417dde3f2d085e5face18fd7354e2002bd4975d Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 23 Oct 2025 11:58:00 +0200 Subject: [PATCH 3/8] [dotnet] Update KnownFrameworkReference with our runtime identifiers. This is a temporary fix until https://github.com/dotnet/sdk/pull/51428 is merged and packages are available. --- dotnet/targets/Microsoft.Sdk.Versions.template.props | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dotnet/targets/Microsoft.Sdk.Versions.template.props b/dotnet/targets/Microsoft.Sdk.Versions.template.props index 93dd8c43fcb..c71200a3325 100644 --- a/dotnet/targets/Microsoft.Sdk.Versions.template.props +++ b/dotnet/targets/Microsoft.Sdk.Versions.template.props @@ -43,5 +43,8 @@ RuntimePackRuntimeIdentifiers="@RUNTIME_PACK_RUNTIME_IDENTIFIERS@" Profile="@PLATFORM@" /> + + + From 77af2b81b3426b2f0c13970ec5af84cedad31032 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 10 Nov 2025 16:57:24 +0100 Subject: [PATCH 4/8] [dotnet] Set DOTNET_Interpreter and DOTNET_ReadyToRun to make sure everything is executed with the CoreCLR interpreter. Set DOTNET_Interpreter and DOTNET_ReadyToRun to make sure everything is executed with the CoreCLR interpreter (when CoreCLR is enabled). This is because only the interpreter works so far, ReadyToRun will come at a later stage. --- dotnet/targets/Xamarin.Shared.Sdk.targets | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index 413aad81c91..b997fbac4bf 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -1247,6 +1247,13 @@ " /> + + + + + <_BundlerEnvironmentVariables Include="DOTNET_Interpreter" Value="%2A%21%2A" /> + <_BundlerEnvironmentVariables Include="DOTNET_ReadyToRun" Value="0" /> + From 9208f1f708bc708d484ff353affe0112e12e5a6d Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 11 Nov 2025 11:38:18 +0100 Subject: [PATCH 5/8] [xharness] Add CoreCLR test variations. --- tests/xharness/Jenkins/TestVariationsFactory.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/xharness/Jenkins/TestVariationsFactory.cs b/tests/xharness/Jenkins/TestVariationsFactory.cs index c6bf837625e..4cf32382b0d 100644 --- a/tests/xharness/Jenkins/TestVariationsFactory.cs +++ b/tests/xharness/Jenkins/TestVariationsFactory.cs @@ -36,6 +36,8 @@ IEnumerable GetTestData (RunTestTask test) var x64_runtime_identifier = string.Empty; var arm64_sim_runtime_identifier = string.Empty; var x64_sim_runtime_identifier = string.Empty; + var supports_mono = test.Platform != TestPlatform.Mac; + var supports_coreclr = true; switch (test.Platform) { case TestPlatform.Mac: @@ -69,6 +71,17 @@ IEnumerable GetTestData (RunTestTask test) } } break; + case "introspection": + if (supports_coreclr && supports_mono) { // we only need specific coreclr test if we *also* support mono (otherwise the default test will be coreclr) + yield return new TestData { Variation = "CoreCLR", TestVariation = "coreclr", Ignored = ignore }; + } + break; + case "monotouch-test": + if (supports_coreclr && supports_mono) { // we only need specific coreclr test if we *also* support mono (otherwise the default test will be coreclr) + yield return new TestData { Variation = "Debug (CoreCLR)", TestVariation = "debug|coreclr", Ignored = ignore }; + yield return new TestData { Variation = "Release (CoreCLR)", TestVariation = "release|coreclr", Ignored = ignore }; + } + break; } switch (test.ProjectPlatform) { From b639a9ebb20ff6553c2d742a3d77d03579dd2381 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 29 Oct 2025 18:36:44 +0100 Subject: [PATCH 6/8] [monotouch-test] Fix the Symbols test for CoreCLR. --- tests/monotouch-test/mono/Symbols.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/monotouch-test/mono/Symbols.cs b/tests/monotouch-test/mono/Symbols.cs index b66f5acb080..34e300f086f 100644 --- a/tests/monotouch-test/mono/Symbols.cs +++ b/tests/monotouch-test/mono/Symbols.cs @@ -16,6 +16,7 @@ public void FunctionNames () bool nativeaot = symbols [1].Contains ("MonoTouchFixtures_Symbols__Collect"); bool llvmonly = symbols [1].Contains ("mono_llvmonly_runtime_invoke"); // LLVM inlines the Collect function, so 'Collect' doesn't show up in the stack trace :/ bool interp = false; + bool coreclr = false; if (!aot) { for (int i = 0; i < 5 && !interp; i++) { @@ -23,10 +24,12 @@ public void FunctionNames () * MONO_NEVER_INLINE, so they should show up in the backtrace * reliably */ interp |= symbols [i].Contains ("ves_pinvoke_method") || symbols [i].Contains ("do_icall"); + + coreclr |= symbols [i].Contains ("ExecuteInterpretedMethod"); } } - Assert.IsTrue (aot || interp || llvmonly || nativeaot, $"#1\n\t{string.Join ("\n\t", symbols)}"); + Assert.IsTrue (aot || interp || llvmonly || nativeaot || coreclr, $"#1\n\t{string.Join ("\n\t", symbols)}"); } void Collect () From d290546b0e6292eb94db798176ca389f43408efc Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 13 Nov 2025 21:55:02 +0100 Subject: [PATCH 7/8] [introspection] Ignore P/Invokes to QCall in ApiPInvokeTest. --- tests/introspection/ApiPInvokeTest.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/introspection/ApiPInvokeTest.cs b/tests/introspection/ApiPInvokeTest.cs index 5dee89e4e24..1a88902eb66 100644 --- a/tests/introspection/ApiPInvokeTest.cs +++ b/tests/introspection/ApiPInvokeTest.cs @@ -255,6 +255,9 @@ protected void Check (Assembly a) case "System.Net.Security.Native": path = null; break; + case "QCall": + // These symbols are inside libcoreclr.dylib, but they're private, so dlsym won't see them. + continue; } var lib = Dlfcn.dlopen (path, 0); From 27c8f7713a29e96379ceaaa9c44d0bb88d3d77d9 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 20 Nov 2025 19:39:43 +0100 Subject: [PATCH 8/8] [tests] Ignore CoreCLR tests when CoreCLR doesn't work (on x64 at the moment). --- tests/xharness/Jenkins/TestVariationsFactory.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/xharness/Jenkins/TestVariationsFactory.cs b/tests/xharness/Jenkins/TestVariationsFactory.cs index 4cf32382b0d..8e3c76fa002 100644 --- a/tests/xharness/Jenkins/TestVariationsFactory.cs +++ b/tests/xharness/Jenkins/TestVariationsFactory.cs @@ -38,6 +38,8 @@ IEnumerable GetTestData (RunTestTask test) var x64_sim_runtime_identifier = string.Empty; var supports_mono = test.Platform != TestPlatform.Mac; var supports_coreclr = true; + var coreclr_works = Harness.CanRunArm64 || test.Platform == TestPlatform.Mac; // ignore tests on x64 until https://github.com/dotnet/runtime/issues/121631 + var ignore_coreclr = coreclr_works ? ignore : true; switch (test.Platform) { case TestPlatform.Mac: @@ -73,13 +75,13 @@ IEnumerable GetTestData (RunTestTask test) break; case "introspection": if (supports_coreclr && supports_mono) { // we only need specific coreclr test if we *also* support mono (otherwise the default test will be coreclr) - yield return new TestData { Variation = "CoreCLR", TestVariation = "coreclr", Ignored = ignore }; + yield return new TestData { Variation = "CoreCLR", TestVariation = "coreclr", Ignored = ignore_coreclr }; } break; case "monotouch-test": if (supports_coreclr && supports_mono) { // we only need specific coreclr test if we *also* support mono (otherwise the default test will be coreclr) - yield return new TestData { Variation = "Debug (CoreCLR)", TestVariation = "debug|coreclr", Ignored = ignore }; - yield return new TestData { Variation = "Release (CoreCLR)", TestVariation = "release|coreclr", Ignored = ignore }; + yield return new TestData { Variation = "Debug (CoreCLR)", TestVariation = "debug|coreclr", Ignored = ignore_coreclr }; + yield return new TestData { Variation = "Release (CoreCLR)", TestVariation = "release|coreclr", Ignored = ignore_coreclr }; } break; }