From b473edb501241d026eb7075607797abaef440105 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Wed, 22 Jul 2020 08:48:07 -0700 Subject: [PATCH 1/8] Add step to run linker on entire runtime pack during libraries build --- eng/Configurations.props | 1 + eng/illink.targets | 47 ++++++++----- src/libraries/Directory.Build.props | 6 ++ src/libraries/Directory.Build.targets | 3 + src/libraries/illink-sharedframework.proj | 85 +++++++++++++++++++++++ src/libraries/pretest.proj | 13 ++++ src/libraries/src.proj | 12 +++- 7 files changed, 148 insertions(+), 19 deletions(-) create mode 100644 src/libraries/illink-sharedframework.proj diff --git a/eng/Configurations.props b/eng/Configurations.props index 59424f7cc30a6..ab2f5c414380d 100644 --- a/eng/Configurations.props +++ b/eng/Configurations.props @@ -34,6 +34,7 @@ + Debug $(Configuration) $(Configuration) Debug diff --git a/eng/illink.targets b/eng/illink.targets index ddd4936cc2647..72cf9a9b4d1a8 100644 --- a/eng/illink.targets +++ b/eng/illink.targets @@ -56,18 +56,18 @@ Must be enabled by setting BinPlaceILLinkTrimAssembly=true --> - + $(ArtifactsBinDir)ILLinkTrimAssembly/$(BuildSettings)/trimmed TrimmedItem - - + + $(ArtifactsBinDir)ILLinkTrimAssembly/$(BuildSettings)/reports TrimmingReport - - - $(ArtifactsBinDir)ILLinkTrimAssembly/$(BuildSettings)/pretrimmed + + + $(LibrariesPretrimmedArtifactsPath) PreTrimmedItem - + + + + + $(LibrariesPretrimmedArtifactsPath) + PreTrimmedItem + + + $(ILLinkArgs) --keep-dep-attributes true - $(ILLinkArgs) --nowarn IL2006;IL2008;IL2009;IL2012;IL2025;IL2026;IL2035;IL2041 + $(ILLinkArgs) --nowarn IL2006;IL2008;IL2009;IL2012;IL2025;IL2026;IL2035;IL2050 @@ -312,7 +323,7 @@ diff --git a/src/libraries/Directory.Build.props b/src/libraries/Directory.Build.props index 57898d4ff67e4..eb1e37ed06760 100644 --- a/src/libraries/Directory.Build.props +++ b/src/libraries/Directory.Build.props @@ -328,4 +328,10 @@ false true + + + $(ArtifactsBinDir)ILLinkTrimAssembly/$(BuildSettings)/pretrimmed + $(ArtifactsBinDir)ILLinkTrimAssembly/$(BuildSettings)/entire_runtimepack_trimmed + + diff --git a/src/libraries/Directory.Build.targets b/src/libraries/Directory.Build.targets index cc196f26392a7..6fbc161b120dc 100644 --- a/src/libraries/Directory.Build.targets +++ b/src/libraries/Directory.Build.targets @@ -64,6 +64,9 @@ true true true + + + false diff --git a/src/libraries/illink-sharedframework.proj b/src/libraries/illink-sharedframework.proj new file mode 100644 index 0000000000000..83ab7da99dbea --- /dev/null +++ b/src/libraries/illink-sharedframework.proj @@ -0,0 +1,85 @@ + + + + + + + $(ILLinkArgs) -c link + + $(ILLinkArgs) -t + + $(ILLinkArgs) -b true + + $(ILLinkArgs) --strip-descriptors false + + $(ILLinkArgs) -x "$(ILLinkTrimXmlLibraryBuild)" + + $(ILLinkArgs) --strip-substitutions false + + + $(ILLinkArgs) --strip-link-attributes false --ignore-link-attributes true + + $(ILLinkArgs) --skip-unresolved true + + $(ILLinkArgs) --disable-opt unusedinterfaces + + $(ILLinkArgs) --keep-dep-attributes true + + $(ILLinkArgs) --nowarn IL2006;IL2009;IL2025;IL2026;IL2035;IL2050 + + + + + <_DependencyDirectories Include="$(LibrariesPretrimmedArtifactsPath.TrimEnd('\'))" /> + <_DependencyDirectories Include="$(CoreCLRArtifactsPath)IL" /> + + + + $(ILLinkArgs) -d @(_DependencyDirectories->'"%(Identity)"', ' -d ') + + + + <_AssembliesToLink Include="System.Private.CoreLib" /> + + <_LibrariesToLink Include="$(LibrariesPretrimmedArtifactsPath)*.dll" /> + <_AssembliesToLink Include="@(_LibrariesToLink->'%(FileName)')" /> + + + + $(ILLinkArgs) -a @(_AssembliesToLink->'%(Identity)', ' -a ') + + + $(ILLinkArgs) -p copy System.Private.CoreLib + + + + + <_DotNetHostDirectory>$(RepoRoot).dotnet + <_DotNetHostFileName>dotnet + <_DotNetHostFileName Condition=" '$(OS)' == 'Windows_NT' ">dotnet.exe + + + + + + + + + + diff --git a/src/libraries/pretest.proj b/src/libraries/pretest.proj index 5cd55be973cb4..5a24a1797a22c 100644 --- a/src/libraries/pretest.proj +++ b/src/libraries/pretest.proj @@ -27,6 +27,19 @@ Properties="$(TraversalGlobalProperties)" /> + + + + + + + + + + + - @@ -49,6 +51,14 @@ Properties="$(TraversalGlobalProperties)" /> + + + + From 6e5944d91f42f8795320d63c9208d7be8d179866 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Thu, 30 Jul 2020 23:13:41 -0700 Subject: [PATCH 2/8] Address feedback --- eng/illink.targets | 22 +++++++++------------- src/libraries/Directory.Build.props | 5 +++-- src/libraries/Directory.Build.targets | 3 --- src/libraries/illink-sharedframework.proj | 3 --- src/libraries/pretest.proj | 13 ------------- 5 files changed, 12 insertions(+), 34 deletions(-) diff --git a/eng/illink.targets b/eng/illink.targets index 72cf9a9b4d1a8..1842ce4e1b335 100644 --- a/eng/illink.targets +++ b/eng/illink.targets @@ -52,18 +52,24 @@ - - $(ArtifactsBinDir)ILLinkTrimAssembly/$(BuildSettings)/trimmed + $([MSBuild]::NormalizePath('$(LibrariesTrimmingArtifactsRoot)', 'trimmed')) TrimmedItem - $(ArtifactsBinDir)ILLinkTrimAssembly/$(BuildSettings)/reports + $([MSBuild]::NormalizePath('$(LibrariesTrimmingArtifactsRoot)', 'reports')) TrimmingReport + + + + $(LibrariesPretrimmedArtifactsPath) PreTrimmedItem @@ -184,16 +190,6 @@ - - - - $(LibrariesPretrimmedArtifactsPath) - PreTrimmedItem - - - - false diff --git a/src/libraries/illink-sharedframework.proj b/src/libraries/illink-sharedframework.proj index 83ab7da99dbea..6b4c48b8d119d 100644 --- a/src/libraries/illink-sharedframework.proj +++ b/src/libraries/illink-sharedframework.proj @@ -76,9 +76,6 @@ ExtraArgs="$(ILLinkArgs)" ToolExe="$(_DotNetHostFileName)" ToolPath="$(_DotNetHostDirectory)" /> - - - diff --git a/src/libraries/pretest.proj b/src/libraries/pretest.proj index 5a24a1797a22c..5cd55be973cb4 100644 --- a/src/libraries/pretest.proj +++ b/src/libraries/pretest.proj @@ -27,19 +27,6 @@ Properties="$(TraversalGlobalProperties)" /> - - - - - - - - - - Date: Fri, 31 Jul 2020 09:18:05 -0700 Subject: [PATCH 3/8] Only run for NetCoreAppCurrent --- src/libraries/illink-sharedframework.proj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libraries/illink-sharedframework.proj b/src/libraries/illink-sharedframework.proj index 6b4c48b8d119d..98a93f34cc90b 100644 --- a/src/libraries/illink-sharedframework.proj +++ b/src/libraries/illink-sharedframework.proj @@ -1,7 +1,8 @@ + AfterTargets="Build" + Condition="'$(BuildTargetFramework)' == '$(NetCoreAppCurrent)'"> From 7da645648d6d1aefb12b9be0ef9514c2b63903d0 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Fri, 31 Jul 2020 12:01:42 -0700 Subject: [PATCH 4/8] Include appropriate S.P.CoreLib --- src/libraries/illink-sharedframework.proj | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libraries/illink-sharedframework.proj b/src/libraries/illink-sharedframework.proj index 98a93f34cc90b..9548268a7a535 100644 --- a/src/libraries/illink-sharedframework.proj +++ b/src/libraries/illink-sharedframework.proj @@ -42,7 +42,8 @@ <_DependencyDirectories Include="$(LibrariesPretrimmedArtifactsPath.TrimEnd('\'))" /> - <_DependencyDirectories Include="$(CoreCLRArtifactsPath)IL" /> + <_DependencyDirectories Condition="'$(RuntimeFlavor)' == 'CoreCLR'" Include="$([MSBuild]::NormalizePath('$(CoreCLRArtifactsPath)', 'IL'))" /> + <_DependencyDirectories Condition="'$(RuntimeFlavor)' == 'Mono'" Include="$([MSBuild]::NormalizePath('$(MonoArtifactsPath)', 'IL'))" /> @@ -79,5 +80,5 @@ ToolPath="$(_DotNetHostDirectory)" /> - + From aa9cd3ab2607deebf4f90ec1114a11417a152816 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Mon, 3 Aug 2020 12:17:21 -0700 Subject: [PATCH 5/8] Address review feedback --- eng/Configurations.props | 1 - eng/illink.targets | 8 +---- src/libraries/Directory.Build.props | 1 - ...k.proj => illink-sharedframeworks.targets} | 31 ++++++++++--------- src/libraries/src.proj | 13 ++------ 5 files changed, 21 insertions(+), 33 deletions(-) rename src/libraries/{illink-sharedframework.proj => illink-sharedframeworks.targets} (77%) diff --git a/eng/Configurations.props b/eng/Configurations.props index ab2f5c414380d..59424f7cc30a6 100644 --- a/eng/Configurations.props +++ b/eng/Configurations.props @@ -34,7 +34,6 @@ - Debug $(Configuration) $(Configuration) Debug diff --git a/eng/illink.targets b/eng/illink.targets index 1842ce4e1b335..e0baead48fcc9 100644 --- a/eng/illink.targets +++ b/eng/illink.targets @@ -64,14 +64,8 @@ $([MSBuild]::NormalizePath('$(LibrariesTrimmingArtifactsRoot)', 'reports')) TrimmingReport - - - - - $(LibrariesPretrimmedArtifactsPath) + $([MSBuild]::NormalizePath('$(LibrariesTrimmingArtifactsRoot)', 'pretrimmed')) PreTrimmedItem diff --git a/src/libraries/Directory.Build.props b/src/libraries/Directory.Build.props index 7efa6125229f8..a2f6b39f8abbf 100644 --- a/src/libraries/Directory.Build.props +++ b/src/libraries/Directory.Build.props @@ -331,7 +331,6 @@ $([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'ILLinkTrimAssembly', '$(BuildSettings)')) - $([MSBuild]::NormalizePath('$(LibrariesTrimmingArtifactsRoot)', 'pretrimmed')) $([MSBuild]::NormalizePath('$(LibrariesTrimmingArtifactsRoot)', 'trimmed-runtimepack')) diff --git a/src/libraries/illink-sharedframework.proj b/src/libraries/illink-sharedframeworks.targets similarity index 77% rename from src/libraries/illink-sharedframework.proj rename to src/libraries/illink-sharedframeworks.targets index 9548268a7a535..193f6b036cae5 100644 --- a/src/libraries/illink-sharedframework.proj +++ b/src/libraries/illink-sharedframeworks.targets @@ -1,8 +1,6 @@ - + - + @@ -39,11 +37,19 @@ $(ILLinkArgs) --nowarn IL2006;IL2009;IL2025;IL2026;IL2035;IL2050 + + + + + + + <_AssemblyPaths>$(MicrosoftNetCoreAppRuntimePackRidLibTfmDir);$(SystemPrivateCoreLibPath) + + - - <_DependencyDirectories Include="$(LibrariesPretrimmedArtifactsPath.TrimEnd('\'))" /> - <_DependencyDirectories Condition="'$(RuntimeFlavor)' == 'CoreCLR'" Include="$([MSBuild]::NormalizePath('$(CoreCLRArtifactsPath)', 'IL'))" /> - <_DependencyDirectories Condition="'$(RuntimeFlavor)' == 'Mono'" Include="$([MSBuild]::NormalizePath('$(MonoArtifactsPath)', 'IL'))" /> + + <_DependencyDirectories Include="$(MicrosoftNetCoreAppRuntimePackRidLibTfmDir.TrimEnd('\'))" /> @@ -53,15 +59,12 @@ <_AssembliesToLink Include="System.Private.CoreLib" /> - <_LibrariesToLink Include="$(LibrariesPretrimmedArtifactsPath)*.dll" /> + <_LibrariesToLink Include="$(MicrosoftNetCoreAppRuntimePackRidLibTfmDir)*.dll" /> <_AssembliesToLink Include="@(_LibrariesToLink->'%(FileName)')" /> - $(ILLinkArgs) -a @(_AssembliesToLink->'%(Identity)', ' -a ') - - - $(ILLinkArgs) -p copy System.Private.CoreLib + $(ILLinkArgs) -r @(_AssembliesToLink->'%(Identity)', ' -r ') - @@ -51,13 +49,8 @@ Properties="$(TraversalGlobalProperties)" /> - - - + Date: Mon, 3 Aug 2020 21:37:04 -0700 Subject: [PATCH 6/8] Add common property group for shared linker args; remove unneeded changes from PR --- eng/illink.targets | 58 +++++++++++-------- src/libraries/Directory.Build.props | 3 +- src/libraries/illink-sharedframeworks.targets | 21 +------ 3 files changed, 37 insertions(+), 45 deletions(-) diff --git a/eng/illink.targets b/eng/illink.targets index e0baead48fcc9..4d76c0718db33 100644 --- a/eng/illink.targets +++ b/eng/illink.targets @@ -52,22 +52,22 @@ - - - $([MSBuild]::NormalizePath('$(LibrariesTrimmingArtifactsRoot)', 'trimmed')) + + $(ArtifactsBinDir)ILLinkTrimAssembly/$(BuildSettings)/trimmed TrimmedItem - - - $([MSBuild]::NormalizePath('$(LibrariesTrimmingArtifactsRoot)', 'reports')) + + + $(ArtifactsBinDir)ILLinkTrimAssembly/$(BuildSettings)/reports TrimmingReport - - - $([MSBuild]::NormalizePath('$(LibrariesTrimmingArtifactsRoot)', 'pretrimmed')) + + + $(ArtifactsBinDir)ILLinkTrimAssembly/$(BuildSettings)/pretrimmed PreTrimmedItem - + - - - + + - $(ILLinkArgs)-r $(TargetName) - - $(ILLinkArgs) -c skip - - $(ILLinkArgs) -u skip - - $(ILLinkArgs) -p link $(TargetName) $(ILLinkArgs) -t - $(ILLinkArgs) -b true $(ILLinkArgs) --strip-descriptors false @@ -214,6 +202,26 @@ $(ILLinkArgs) --skip-unresolved true $(ILLinkArgs) --disable-opt unusedinterfaces + + + + + + + + $(ILLinkArgs) -r $(TargetName) + + $(ILLinkArgs) -c skip + + $(ILLinkArgs) -u skip + + $(ILLinkArgs) -p link $(TargetName) + $(ILLinkArgs) -b true $(ILLinkArgs) --keep-dep-attributes true diff --git a/src/libraries/Directory.Build.props b/src/libraries/Directory.Build.props index a2f6b39f8abbf..fa087cfc37cce 100644 --- a/src/libraries/Directory.Build.props +++ b/src/libraries/Directory.Build.props @@ -330,8 +330,7 @@ - $([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'ILLinkTrimAssembly', '$(BuildSettings)')) - $([MSBuild]::NormalizePath('$(LibrariesTrimmingArtifactsRoot)', 'trimmed-runtimepack')) + $([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'ILLinkTrimAssembly', '$(BuildSettings)', 'trimmed-runtimepack')) diff --git a/src/libraries/illink-sharedframeworks.targets b/src/libraries/illink-sharedframeworks.targets index 193f6b036cae5..d4b1aa79c3236 100644 --- a/src/libraries/illink-sharedframeworks.targets +++ b/src/libraries/illink-sharedframeworks.targets @@ -1,29 +1,14 @@ - + $(ILLinkArgs) -c link - - $(ILLinkArgs) -t $(ILLinkArgs) -b true - - $(ILLinkArgs) --strip-descriptors false - - $(ILLinkArgs) -x "$(ILLinkTrimXmlLibraryBuild)" - - $(ILLinkArgs) --strip-substitutions false - - - $(ILLinkArgs) --strip-link-attributes false --ignore-link-attributes true - - $(ILLinkArgs) --skip-unresolved true - - $(ILLinkArgs) --disable-opt unusedinterfaces - - $(ILLinkArgs) --keep-dep-attributes true + $(ILLinkArgs) -t - - $(ILLinkArgs) --strip-descriptors false - - $(ILLinkArgs) -x "$(ILLinkTrimXmlLibraryBuild)" - - $(ILLinkArgs) --strip-substitutions false $(ILLinkArgs) --strip-link-attributes false --ignore-link-attributes true @@ -222,6 +216,12 @@ $(ILLinkArgs) -p link $(TargetName) $(ILLinkArgs) -b true + + $(ILLinkArgs) --strip-descriptors false + + $(ILLinkArgs) -x "$(ILLinkTrimXmlLibraryBuild)" + + $(ILLinkArgs) --strip-substitutions false $(ILLinkArgs) --keep-dep-attributes true $(ILLinkArgs) -c link