From 3e0d767831eb2fce89bb001e3a64aa6b43e5733b Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Fri, 5 Jun 2020 20:22:39 -0700 Subject: [PATCH 1/5] Use [SkipLocalsInit] & remove code for ILLink to strip locals init --- eng/illink.targets | 1 - .../System.Private.CoreLib.csproj | 2 +- .../src/ShouldSkipLocalsInit.cs | 7 +++++++ .../Common/src/ShouldSkipLocalsInit.cs | 7 +++++++ src/libraries/Directory.Build.props | 4 ++-- src/libraries/Directory.Build.targets | 18 ++++++++++++++++++ .../SkipLocalsInitAttribute.cs | 7 ++++++- .../System.Private.CoreLib.csproj | 2 +- .../src/ShouldSkipLocalsInit.cs | 7 +++++++ 9 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 src/coreclr/src/System.Private.CoreLib/src/ShouldSkipLocalsInit.cs create mode 100644 src/libraries/Common/src/ShouldSkipLocalsInit.cs create mode 100644 src/mono/netcore/System.Private.CoreLib/src/ShouldSkipLocalsInit.cs diff --git a/eng/illink.targets b/eng/illink.targets index 79fc5e813ae987..e1f2ded9de1992 100644 --- a/eng/illink.targets +++ b/eng/illink.targets @@ -149,7 +149,6 @@ diff --git a/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj index 84c9e2611f6619..c569fdbd819799 100644 --- a/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -17,7 +17,6 @@ Debug;Release;Checked x64;x86;arm;arm64 - true true $(IntermediateOutputPath)System.Private.CoreLib.xml @@ -119,6 +118,7 @@ + diff --git a/src/coreclr/src/System.Private.CoreLib/src/ShouldSkipLocalsInit.cs b/src/coreclr/src/System.Private.CoreLib/src/ShouldSkipLocalsInit.cs new file mode 100644 index 00000000000000..ff0ed89329647e --- /dev/null +++ b/src/coreclr/src/System.Private.CoreLib/src/ShouldSkipLocalsInit.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// Used to indicate to the compiler that the .locals init flag should +// not be set in nested method headers when emitting to metadata. +[module: System.Runtime.CompilerServices.SkipLocalsInit] diff --git a/src/libraries/Common/src/ShouldSkipLocalsInit.cs b/src/libraries/Common/src/ShouldSkipLocalsInit.cs new file mode 100644 index 00000000000000..ff0ed89329647e --- /dev/null +++ b/src/libraries/Common/src/ShouldSkipLocalsInit.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// Used to indicate to the compiler that the .locals init flag should +// not be set in nested method headers when emitting to metadata. +[module: System.Runtime.CompilerServices.SkipLocalsInit] diff --git a/src/libraries/Directory.Build.props b/src/libraries/Directory.Build.props index 8a5a16a37f2878..d16418dabd4a97 100644 --- a/src/libraries/Directory.Build.props +++ b/src/libraries/Directory.Build.props @@ -293,8 +293,8 @@ false - - true + + true diff --git a/src/libraries/Directory.Build.targets b/src/libraries/Directory.Build.targets index cad6c2ed4803af..0cd58639ffe4ef 100644 --- a/src/libraries/Directory.Build.targets +++ b/src/libraries/Directory.Build.targets @@ -233,4 +233,22 @@ + + + + + + + true + + + + + + + + + + + diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SkipLocalsInitAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SkipLocalsInitAttribute.cs index 349c12ace69c43..366e83886e2d01 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SkipLocalsInitAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SkipLocalsInitAttribute.cs @@ -26,7 +26,12 @@ namespace System.Runtime.CompilerServices | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event, Inherited = false)] - public sealed class SkipLocalsInitAttribute : Attribute +#if SYSTEM_PRIVATE_CORELIB + public +#else + internal +#endif + sealed class SkipLocalsInitAttribute : Attribute { public SkipLocalsInitAttribute() { 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 97710f8acf8029..6169368552419f 100644 --- a/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -20,7 +20,6 @@ Debug;Release;Checked x64;x86;arm;arm64;wasm - true true $(MSBuildThisFileDirectory)src\LinkerDescriptor\System.Private.CoreLib.xml @@ -152,6 +151,7 @@ + diff --git a/src/mono/netcore/System.Private.CoreLib/src/ShouldSkipLocalsInit.cs b/src/mono/netcore/System.Private.CoreLib/src/ShouldSkipLocalsInit.cs new file mode 100644 index 00000000000000..ff0ed89329647e --- /dev/null +++ b/src/mono/netcore/System.Private.CoreLib/src/ShouldSkipLocalsInit.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// Used to indicate to the compiler that the .locals init flag should +// not be set in nested method headers when emitting to metadata. +[module: System.Runtime.CompilerServices.SkipLocalsInit] From ba4e7d223d4f7f612e3b7b2d0b1168522f39df53 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Mon, 8 Jun 2020 12:21:45 -0700 Subject: [PATCH 2/5] Address review feedback --- .../System.Private.CoreLib.csproj | 1 - .../src/ShouldSkipLocalsInit.cs | 7 ------- src/libraries/Common/src/ShouldSkipLocalsInit.cs | 3 +-- src/libraries/Directory.Build.props | 3 +-- src/libraries/Directory.Build.targets | 5 +---- .../src/System.Private.CoreLib.Shared.projitems | 3 +++ .../CompilerServices/SkipLocalsInitAttribute.cs | 11 +++-------- .../System.Private.CoreLib.csproj | 1 - .../src/ShouldSkipLocalsInit.cs | 7 ------- 9 files changed, 9 insertions(+), 32 deletions(-) delete mode 100644 src/coreclr/src/System.Private.CoreLib/src/ShouldSkipLocalsInit.cs delete mode 100644 src/mono/netcore/System.Private.CoreLib/src/ShouldSkipLocalsInit.cs diff --git a/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj index c569fdbd819799..7147687ee04b94 100644 --- a/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -118,7 +118,6 @@ - diff --git a/src/coreclr/src/System.Private.CoreLib/src/ShouldSkipLocalsInit.cs b/src/coreclr/src/System.Private.CoreLib/src/ShouldSkipLocalsInit.cs deleted file mode 100644 index ff0ed89329647e..00000000000000 --- a/src/coreclr/src/System.Private.CoreLib/src/ShouldSkipLocalsInit.cs +++ /dev/null @@ -1,7 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// Used to indicate to the compiler that the .locals init flag should -// not be set in nested method headers when emitting to metadata. -[module: System.Runtime.CompilerServices.SkipLocalsInit] diff --git a/src/libraries/Common/src/ShouldSkipLocalsInit.cs b/src/libraries/Common/src/ShouldSkipLocalsInit.cs index ff0ed89329647e..3ddba38173aed1 100644 --- a/src/libraries/Common/src/ShouldSkipLocalsInit.cs +++ b/src/libraries/Common/src/ShouldSkipLocalsInit.cs @@ -2,6 +2,5 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -// Used to indicate to the compiler that the .locals init flag should -// not be set in nested method headers when emitting to metadata. +// Used to indicate to the compiler that the .locals init flag should not be set in method headers. [module: System.Runtime.CompilerServices.SkipLocalsInit] diff --git a/src/libraries/Directory.Build.props b/src/libraries/Directory.Build.props index d16418dabd4a97..2adad9c75aaa55 100644 --- a/src/libraries/Directory.Build.props +++ b/src/libraries/Directory.Build.props @@ -293,8 +293,7 @@ false - - true + true diff --git a/src/libraries/Directory.Build.targets b/src/libraries/Directory.Build.targets index 0cd58639ffe4ef..e6da3f71e87b94 100644 --- a/src/libraries/Directory.Build.targets +++ b/src/libraries/Directory.Build.targets @@ -236,7 +236,7 @@ - + true @@ -245,9 +245,6 @@ - - - diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 6f2855c237f967..31d502335d9e7e 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -1058,6 +1058,9 @@ Common\Interop\Windows\Normaliz\Interop.Normalization.cs + + Common\ShouldSkipLocalsInit.cs + Common\System\HResults.cs diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SkipLocalsInitAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SkipLocalsInitAttribute.cs index 366e83886e2d01..89439cee15441f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SkipLocalsInitAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/SkipLocalsInitAttribute.cs @@ -5,8 +5,8 @@ namespace System.Runtime.CompilerServices { /// - /// Used to indicate to the compiler that the .locals init flag should - /// not be set in nested method headers when emitting to metadata. + /// Used to indicate to the compiler that the .locals init + /// flag should not be set in method headers. /// /// /// This attribute is unsafe because it may reveal uninitialized memory to @@ -26,12 +26,7 @@ namespace System.Runtime.CompilerServices | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event, Inherited = false)] -#if SYSTEM_PRIVATE_CORELIB - public -#else - internal -#endif - sealed class SkipLocalsInitAttribute : Attribute + public sealed class SkipLocalsInitAttribute : Attribute { public SkipLocalsInitAttribute() { 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 6169368552419f..5e8572f771e5ca 100644 --- a/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -151,7 +151,6 @@ - diff --git a/src/mono/netcore/System.Private.CoreLib/src/ShouldSkipLocalsInit.cs b/src/mono/netcore/System.Private.CoreLib/src/ShouldSkipLocalsInit.cs deleted file mode 100644 index ff0ed89329647e..00000000000000 --- a/src/mono/netcore/System.Private.CoreLib/src/ShouldSkipLocalsInit.cs +++ /dev/null @@ -1,7 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// Used to indicate to the compiler that the .locals init flag should -// not be set in nested method headers when emitting to metadata. -[module: System.Runtime.CompilerServices.SkipLocalsInit] From 0e44a488ebc2273858ed14afd94cf92edc8db022 Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Tue, 9 Jun 2020 13:39:27 -0700 Subject: [PATCH 3/5] Simply condition --- src/libraries/Directory.Build.props | 2 -- src/libraries/Directory.Build.targets | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libraries/Directory.Build.props b/src/libraries/Directory.Build.props index 2adad9c75aaa55..5f3ae8b85923bc 100644 --- a/src/libraries/Directory.Build.props +++ b/src/libraries/Directory.Build.props @@ -292,8 +292,6 @@ false - - true diff --git a/src/libraries/Directory.Build.targets b/src/libraries/Directory.Build.targets index e6da3f71e87b94..3e297ee8e5d58b 100644 --- a/src/libraries/Directory.Build.targets +++ b/src/libraries/Directory.Build.targets @@ -234,9 +234,13 @@ Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);@(Compile)" /> + + true + + - + true From 37c23a663c958b50464740555f4ee0c0238d44fd Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Tue, 9 Jun 2020 14:18:39 -0700 Subject: [PATCH 4/5] Clean up --- .../Common/src/{ShouldSkipLocalsInit.cs => SkipLocalsInit.cs} | 0 src/libraries/Directory.Build.targets | 2 +- .../src/System.Private.CoreLib.Shared.projitems | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) rename src/libraries/Common/src/{ShouldSkipLocalsInit.cs => SkipLocalsInit.cs} (100%) diff --git a/src/libraries/Common/src/ShouldSkipLocalsInit.cs b/src/libraries/Common/src/SkipLocalsInit.cs similarity index 100% rename from src/libraries/Common/src/ShouldSkipLocalsInit.cs rename to src/libraries/Common/src/SkipLocalsInit.cs diff --git a/src/libraries/Directory.Build.targets b/src/libraries/Directory.Build.targets index 3e297ee8e5d58b..0b2e8d55ada82f 100644 --- a/src/libraries/Directory.Build.targets +++ b/src/libraries/Directory.Build.targets @@ -247,7 +247,7 @@ - + diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 31d502335d9e7e..fc0b5175416b74 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -1058,8 +1058,8 @@ Common\Interop\Windows\Normaliz\Interop.Normalization.cs - - Common\ShouldSkipLocalsInit.cs + + Common\SkipLocalsInit.cs Common\System\HResults.cs From 21c3bcca57c12d5766bde32b3cd044d7625a566b Mon Sep 17 00:00:00 2001 From: Layomi Akinrinade Date: Tue, 9 Jun 2020 15:07:33 -0700 Subject: [PATCH 5/5] Fix condition --- src/libraries/Directory.Build.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/Directory.Build.targets b/src/libraries/Directory.Build.targets index 0b2e8d55ada82f..b83ed06a19b5db 100644 --- a/src/libraries/Directory.Build.targets +++ b/src/libraries/Directory.Build.targets @@ -235,7 +235,7 @@ - true + true