From c294b47ff6713fb07dc913fba7bc33959c57e54e Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 9 Jul 2020 17:58:31 +0200 Subject: [PATCH 1/6] Add always trimmed attributes list for browser config Example of size reduction on SPC with the most minimalistic Hello World sample. | System.Private.CoreLib | Size (kB) | Delta | |-|-|-| | Original | 1358 kB | - | | Trimmed | 1271 kB | - 87 kB | --- eng/illink.targets | 20 +-- .../System.Private.CoreLib.csproj | 3 + .../src/ILLink/ILLink.LinkAttributes.wasm.xml | 142 ++++++++++++++++++ 3 files changed, 156 insertions(+), 9 deletions(-) create mode 100644 src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml diff --git a/eng/illink.targets b/eng/illink.targets index fc38a10979f854..3cade70c8a2952 100644 --- a/eng/illink.targets +++ b/eng/illink.targets @@ -51,9 +51,9 @@ - + --> $(ArtifactsBinDir)ILLinkTrimAssembly/$(BuildSettings)/trimmed @@ -111,11 +111,11 @@ - + - @@ -152,7 +152,7 @@ - @@ -186,6 +186,8 @@ $(ILLinkArgs) -x "$(ILLinkTrimXmlLibraryBuild)" $(ILLinkArgs) --strip-substitutions false + + $(ILLinkArgs) --strip-link-attributes false $(ILLinkArgs) --skip-unresolved true @@ -235,7 +237,7 @@ <_DotNetHostFileName>dotnet <_DotNetHostFileName Condition=" '$(OS)' == 'Windows_NT' ">dotnet.exe - + - - - diff --git a/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj index 2eb2ec324e1f13..5cdb8f1698da9e 100644 --- a/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -152,6 +152,9 @@ + + diff --git a/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml b/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml new file mode 100644 index 00000000000000..c613fdf807f9a0 --- /dev/null +++ b/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 08d790a3ba608168dfff3d1a15a522545b9cb7da Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 9 Jul 2020 19:01:10 +0200 Subject: [PATCH 2/6] Review feedback --- .../src/ILLink/ILLink.LinkAttributes.wasm.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml b/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml index c613fdf807f9a0..02f4c5e27929cb 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml +++ b/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml @@ -7,9 +7,6 @@ - - - @@ -57,9 +54,6 @@ - - - @@ -86,9 +80,6 @@ - - - From ffe0b6d9e1148ce2da25d480ac3103d1872233f0 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Thu, 9 Jul 2020 14:01:46 -0500 Subject: [PATCH 3/6] Combine and embed the ILLink.LinkAttributes.xml file into the assembly. --- eng/illink.targets | 27 +++++++++++++++++-- .../System.Private.CoreLib.csproj | 4 +-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/eng/illink.targets b/eng/illink.targets index 3cade70c8a2952..7ceaa32557897f 100644 --- a/eng/illink.targets +++ b/eng/illink.targets @@ -41,6 +41,7 @@ $(IntermediateOutputPath)ILLink.Descriptors.xml $(IntermediateOutputPath)ILLink.Substitutions.xml + $(IntermediateOutputPath)ILLink.LinkAttributes.xml true @@ -70,7 +71,7 @@ + DependsOnTargets="_CombineILLinkDescriptorsXmls;_CombineILLinkSubstitutionsXmls;_CombineILLinkLinkAttributesXmls"> @@ -84,6 +85,12 @@ + + + ILLink.LinkAttributes.xml + + + @@ -152,6 +159,22 @@ + + + $(ILLinkLinkAttributesXmlIntermediatePath) + + + + + + + + + @@ -187,7 +210,7 @@ $(ILLinkArgs) --strip-substitutions false - $(ILLinkArgs) --strip-link-attributes false + $(ILLinkArgs) --strip-link-attributes false $(ILLinkArgs) --skip-unresolved true diff --git a/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj index 5cdb8f1698da9e..8b2acf2ac74f45 100644 --- a/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -153,8 +153,8 @@ - + From bb840d2cade56829c2e79ff2de2198989a81246a Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Thu, 9 Jul 2020 16:07:16 -0500 Subject: [PATCH 4/6] Update linker command line to ignore attributes file. Add ExcludeFromCodeCoverageAttribute. --- eng/illink.targets | 3 ++- .../src/ILLink/ILLink.LinkAttributes.wasm.xml | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/eng/illink.targets b/eng/illink.targets index 7ceaa32557897f..7914b6cfaba832 100644 --- a/eng/illink.targets +++ b/eng/illink.targets @@ -210,7 +210,8 @@ $(ILLinkArgs) --strip-substitutions false - $(ILLinkArgs) --strip-link-attributes false + + $(ILLinkArgs) --strip-link-attributes false --ignore-link-attributes true $(ILLinkArgs) --skip-unresolved true diff --git a/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml b/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml index 02f4c5e27929cb..f35d26667dbc3b 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml +++ b/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml @@ -12,6 +12,9 @@ + + + From 64f2a4589bfb165d8a69709d64b659831b055337 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Thu, 9 Jul 2020 17:43:03 -0500 Subject: [PATCH 5/6] PR feedback. Add note about Obsolete. Only use assembly fullname="*" for compiler generated attributes. --- .../src/ILLink/ILLink.LinkAttributes.wasm.xml | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml b/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml index f35d26667dbc3b..3e150d1a6381b3 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml +++ b/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml @@ -1,10 +1,16 @@ - + + @@ -77,10 +83,13 @@ + + + - + @@ -92,33 +101,40 @@ - + - + - + + + - + + + - + + + + + + - + - + - + - - - + @@ -126,11 +142,5 @@ - - - - - - From fc69953d98e61b8d758c44c6a6451de7f1734351 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Fri, 10 Jul 2020 09:10:31 +0200 Subject: [PATCH 6/6] Update ILLink.LinkAttributes.wasm.xml --- .../src/ILLink/ILLink.LinkAttributes.wasm.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml b/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml index 3e150d1a6381b3..78fc3756bf0e41 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml +++ b/src/mono/netcore/System.Private.CoreLib/src/ILLink/ILLink.LinkAttributes.wasm.xml @@ -83,7 +83,10 @@ - + +