Skip to content

Commit

Permalink
Update ILLink.Tasks (dotnet/coreclr#25596)
Browse files Browse the repository at this point in the history
* Update ILLink.Tasks

This adds a few roots that are needed by reflection APIs, experimental
(internal) APIs, and by the runtime.

* Remove MemoryLoadChangeNotification root

The Register/Unregister methods were already being removed by the
linker, so we do not need to introduce them.

* Keep ThreadPoolBoundHandle implementation of IDisposable

* Update to linker version with unusedinterfaces opt

* GeneratePackagePath -> GeneratePathProperty

This wasn't causing any problems since these packages happened to have
tools folders, which always get the path property generated. We could
get rid of them, but perhaps it's better to be explicit.

* Prevent problems when running on desktop

I'm not sure we ever build corelib using desktop MSBuild, but this
should prevent problems like
dotnet/corefx#42266 if we do.


Commit migrated from dotnet/coreclr@34fe045
  • Loading branch information
sbomer authored Nov 1, 2019
1 parent fa25aea commit 0a96574
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 13 deletions.
6 changes: 0 additions & 6 deletions src/coreclr/dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
<CurrentRefXmlPath>$(MSBuildThisFileFullPath)</CurrentRefXmlPath>
</PropertyGroup>

<!-- ILLink.Tasks package version -->
<PropertyGroup>
<ILLinkTasksPackage>ILLink.Tasks</ILLinkTasksPackage>
<ILLinkTasksPackageVersion>0.1.5-preview-1461378</ILLinkTasksPackageVersion>
</PropertyGroup>

<ItemGroup>
<RemoteDependencyBuildInfo Include="CoreClr">
<BuildInfoPath>$(BaseDotNetBuildInfo)coreclr/$(DependencyBranch)</BuildInfoPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<_RexcepFilePath Condition=" '$(_RexcepFilePath)' == '' ">$(MSBuildThisFileDirectory)..\vm\rexcep.h</_RexcepFilePath>
<_ILLinkTrimXmlFilePath Condition=" '$(_ILLinkTrimXmlFilePath)' == '' ">$(MSBuildThisFileDirectory)ILLinkTrim.xml</_ILLinkTrimXmlFilePath>
<_ILLinkTasksToolsDir>$(PkgILLink_Tasks)/tools</_ILLinkTasksToolsDir>
<_ILLinkTasksDir>$(_ILLinkTasksToolsDir)/net46/</_ILLinkTasksDir>
<_ILLinkTasksDir>$(_ILLinkTasksToolsDir)/net472/</_ILLinkTasksDir>
<_ILLinkTasksDir Condition="'$(MSBuildRuntimeType)' == 'Core'">$(_ILLinkTasksToolsDir)/netcoreapp2.0/</_ILLinkTasksDir>
</PropertyGroup>

Expand Down
16 changes: 14 additions & 2 deletions src/coreclr/src/System.Private.CoreLib/ILLink.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- Inputs and outputs of ILLinkTrimAssembly -->
<PropertyGroup>
<ILLinkTasksToolsDir>$(PkgILLink_Tasks)/tools</ILLinkTasksToolsDir>
<ILLinkTasksDir>$(ILLinkTasksToolsDir)/net46/</ILLinkTasksDir>
<ILLinkTasksDir>$(ILLinkTasksToolsDir)/net472/</ILLinkTasksDir>
<ILLinkTasksDir Condition="'$(MSBuildRuntimeType)' == 'Core'">$(ILLinkTasksToolsDir)/netcoreapp2.0/</ILLinkTasksDir>
<ILLinkTasksPath>$(ILLinkTasksDir)ILLink.Tasks.dll</ILLinkTasksPath>
<ILLinkTrimAssembly Condition="'$(ILLinkTrimAssembly)' == ''">true</ILLinkTrimAssembly>
Expand Down Expand Up @@ -62,6 +62,8 @@
<ILLinkArgs>$(ILLinkArgs) -v true</ILLinkArgs>
<!-- don't remove the embedded root xml resource since ILLink may run again on the assembly -->
<ILLinkArgs>$(ILLinkArgs) --strip-resources false</ILLinkArgs>
<!-- keep interface implementations -->
<ILLinkArgs>$(ILLinkArgs) --disable-opt unusedinterfaces</ILLinkArgs>
</PropertyGroup>

<MakeDir Directories="$(ILLinkTrimInputPath)" />
Expand All @@ -77,12 +79,22 @@
Condition="'$(ILLinkRewritePDBs)' == 'true' AND Exists('$(ILLinkTrimAssemblySymbols)')"
/>

<!-- When running from Desktop MSBuild, DOTNET_HOST_PATH is not set.
In this case, explicitly specify the path to the dotnet host. -->
<PropertyGroup Condition=" '$(DOTNET_HOST_PATH)' == '' ">
<_DotNetHostDirectory>$(NetCoreRoot)</_DotNetHostDirectory>
<_DotNetHostFileName>dotnet</_DotNetHostFileName>
<_DotNetHostFileName Condition=" '$(OS)' == 'Windows_NT' ">dotnet.exe</_DotNetHostFileName>
</PropertyGroup>

<ILLink AssemblyPaths="$(ILLinkTrimInputAssembly)"
RootAssemblyNames=""
OutputDirectory="$(ILLinkTrimOutputPath)"
ClearInitLocals="true"
ClearInitLocalsAssemblies="$(TargetName)"
ExtraArgs="$(ILLinkArgs)" />
ExtraArgs="$(ILLinkArgs)"
ToolExe="$(_DotNetHostFileName)"
ToolPath="$(_DotNetHostDirectory)" />

</Target>

Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/src/System.Private.CoreLib/ILLinkTrim.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,11 @@
<!-- Workaround for https://github.com/mono/linker/issues/378 -->
<type fullname="System.Runtime.InteropServices.IDispatch" />
<type fullname="Internal.Runtime.InteropServices.IClassFactory2" />
<type fullname="System.Threading.ThreadPoolBoundHandle">
<!-- Workaround to keep .interfaceimpl even though this type
is not instantiated on unix:
https://github.com/mono/linker/pull/649 -->
<method name=".ctor" />
</type>
</assembly>
</linker>
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,7 @@

<!-- Setup ILLink.targets -->
<ItemGroup>
<PackageReference Include="$(ILLinkTasksPackage)" GeneratePackagePath="True">
<Version>$(ILLinkTasksPackageVersion)</Version>
</PackageReference>
<PackageReference Include="ILLink.Tasks" Version="$(ILLinkTasksVersion)" ExcludeAssets="build" GeneratePathProperty="True" />
</ItemGroup>

<!-- Analyzers -->
Expand Down
18 changes: 18 additions & 0 deletions src/coreclr/src/vm/mscorlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ DEFINE_FIELD(ARRAY_WITH_OFFSET, M_COUNT, m_count)

DEFINE_CLASS(ASSEMBLY_BUILDER, ReflectionEmit, AssemblyBuilder)
DEFINE_CLASS(INTERNAL_ASSEMBLY_BUILDER, ReflectionEmit, InternalAssemblyBuilder)
#if FOR_ILLINK
DEFINE_METHOD(INTERNAL_ASSEMBLY_BUILDER, CTOR, .ctor, IM_RetVoid)
#endif

DEFINE_CLASS(ASSEMBLY_HASH_ALGORITHM, Assemblies, AssemblyHashAlgorithm)
DEFINE_CLASS(PORTABLE_EXECUTABLE_KINDS, Reflection, PortableExecutableKinds)
Expand Down Expand Up @@ -386,6 +389,9 @@ DEFINE_FIELD(RT_FIELD_INFO, HANDLE, m_fieldHandle)
DEFINE_CLASS_U(System, RuntimeFieldInfoStub, ReflectFieldObject)
DEFINE_FIELD_U(m_fieldHandle, ReflectFieldObject, m_pFD)
DEFINE_CLASS(STUBFIELDINFO, System, RuntimeFieldInfoStub)
#if FOR_ILLINK
DEFINE_METHOD(STUBFIELDINFO, CTOR, .ctor, IM_RetVoid)
#endif

DEFINE_CLASS(FIELD, Reflection, RuntimeFieldInfo)
DEFINE_METHOD(FIELD, SET_VALUE, SetValue, IM_Obj_Obj_BindingFlags_Binder_CultureInfo_RetVoid)
Expand Down Expand Up @@ -515,12 +521,18 @@ DEFINE_FIELD_U(_handlerLength, RuntimeExceptionHandlingClause, _h
DEFINE_FIELD_U(_catchMetadataToken, RuntimeExceptionHandlingClause, _catchToken)
DEFINE_FIELD_U(_filterOffset, RuntimeExceptionHandlingClause, _filterOffset)
DEFINE_CLASS(RUNTIME_EH_CLAUSE, Reflection, RuntimeExceptionHandlingClause)
#if FOR_ILLINK
DEFINE_METHOD(RUNTIME_EH_CLAUSE, CTOR, .ctor, IM_RetVoid)
#endif

DEFINE_CLASS_U(Reflection, RuntimeLocalVariableInfo, RuntimeLocalVariableInfo)
DEFINE_FIELD_U(_type, RuntimeLocalVariableInfo, _type)
DEFINE_FIELD_U(_localIndex, RuntimeLocalVariableInfo, _localIndex)
DEFINE_FIELD_U(_isPinned, RuntimeLocalVariableInfo, _isPinned)
DEFINE_CLASS(RUNTIME_LOCAL_VARIABLE_INFO, Reflection, RuntimeLocalVariableInfo)
#if FOR_ILLINK
DEFINE_METHOD(RUNTIME_LOCAL_VARIABLE_INFO, CTOR, .ctor, IM_RetVoid)
#endif

DEFINE_CLASS_U(Reflection, RuntimeMethodBody, RuntimeMethodBody)
DEFINE_FIELD_U(_IL, RuntimeMethodBody, _IL)
Expand Down Expand Up @@ -553,6 +565,9 @@ DEFINE_CLASS(MODULE, Reflection, RuntimeModule)
DEFINE_FIELD(MODULE, DATA, m_pData)

DEFINE_CLASS(MODULE_BUILDER, ReflectionEmit, InternalModuleBuilder)
#if FOR_ILLINK
DEFINE_METHOD(MODULE_BUILDER, CTOR, .ctor, IM_RetVoid)
#endif
DEFINE_CLASS(TYPE_BUILDER, ReflectionEmit, TypeBuilder)
DEFINE_CLASS(ENUM_BUILDER, ReflectionEmit, EnumBuilder)

Expand Down Expand Up @@ -1432,6 +1447,9 @@ DEFINE_FIELD_U(_dependentHandle, LAHashDependentHashTrackerObject,_dep
DEFINE_FIELD_U(_loaderAllocator, LAHashDependentHashTrackerObject,_loaderAllocator)

DEFINE_CLASS(LAHASHDEPENDENTHASHTRACKER, CompilerServices, LAHashDependentHashTracker)
#if FOR_ILLINK
DEFINE_METHOD(LAHASHDEPENDENTHASHTRACKER, CTOR, .ctor, IM_RetVoid)
#endif

DEFINE_CLASS_U(CompilerServices, LAHashKeyToTrackers, LAHashKeyToTrackersObject)
DEFINE_FIELD_U(_trackerOrTrackerSet, LAHashKeyToTrackersObject, _trackerOrTrackerSet)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/tests/external/external.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="$(MicrosoftDiagnosticsTracingTraceEventPackageVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />
<PackageReference Include="xunit.runner.console" Version="$(XunitPackageVersion)" GeneratePackagePath="True" />
<PackageReference Include="xunit.runner.console" Version="$(XunitPackageVersion)" GeneratePathProperty="True" />
<PackageReference Include="xunit.runner.utility" Version="$(XunitPackageVersion)" />
</ItemGroup>

Expand Down

0 comments on commit 0a96574

Please sign in to comment.