From 9d5f27953e84a43a34496809480c54fb5f897286 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Mon, 14 Aug 2023 10:47:15 +0300 Subject: [PATCH 1/6] Make `--skip-unresolved` the default when not running from SDK --- src/tools/illink/src/linker/Linker/LinkContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/illink/src/linker/Linker/LinkContext.cs b/src/tools/illink/src/linker/Linker/LinkContext.cs index 8de76753dce6fe..2a26b739ff0d72 100644 --- a/src/tools/illink/src/linker/Linker/LinkContext.cs +++ b/src/tools/illink/src/linker/Linker/LinkContext.cs @@ -108,7 +108,7 @@ public Pipeline Pipeline { public readonly bool KeepMembersForDebugger = true; - public bool IgnoreUnresolved { get; set; } + public bool IgnoreUnresolved { get; set; } = true; public bool EnableReducedTracing { get; set; } From a22279919e46a056e99a48c27766f093c9a9ab79 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Mon, 14 Aug 2023 10:48:51 +0300 Subject: [PATCH 2/6] Fix command-line doc --- src/tools/illink/src/linker/Linker/Driver.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/illink/src/linker/Linker/Driver.cs b/src/tools/illink/src/linker/Linker/Driver.cs index 695b76c6df6c32..7b4a78a6903489 100644 --- a/src/tools/illink/src/linker/Linker/Driver.cs +++ b/src/tools/illink/src/linker/Linker/Driver.cs @@ -1336,7 +1336,7 @@ static void Usage () Console.WriteLine (" --custom-data KEY=VALUE Populates context data set with user specified key-value pair"); Console.WriteLine (" --deterministic Produce a deterministic output for modified assemblies"); Console.WriteLine (" --ignore-descriptors Skips reading embedded descriptors (short -z). Defaults to false"); - Console.WriteLine (" --skip-unresolved Ignore unresolved types, methods, and assemblies. Defaults to false"); + Console.WriteLine (" --skip-unresolved Ignore unresolved types, methods, and assemblies. Defaults to true"); Console.WriteLine (" --output-pinvokes PATH Output a JSON file with all modules and entry points of the P/Invokes found"); Console.WriteLine (" --verbose Log messages indicating progress and warnings"); Console.WriteLine (" --nowarn WARN Disable specific warning messages"); From 1152d6f6e0cda5689c51ce543cef40104c7a7482 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Thu, 17 Aug 2023 09:03:41 +0300 Subject: [PATCH 3/6] Update NullableOnConstraints test --- .../Attributes/OnlyKeepUsed/NullableOnConstraints.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/NullableOnConstraints.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/NullableOnConstraints.cs index b396bb3b10b568..ff81f5f98061df 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/NullableOnConstraints.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/NullableOnConstraints.cs @@ -7,6 +7,7 @@ namespace Mono.Linker.Tests.Cases.Attributes.OnlyKeepUsed { [SetupCSharpCompilerToUse ("csc")] [SetupLinkerArgument ("--used-attrs-only", "true")] + [SetupLinkerArgument ("--skip-unresolved", "false")] public class NullableOnConstraints { public static void Main () @@ -43,4 +44,4 @@ interface I class C where T : I? { } -} \ No newline at end of file +} From 6216c059852685298cded5f99d75421e6ef096b8 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Thu, 17 Aug 2023 09:04:17 +0300 Subject: [PATCH 4/6] chore: Update CanPreserveNullableCustomOperators test --- .../LinqExpressions/CanPreserveNullableCustomOperators.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/LinqExpressions/CanPreserveNullableCustomOperators.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/LinqExpressions/CanPreserveNullableCustomOperators.cs index 32398f667348c4..10dc5929f059d9 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/LinqExpressions/CanPreserveNullableCustomOperators.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/LinqExpressions/CanPreserveNullableCustomOperators.cs @@ -5,6 +5,7 @@ namespace Mono.Linker.Tests.Cases.LinqExpressions { [SetupCompileArgument ("/unsafe")] [SetupLinkerArgument ("--used-attrs-only")] + [SetupLinkerArgument ("--skip-unresolved", "false")] public class CanPreserveNullableCustomOperators { public static void Main () From 70ef17fcb453b3ee44e1363a5cc40cc3b33b575a Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Thu, 17 Aug 2023 09:06:46 +0300 Subject: [PATCH 5/6] Remove `--skip-unresolved` from targets as it's the default now in command-line linker --- .../illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets b/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets index 8f009acd7862d6..3ba13f1f5ad329 100644 --- a/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets +++ b/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets @@ -221,7 +221,6 @@ Copyright (c) .NET Foundation. All rights reserved. $(TreatWarningsAsErrors) - <_ExtraTrimmerArgs>--skip-unresolved true $(_ExtraTrimmerArgs) true From 8a99faba2a8467efbc60697e0fd67b243ede1836 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Fri, 1 Sep 2023 17:52:16 +0000 Subject: [PATCH 6/6] Fix tests that check --skip-unresolved false behavior --- .../References/MissingReferenceInUnusedCodePath.cs | 1 + .../References/MissingReferenceInUsedCodePath.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/References/MissingReferenceInUnusedCodePath.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/References/MissingReferenceInUnusedCodePath.cs index 16d5de6bd45402..8502fd005e20c3 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/References/MissingReferenceInUnusedCodePath.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/References/MissingReferenceInUnusedCodePath.cs @@ -11,6 +11,7 @@ namespace Mono.Linker.Tests.Cases.References; [NoLinkedOutput] [SetupCompileBefore ("missing.dll", new[] { "Dependencies/MissingAssembly.cs" })] [DeleteBefore ("missing.dll")] +[SetupLinkerArgument ("--skip-unresolved", "false")] public class MissingReferenceInUnusedCodePath { public static void Main () diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/References/MissingReferenceInUsedCodePath.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/References/MissingReferenceInUsedCodePath.cs index 99477f01d68213..18455ed3c38ecb 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/References/MissingReferenceInUsedCodePath.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/References/MissingReferenceInUsedCodePath.cs @@ -11,6 +11,7 @@ namespace Mono.Linker.Tests.Cases.References; [NoLinkedOutput] [SetupCompileBefore ("missing.dll", new[] { "Dependencies/MissingAssembly.cs" })] [DeleteBefore ("missing.dll")] +[SetupLinkerArgument ("--skip-unresolved", "false")] public class MissingReferenceInUsedCodePath { public static void Main ()