diff --git a/docs/design/tools/illink/trimmed-assemblies.md b/docs/design/tools/illink/trimmed-assemblies.md index ac8e03fddc2aa9..fede239a17b52d 100644 --- a/docs/design/tools/illink/trimmed-assemblies.md +++ b/docs/design/tools/illink/trimmed-assemblies.md @@ -135,7 +135,7 @@ could be used instead of - + true diff --git a/eng/illink.targets b/eng/illink.targets index 29dd3dd83bf76a..3b4a9ec74be7ec 100644 --- a/eng/illink.targets +++ b/eng/illink.targets @@ -255,7 +255,7 @@ <_DependencyDirectories Remove="@(_DependencyDirectories)" /> <_DependencyDirectories Include="%(_DependencyDirectoriesNoSlash.PathWithoutSlash)" /> - + library @@ -264,7 +264,7 @@ $(ILLinkArgs) -d @(_DependencyDirectories->'"%(Identity)"', ' -d ') - - + all diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets index e758f681c3c0ee..c327c5d990e1b0 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets @@ -200,27 +200,14 @@ The .NET Foundation licenses this file to you under the MIT license. DependsOnTargets="$(IlcCompileDependsOn)"> - - <_IlcRootedAssembliesRaw Include="@(TrimmerRootAssembly)" Condition="%(TrimmerRootAssembly.RootMode) != 'EntryPoint'" /> - <_IlcRootedAssembliesRaw Include="@(ManagedAssemblyToLink)" Condition="%(ManagedAssemblyToLink.TrimMode) == 'copy'" /> - <_IlcConditionallyRootedAssembliesRaw Include="@(ManagedAssemblyToLink)" Condition="%(ManagedAssemblyToLink.TrimMode) == 'copyused'" /> - <_IlcTrimmedAssembliesRaw Include="@(ManagedAssemblyToLink)" Condition="%(ManagedAssemblyToLink.TrimMode) == 'link'" /> - <_IlcSingleWarnAssembliesRaw Include="@(ManagedAssemblyToLink)" Condition="%(ManagedAssemblyToLink.TrimmerSingleWarn) == 'true'" /> - <_IlcNoSingleWarnAssembliesRaw Include="@(ManagedAssemblyToLink)" Condition="%(ManagedAssemblyToLink.TrimmerSingleWarn) == 'false'" /> - - - - - <_IlcRootedAssemblies Include="@(_IlcRootedAssembliesRaw->'%(Filename)')" Condition="$([System.IO.File]::Exists('%(Identity)'))" /> - <_IlcRootedAssemblies Include="@(_IlcRootedAssembliesRaw)" Condition="!$([System.IO.File]::Exists('%(Identity)'))" /> - <_IlcConditionallyRootedAssemblies Include="@(_IlcConditionallyRootedAssembliesRaw->'%(Filename)')" Condition="$([System.IO.File]::Exists('%(Identity)'))" /> - <_IlcConditionallyRootedAssemblies Include="@(_IlcConditionallyRootedAssembliesRaw)" Condition="!$([System.IO.File]::Exists('%(Identity)'))" /> - <_IlcTrimmedAssemblies Include="@(_IlcTrimmedAssembliesRaw->'%(Filename)')" Condition="$([System.IO.File]::Exists('%(Identity)'))" /> - <_IlcTrimmedAssemblies Include="@(_IlcTrimmedAssembliesRaw)" Condition="!$([System.IO.File]::Exists('%(Identity)'))" /> - <_IlcSingleWarnAssemblies Include="@(_IlcSingleWarnAssembliesRaw->'%(Filename)')" Condition="$([System.IO.File]::Exists('%(Identity)'))" /> - <_IlcSingleWarnAssemblies Include="@(_IlcSingleWarnAssembliesRaw)" Condition="!$([System.IO.File]::Exists('%(Identity)'))" /> - <_IlcNoSingleWarnAssemblies Include="@(_IlcNoSingleWarnAssembliesRaw->'%(Filename)')" Condition="$([System.IO.File]::Exists('%(Identity)'))" /> - <_IlcNoSingleWarnAssemblies Include="@(_IlcNoSingleWarnAssembliesRaw)" Condition="!$([System.IO.File]::Exists('%(Identity)'))" /> + + + <_IlcRootedAssemblies Include="@(TrimmerRootAssembly)" Condition="%(TrimmerRootAssembly.RootMode) != 'EntryPoint'" /> + <_IlcRootedAssemblies Include="@(ManagedAssemblyToLink->'%(Filename)')" Condition="%(ManagedAssemblyToLink.TrimMode) == 'copy'" /> + <_IlcConditionallyRootedAssemblies Include="@(ManagedAssemblyToLink->'%(Filename)')" Condition="%(ManagedAssemblyToLink.TrimMode) == 'copyused'" /> + <_IlcTrimmedAssemblies Include="@(ManagedAssemblyToLink->'%(Filename)')" Condition="%(ManagedAssemblyToLink.TrimMode) == 'link'" /> + <_IlcSingleWarnAssemblies Include="@(ManagedAssemblyToLink->'%(Filename)')" Condition="%(ManagedAssemblyToLink.TrimmerSingleWarn) == 'true'" /> + <_IlcNoSingleWarnAssemblies Include="@(ManagedAssemblyToLink->'%(Filename)')" Condition="%(ManagedAssemblyToLink.TrimmerSingleWarn) == 'false'" /> diff --git a/src/libraries/oob-trim.proj b/src/libraries/oob-trim.proj index b17f8e920129a9..f3ffdc2eaec978 100644 --- a/src/libraries/oob-trim.proj +++ b/src/libraries/oob-trim.proj @@ -41,9 +41,13 @@ $(OOBILLinkArgs) --link-attributes "@(OOBLibrarySuppressionsXml->'%(FullPath)', '" --link-attributes "')" + + <_OOBRootAssemblyName Include="@(OOBAssemblyToTrim->'%(Filename)')" /> + + - + <_SharedFrameworkRootAssemblyName Include="@(SharedFrameworkAssembly->'%(Filename)')"> + library + - - + all diff --git a/src/mono/msbuild/apple/build/AppleBuild.LocalBuild.targets b/src/mono/msbuild/apple/build/AppleBuild.LocalBuild.targets index 14df939e12ffe6..c961260dc88c03 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.LocalBuild.targets +++ b/src/mono/msbuild/apple/build/AppleBuild.LocalBuild.targets @@ -53,7 +53,7 @@ + Include="%(AppleAssembliesToBundle.FileName)" /> diff --git a/src/tools/illink/src/ILLink.Shared/SharedStrings.resx b/src/tools/illink/src/ILLink.Shared/SharedStrings.resx index 65a4972e5eec82..9caa74973c69c0 100644 --- a/src/tools/illink/src/ILLink.Shared/SharedStrings.resx +++ b/src/tools/illink/src/ILLink.Shared/SharedStrings.resx @@ -301,7 +301,7 @@ Root assembly could not be found. - Root assembly '{0}' could not be found. + Root assembly with name '{0}' could not be found. XML descriptor file could not be found'. 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 16198390f88f7b..ad582eb7228919 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 @@ -283,7 +283,7 @@ Copyright (c) .NET Foundation. All rights reserved. - + diff --git a/src/tools/illink/src/linker/Linker.Steps/RootAssemblyInputStep.cs b/src/tools/illink/src/linker/Linker.Steps/RootAssemblyInputStep.cs index 3b80bdf0d04db1..1275e90939695c 100644 --- a/src/tools/illink/src/linker/Linker.Steps/RootAssemblyInputStep.cs +++ b/src/tools/illink/src/linker/Linker.Steps/RootAssemblyInputStep.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.IO; using ILLink.Shared; using Mono.Cecil; @@ -9,18 +8,18 @@ namespace Mono.Linker.Steps { public class RootAssemblyInput : BaseStep { - readonly string fileName; + readonly string assemblyName; readonly AssemblyRootMode rootMode; - public RootAssemblyInput(string fileName, AssemblyRootMode rootMode) + public RootAssemblyInput(string assemblyName, AssemblyRootMode rootMode) { - this.fileName = fileName; + this.assemblyName = assemblyName; this.rootMode = rootMode; } protected override void Process() { - AssemblyDefinition? assembly = LoadAssemblyFile(); + AssemblyDefinition? assembly = LoadAssemblyByName(); if (assembly == null) return; @@ -105,23 +104,11 @@ protected override void Process() } } - AssemblyDefinition? LoadAssemblyFile() + AssemblyDefinition? LoadAssemblyByName() { - AssemblyDefinition? assembly; - - if (File.Exists(fileName)) - { - assembly = Context.Resolver.GetAssembly(fileName); - Context.Resolver.CacheAssembly(assembly); - return assembly; - } - - // - // Quirks mode for netcore to support passing ambiguous assembly name - // - assembly = Context.TryResolve(fileName); + var assembly = Context.TryResolve(assemblyName); if (assembly == null) - Context.LogError(null, DiagnosticId.RootAssemblyCouldNotBeFound, fileName); + Context.LogError(null, DiagnosticId.RootAssemblyCouldNotBeFound, assemblyName); return assembly; } diff --git a/src/tools/illink/src/linker/Linker/Driver.cs b/src/tools/illink/src/linker/Linker/Driver.cs index c1934fbf2ba7d8..42d3d188b8328e 100644 --- a/src/tools/illink/src/linker/Linker/Driver.cs +++ b/src/tools/illink/src/linker/Linker/Driver.cs @@ -750,15 +750,9 @@ protected int SetupContext(ILogger? customLogger = null) } case "a": { - if (!GetStringParam(token, out string? assemblyFile)) + if (!GetStringParam(token, out string? assemblyName)) return -1; - if (!File.Exists(assemblyFile) && assemblyFile.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase)) - { - context.LogError(null, DiagnosticId.RootAssemblyCouldNotBeFound, assemblyFile); - return -1; - } - AssemblyRootMode rmode = AssemblyRootMode.AllMembers; var rootMode = GetNextStringValue(); if (rootMode != null) @@ -770,7 +764,7 @@ protected int SetupContext(ILogger? customLogger = null) rmode = parsed_rmode.Value; } - inputs.Add(new RootAssemblyInput(assemblyFile, rmode)); + inputs.Add(new RootAssemblyInput(assemblyName, rmode)); continue; } case "b": @@ -1460,7 +1454,7 @@ static void Usage() Console.WriteLine(_linker); Console.WriteLine($"illink [options] {resolvers}"); - Console.WriteLine(" -a FILE [MODE] Assembly file used as root assembly with optional MODE value to alter default root mode"); + Console.WriteLine(" -a ASSEMBLYNAME [MODE] Assembly name used as root assembly with optional MODE value to alter default root mode"); Console.WriteLine(" Mode can be one of the following values"); Console.WriteLine(" all: Keep all members in root assembly"); Console.WriteLine(" default: Use entry point for applications and all members for libraries"); diff --git a/src/tools/illink/test/ILLink.Tasks.Tests/Mock.cs b/src/tools/illink/test/ILLink.Tasks.Tests/Mock.cs index c4198109552f8b..574189e1198365 100644 --- a/src/tools/illink/test/ILLink.Tasks.Tests/Mock.cs +++ b/src/tools/illink/test/ILLink.Tasks.Tests/Mock.cs @@ -117,7 +117,7 @@ public IEnumerable GetRootAssemblies() if (!(step is RootAssemblyInput)) continue; - var assemblyName = (string)typeof(RootAssemblyInput).GetField("fileName", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(step); + var assemblyName = (string)typeof(RootAssemblyInput).GetField("assemblyName", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(step); if (assemblyName == null) continue; diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/CustomLibraryEventSource.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/CustomLibraryEventSource.cs index 43dc8232fa4049..b06be2416e4014 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/CustomLibraryEventSource.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/CustomLibraryEventSource.cs @@ -5,7 +5,7 @@ namespace Mono.Linker.Tests.Cases.BCLFeatures.ETW { [Reference("System.Diagnostics.Tracing.dll")] - [SetupLinkerArgument("-a", "test.exe", "library")] + [SetupLinkerArgument("-a", "test", "library")] [KeptMember(".ctor()")] public class CustomLibraryEventSource { diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/CommandLine/DuplicateRootAssembly.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/CommandLine/DuplicateRootAssembly.cs index 7cfb55ddf7fd2e..d18df9942e8f75 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/CommandLine/DuplicateRootAssembly.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/CommandLine/DuplicateRootAssembly.cs @@ -5,8 +5,8 @@ namespace Mono.Linker.Tests.Cases.CommandLine; -[SetupLinkerArgument("-a", "test.exe", "entrypoint")] -[SetupLinkerArgument("-a", "../input/test.exe", "entrypoint")] +[SetupLinkerArgument("-a", "test", "entrypoint")] +[SetupLinkerArgument("-a", "test", "entrypoint")] public class DuplicateRootAssembly { public static void Main() diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/CommandLine/MultipleEntryPointRoots.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/CommandLine/MultipleEntryPointRoots.cs index 25272e9465f8d3..edc9f53f9778fd 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/CommandLine/MultipleEntryPointRoots.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/CommandLine/MultipleEntryPointRoots.cs @@ -8,8 +8,8 @@ namespace Mono.Linker.Tests.Cases.CommandLine; [ExpectNonZeroExitCode(1)] [SetupCompileBefore("other.exe", new[] { "Dependencies/MultipleEntryPointRoots_Lib.cs" })] -[SetupLinkerArgument("-a", "test.exe", "entrypoint")] -[SetupLinkerArgument("-a", "other.exe", "entrypoint")] +[SetupLinkerArgument("-a", "test", "entrypoint")] +[SetupLinkerArgument("-a", "other", "entrypoint")] [LogContains("IL1048")] [NoLinkedOutput] public class MultipleEntryPointRoots diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/InterfaceImplementedThroughBaseInterface.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/InterfaceImplementedThroughBaseInterface.cs index 2a0e0859397738..0db1641b5051d6 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/InterfaceImplementedThroughBaseInterface.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/InterfaceImplementedThroughBaseInterface.cs @@ -12,8 +12,8 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces { [SkipUnresolved(true)] - [SetupLinkerArgument("-a", "test.exe", "library")] - [SetupLinkerArgument("-a", "library.dll", "library")] + [SetupLinkerArgument("-a", "test", "library")] + [SetupLinkerArgument("-a", "library", "library")] [TestCaseRequirements(TestRunCharacteristics.SupportsDefaultInterfaceMethods, "Requires support for default interface methods")] [Define("IL_ASSEMBLY_AVAILABLE")] [SetupCompileBefore("library.dll", new[] { "Dependencies/InterfaceImplementedThroughBaseInterface.il" })] diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/OnReferenceType/InterfaceTypeInOtherUsedOnlyByCopiedAssembly.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/OnReferenceType/InterfaceTypeInOtherUsedOnlyByCopiedAssembly.cs index c46304d27fc0df..5794fb8a94ea39 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/OnReferenceType/InterfaceTypeInOtherUsedOnlyByCopiedAssembly.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/OnReferenceType/InterfaceTypeInOtherUsedOnlyByCopiedAssembly.cs @@ -8,7 +8,7 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces.OnReferenceType [SetupCompileBefore("copy.dll", new[] { typeof(InterfaceTypeInOtherUsedOnlyByCopiedAssembly_Copy) }, new[] { "linked.dll" })] [SetupLinkerAction("copy", "copy")] - [SetupLinkerArgument("-a", "copy.dll")] + [SetupLinkerArgument("-a", "copy")] [KeptTypeInAssembly("linked.dll", typeof(InterfaceTypeInOtherUsedOnlyByCopiedAssembly_Link.IFoo))] [KeptMemberInAssembly("copy.dll", typeof(InterfaceTypeInOtherUsedOnlyByCopiedAssembly_Copy.A), "Method()")] diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/OnReferenceType/InterfaceTypeInOtherUsedOnlyByCopiedAssemblyExplicit.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/OnReferenceType/InterfaceTypeInOtherUsedOnlyByCopiedAssemblyExplicit.cs index 2225c06a5dfa45..4d73b819d73fe7 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/OnReferenceType/InterfaceTypeInOtherUsedOnlyByCopiedAssemblyExplicit.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/OnReferenceType/InterfaceTypeInOtherUsedOnlyByCopiedAssemblyExplicit.cs @@ -8,7 +8,7 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces.OnReferenceType [SetupCompileBefore("copy.dll", new[] { typeof(InterfaceTypeInOtherUsedOnlyByCopiedAssemblyExplicit_Copy) }, new[] { "linked.dll" })] [SetupLinkerAction("copy", "copy")] - [SetupLinkerArgument("-a", "copy.dll")] + [SetupLinkerArgument("-a", "copy")] [KeptMemberInAssembly("linked.dll", typeof(InterfaceTypeInOtherUsedOnlyByCopiedAssemblyExplicit_Link.IFoo), "Method()")] [KeptMemberInAssembly("copy.dll", typeof(InterfaceTypeInOtherUsedOnlyByCopiedAssemblyExplicit_Copy.A), "Mono.Linker.Tests.Cases.Inheritance.Interfaces.Dependencies.InterfaceTypeInOtherUsedOnlyByCopiedAssemblyExplicit_Link.IFoo.Method()")] diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/StaticAbstractInterfaceMethodsLibrary.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/StaticAbstractInterfaceMethodsLibrary.cs index 8995cd0271863a..8db08ba12b62cf 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/StaticAbstractInterfaceMethodsLibrary.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/StaticAbstractInterfaceMethodsLibrary.cs @@ -9,7 +9,7 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces.StaticInterfaceMethods { - [SetupLinkerArgument("-a", "test.exe", "library")] + [SetupLinkerArgument("-a", "test", "library")] public static class StaticAbstractInterfaceMethodsLibrary { public static void Main() diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/StaticVirtualInterfaceMethodsInPreservedScopeLibrary.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/StaticVirtualInterfaceMethodsInPreservedScopeLibrary.cs index fd6234398a2b1d..cf096f8f49c239 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/StaticVirtualInterfaceMethodsInPreservedScopeLibrary.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/StaticVirtualInterfaceMethodsInPreservedScopeLibrary.cs @@ -9,7 +9,7 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces.StaticInterfaceMethods { [SetupCompileBefore("library.dll", new[] { "Dependencies/Library.cs" })] [SetupLinkerAction("skip", "library")] - [SetupLinkerArgument("-a", "test.exe", "library")] + [SetupLinkerArgument("-a", "test", "library")] public static class StaticVirtualInterfaceMethodsInPreservedScopeLibrary { [Kept] diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/StaticVirtualInterfaceMethodsLibrary.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/StaticVirtualInterfaceMethodsLibrary.cs index a208e53a6ad53d..566898a723a431 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/StaticVirtualInterfaceMethodsLibrary.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/StaticVirtualInterfaceMethodsLibrary.cs @@ -9,7 +9,7 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces.StaticInterfaceMethods { [SetupCompileBefore("library.dll", new[] { "Dependencies/Library.cs" })] [SetupLinkerAction("skip", "library")] - [SetupLinkerArgument("-a", "test.exe", "library")] + [SetupLinkerArgument("-a", "test", "library")] public static class StaticVirtualInterfaceMethodsLibrary { [Kept] diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/LibraryWithUnresolvedInterfaces.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/LibraryWithUnresolvedInterfaces.cs index baadc626c5ffec..ccf45ab62be291 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/LibraryWithUnresolvedInterfaces.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/LibraryWithUnresolvedInterfaces.cs @@ -11,7 +11,7 @@ namespace Mono.Linker.Tests.Cases.Libraries [KeptAttributeAttribute(typeof(IgnoreTestCaseAttribute), By = Tool.Trimmer)] [SetupCompileBefore("copylibrary.dll", new[] { "Dependencies/CopyLibrary.cs" }, removeFromLinkerInput: true)] [SkipUnresolved(true)] - [SetupLinkerArgument("-a", "test.exe", "library")] + [SetupLinkerArgument("-a", "test", "library")] [SetupLinkerArgument("--enable-opt", "ipconstprop")] [VerifyMetadataNames] public class LibraryWithUnresolvedInterfaces diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/RootAllLibraryBehavior.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/RootAllLibraryBehavior.cs index 3f3f525c3813c8..ce0bc0d85c36de 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/RootAllLibraryBehavior.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/RootAllLibraryBehavior.cs @@ -26,7 +26,7 @@ namespace Mono.Linker.Tests.Cases.Libraries new string[] { "Dependencies/RootAllLibrary_Substitutions.xml", "ILLink.Substitutions.xml" }, })] - [SetupLinkerArgument("-a", "library.dll")] + [SetupLinkerArgument("-a", "library")] [IgnoreSubstitutions(false)] [IgnoreLinkAttributes(false)] diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/RootLibrary.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/RootLibrary.cs index 972b87d8b0b542..276d5c9303a8c2 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/RootLibrary.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/RootLibrary.cs @@ -15,7 +15,7 @@ namespace Mono.Linker.Tests.Cases.Libraries [KeptAttributeAttribute(typeof(IgnoreTestCaseAttribute), By = Tool.Trimmer)] [SetupCompileBefore("copylibrary.dll", new[] { "Dependencies/CopyLibrary.cs" })] [SetupLinkerAction("copy", "copylibrary")] - [SetupLinkerArgument("-a", "test.exe", "library")] + [SetupLinkerArgument("-a", "test", "library")] [SetupLinkerArgument("--enable-opt", "ipconstprop")] [VerifyMetadataNames] [SetupLinkerArgument("--feature", "Mono.Linker.Tests.Cases.Libraries.RootLibrary.FeatureGuardSubstitutionsTest.FeatureSwitch", "false")] diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/RootLibraryVisibleForwardersWithoutReference.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/RootLibraryVisibleForwardersWithoutReference.cs index 3335bfc2676a88..47b2bb632a16b1 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/RootLibraryVisibleForwardersWithoutReference.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/RootLibraryVisibleForwardersWithoutReference.cs @@ -13,7 +13,8 @@ namespace Mono.Linker.Tests.Cases.Libraries [SetupCompileBefore("library.dll", new[] { "Dependencies/RootLibraryVisibleForwarders_Lib.cs" }, outputSubFolder: "isolated")] [SetupLinkerLinkPublicAndFamily] - [SetupLinkerArgument("-a", "isolated/library.dll", "visible")] // Checks for no-eager exported type resolving + [SetupLinkerArgument("-reference", "isolated/library.dll")] + [SetupLinkerArgument("-a", "library", "visible")] // Checks for no-eager exported type resolving [Define("RootLibraryVisibleForwarders")] [Kept] diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/LinkXml/UsedNonRequiredExportedTypeIsKeptWhenRooted.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/LinkXml/UsedNonRequiredExportedTypeIsKeptWhenRooted.cs index 84c371bc7ae89c..eec5a01c6f8682 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/LinkXml/UsedNonRequiredExportedTypeIsKeptWhenRooted.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/LinkXml/UsedNonRequiredExportedTypeIsKeptWhenRooted.cs @@ -7,7 +7,7 @@ namespace Mono.Linker.Tests.Cases.LinkXml [KeptAttributeAttribute(typeof(IgnoreTestCaseAttribute), By = Tool.Trimmer)] [SetupLinkerDescriptorFile("UsedNonRequiredExportedTypeIsKeptWhenRooted.xml")] - [SetupLinkerArgument("-a", "libfwd.dll", "visible")] + [SetupLinkerArgument("-a", "libfwd", "visible")] [SetupCompileBefore("libfwd.dll", new[] { "Dependencies/UsedNonRequiredExportedTypeIsKeptWhenRooted_lib.cs" })] [SetupCompileAfter("lib.dll", new[] { "Dependencies/UsedNonRequiredExportedTypeIsKeptWhenRooted_lib.cs" })] diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Metadata/RootLibraryAssemblyNamesAreKept.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Metadata/RootLibraryAssemblyNamesAreKept.cs index f532cec91cba66..a4029d39e71efd 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Metadata/RootLibraryAssemblyNamesAreKept.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Metadata/RootLibraryAssemblyNamesAreKept.cs @@ -4,7 +4,7 @@ namespace Mono.Linker.Tests.Cases.Metadata { [VerifyMetadataNames] - [SetupLinkerArgument("-a", "test.exe", "library")] + [SetupLinkerArgument("-a", "test", "library")] [KeptMember(".ctor()")] public class RootLibraryAssemblyNamesAreKept { diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Metadata/RootVisibleAssemblyNamesAreKept.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Metadata/RootVisibleAssemblyNamesAreKept.cs index ffa36015325068..64303abf803dd3 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Metadata/RootVisibleAssemblyNamesAreKept.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Metadata/RootVisibleAssemblyNamesAreKept.cs @@ -4,7 +4,7 @@ namespace Mono.Linker.Tests.Cases.Metadata { [VerifyMetadataNames] - [SetupLinkerArgument("-a", "test.exe", "visible")] + [SetupLinkerArgument("-a", "test", "visible")] [KeptMember(".ctor()")] public class RootVisibleAssemblyNamesAreKept { diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/ObjectGetTypeLibraryMode.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/ObjectGetTypeLibraryMode.cs index 8ecbc00cb98fc7..60eca1de3f8a68 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/ObjectGetTypeLibraryMode.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/ObjectGetTypeLibraryMode.cs @@ -7,7 +7,7 @@ namespace Mono.Linker.Tests.Cases.Reflection { - [SetupLinkerArgument("-a", "test.exe", "library")] + [SetupLinkerArgument("-a", "test", "library")] [ExpectedNoWarnings] [KeptMember(".ctor()")] public class ObjectGetTypeLibraryMode diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchyLibraryModeSuppressions.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchyLibraryModeSuppressions.cs index 2945e16f85441f..225259d356b986 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchyLibraryModeSuppressions.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchyLibraryModeSuppressions.cs @@ -7,7 +7,7 @@ namespace Mono.Linker.Tests.Cases.Reflection { - [SetupLinkerArgument("-a", "test.exe", "library")] + [SetupLinkerArgument("-a", "test", "library")] [ExpectedNoWarnings] [KeptMember(".ctor()")] public class TypeHierarchyLibraryModeSuppressions diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresInLibraryAssembly.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresInLibraryAssembly.cs index e2bfd58f2d4cf1..8eea7b1375e593 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresInLibraryAssembly.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresInLibraryAssembly.cs @@ -8,7 +8,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability { - [SetupLinkerArgument("-a", "test.exe", "library")] + [SetupLinkerArgument("-a", "test", "library")] [SkipKeptItemsValidation] [ExpectedNoWarnings] diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/UnreachableBody/LinkedOtherIncludedLibrary.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/UnreachableBody/LinkedOtherIncludedLibrary.cs index 49defd3721fe03..7c5124cd29542c 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/UnreachableBody/LinkedOtherIncludedLibrary.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/UnreachableBody/LinkedOtherIncludedLibrary.cs @@ -5,7 +5,7 @@ namespace Mono.Linker.Tests.Cases.UnreachableBody { #if NET - [SetupLinkerArgument("-a", "other2.dll")] + [SetupLinkerArgument("-a", "other2")] #else [SetupLinkerArgument("-r", "other2")] #endif diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/UnreachableBody/LinkedOtherIncludedLibraryNoInstanceCtor.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/UnreachableBody/LinkedOtherIncludedLibraryNoInstanceCtor.cs index bbfdfe0fc3dea5..ae071f2adf5375 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/UnreachableBody/LinkedOtherIncludedLibraryNoInstanceCtor.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/UnreachableBody/LinkedOtherIncludedLibraryNoInstanceCtor.cs @@ -6,7 +6,7 @@ namespace Mono.Linker.Tests.Cases.UnreachableBody [SkipUnresolved(true)] [Define("OTHER_INCLUDED")] #if NET - [SetupLinkerArgument("-a", "other.dll", "visible")] + [SetupLinkerArgument("-a", "other", "visible")] #else [SetupLinkerArgument("-r", "other")] #endif diff --git a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadataProvider.cs b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadataProvider.cs index 412c9fcc636ebd..88b617ea3f1bbd 100644 --- a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadataProvider.cs +++ b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadataProvider.cs @@ -82,7 +82,7 @@ public virtual TestCaseLinkerOptions GetLinkerOptions(NPath inputPath) values[0] = string.Concat(values[0].AsSpan(0, pos + 1), Path.Combine(inputPath, custom_assembly_path)); } break; - case "-a": + case "-reference": if (!Path.IsPathRooted(values[0])) values[0] = Path.Combine(inputPath, values[0]); diff --git a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TrimmingArgumentBuilder.cs b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TrimmingArgumentBuilder.cs index b629358445f694..25811091b49cda 100644 --- a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TrimmingArgumentBuilder.cs +++ b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TrimmingArgumentBuilder.cs @@ -57,29 +57,29 @@ public virtual void AddDefaultAction(string value) Append(value); } - public virtual void RootAssemblyEntryPoint(string fileName) + public virtual void RootAssemblyEntryPoint(string assemblyName) { Append("-a"); - Append(fileName); + Append(assemblyName); Append("entrypoint"); } - public virtual void RootAssemblyVisible(string fileName) + public virtual void RootAssemblyVisible(string assemblyName) { #if NET Append("-a"); - Append(fileName); + Append(assemblyName); Append("visible"); #else Append("-r"); - Append(fileName); + Append(assemblyName); #endif } - public virtual void RootAssembly(string fileName) + public virtual void RootAssembly(string assemblyName) { Append("-a"); - Append(fileName); + Append(assemblyName); } public virtual void IgnoreDescriptors(bool value) @@ -191,12 +191,13 @@ public virtual void AddAdditionalArgument(string flag, string[] values) public virtual void ProcessTestInputAssembly(NPath inputAssemblyPath) { + var assemblyName = inputAssemblyPath.FileNameWithoutExtension; if (_metadataProvider.LinkPublicAndFamily()) - RootAssemblyVisible(inputAssemblyPath.ToString()); + RootAssemblyVisible(assemblyName); else if (_metadataProvider.LinkAll()) - RootAssembly(inputAssemblyPath.ToString()); + RootAssembly(assemblyName); else - RootAssemblyEntryPoint(inputAssemblyPath.ToString()); + RootAssemblyEntryPoint(assemblyName); } public virtual void ProcessOptions(TestCaseLinkerOptions options)