Skip to content

Commit

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

* Don't import linker nuget package targets

We use custom targets to invoke the linker.

* Don't pass directories as assembly paths

Instead pass them as extra linker args. To avoid issues with the
response file parsing logic, we remove trailing slashes.

* Update to linker version with unusedinterfaces opt

* Update System.Text.Json with more ctor roots


Commit migrated from dotnet/corefx@e715ba8
  • Loading branch information
sbomer authored and stephentoub committed Oct 24, 2019
1 parent 13b9d54 commit 304fcbe
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
19 changes: 17 additions & 2 deletions eng/illink.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- Inputs and outputs of ILLinkTrimAssembly -->
<PropertyGroup>
<ILLinkTasksPath Condition="'$(ILLinkTasksPath)' == '' And '$(MSBuildRuntimeType)' == 'core'">$(ILLinkDir)netcoreapp2.0/ILLink.Tasks.dll</ILLinkTasksPath>
<ILLinkTasksPath Condition="'$(ILLinkTasksPath)' == '' And '$(MSBuildRuntimeType)' != 'core'">$(ILLinkDir)net46/ILLink.Tasks.dll</ILLinkTasksPath>
<ILLinkTasksPath Condition="'$(ILLinkTasksPath)' == '' And '$(MSBuildRuntimeType)' != 'core'">$(ILLinkDir)net472/ILLink.Tasks.dll</ILLinkTasksPath>
<ILLinkTrimAssemblyPath>$(IntermediateOutputPath)$(TargetName)$(TargetExt)</ILLinkTrimAssemblyPath>
<ILLinkTrimAssemblySymbols>$(IntermediateOutputPath)$(TargetName).pdb</ILLinkTrimAssemblySymbols>
<ILLinkTrimInputPath>$(IntermediateOutputPath)PreTrim/</ILLinkTrimInputPath>
Expand Down Expand Up @@ -80,6 +80,8 @@
<ILLinkArgs>$(ILLinkArgs) --strip-resources false</ILLinkArgs>
<!-- ignore unresolved references -->
<ILLinkArgs>$(ILLinkArgs) --skip-unresolved true</ILLinkArgs>
<!-- keep interface implementations -->
<ILLinkArgs>$(ILLinkArgs) --disable-opt unusedinterfaces</ILLinkArgs>
</PropertyGroup>

<MakeDir Directories="$(ILLinkTrimInputPath)" />
Expand All @@ -101,9 +103,22 @@
<!-- Add project references first to give precedence to project-specific files -->
<_DependencyDirectories Condition="'%(_DependencyDirectoriesTemp.ReferenceSourceTarget)'=='ProjectReference'" Include="%(_DependencyDirectoriesTemp.Identity)" />
<_DependencyDirectories Condition="'%(_DependencyDirectoriesTemp.ReferenceSourceTarget)'!='ProjectReference'" Include="%(_DependencyDirectoriesTemp.Identity)" />
<!-- Remove trailing slash to work around response file parsing behavior -->
<_DependencyDirectoriesSlash Include="@(_DependencyDirectories)">
<PathWithSlash>$([MSBuild]::EnsureTrailingSlash('%(Identity)'))</PathWithSlash>
</_DependencyDirectoriesSlash>
<_DependencyDirectoriesNoSlash Include="@(_DependencyDirectoriesSlash)">
<PathWithoutSlash>$([System.String]::new('%(PathWithSlash)').TrimEnd($([System.IO.Path]::DirectorySeparatorChar)))</PathWithoutSlash>
</_DependencyDirectoriesNoSlash>
<_DependencyDirectories Remove="@(_DependencyDirectories)" />
<_DependencyDirectories Include="%(_DependencyDirectoriesNoSlash.PathWithoutSlash)" />
</ItemGroup>

<ILLink AssemblyPaths="$(ILLinkTrimInputAssembly);@(_DependencyDirectories)"
<PropertyGroup>
<ILLinkArgs Condition="@(_DependencyDirectories->Count()) > 0">$(ILLinkArgs) -d @(_DependencyDirectories->'"%(Identity)"', ' -d ')</ILLinkArgs>
</PropertyGroup>

<ILLink AssemblyPaths="$(ILLinkTrimInputAssembly)"
RootAssemblyNames=""
OutputDirectory="$(ILLinkTrimOutputPath)"
ClearInitLocals="$(ILLinkClearInitLocals)"
Expand Down
2 changes: 1 addition & 1 deletion eng/restore/illink.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<ItemGroup>
<PackageReference Include="illink.tasks" Version="$(ILLinkTasksPackageVersion)" PrivateAssets="all" IsImplicitlyDefined="true" />
<PackageReference Include="illink.tasks" Version="$(ILLinkTasksPackageVersion)" PrivateAssets="all" IsImplicitlyDefined="true" ExcludeAssets="build" />
</ItemGroup>

<Target Name="IncludeToolsFiles"
Expand Down
12 changes: 12 additions & 0 deletions src/libraries/System.Text.Json/src/ILLinkTrim.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,17 @@
<!-- Instantiated via reflection -->
<method name=".ctor" />
</type>
<type fullname="System.Text.Json.ImmutableCollectionCreator">
<!-- Instantiated via reflection -->
<method name=".ctor" />
</type>
<type fullname="System.Text.Json.ImmutableDictionaryCreator`2">
<!-- Instantiated via reflection -->
<method name=".ctor" />
</type>
<type fullname="System.Text.Json.ImmutableEnumerableCreator`2">
<!-- Instantiated via reflection -->
<method name=".ctor" />
</type>
</assembly>
</linker>

0 comments on commit 304fcbe

Please sign in to comment.