The .NET IL Linker

The .NET Core team has been working on a linker in collaboration with the Mono team. It is based on the Mono Linker project, and by extension, on the Cecil project.

The goal of the .NET IL Linker project is two part:

  • Provide a capable linker for .NET Core to make it easy to significantly reduce .NET Core application sizes.
  • Establish the Mono Linker as the primary linker for the .NET ecosystem.

You can start using the linker today, using the following instructions:

Discussion

Please share your thoughts on this change and see what others are saying at:

Details

In trivial cases, the linker can reduce the size of applications by 50%. The size wins may be more favorable or more moderate for larger applications. The linker removes code in your application and dependent libraries that are not reached by any code paths. It is effectively an application-specific dead code analysis.

The IL Linker currently only supports .NET Core Self Contained Applications with this first preview version. You can try using the linker with an example self-contained .NET Core application sample. The primary difference with this application is that it has a reference to the ILLink.Tasks package in its cspoj project file.

The Linker provides an option to print a size improvement chart that describes binaries that have been removed from an application or that have been reduced in size. It also provides the total % size reduction for the application. You can see an example of one of these charts in the following example.

.NET IL Linker Size Improvement Chart

Please provide feedback on your use of the linker. We are actively looking for feedback to improve the linker. In particular, we are looking for feedback on the following topics:

  • Linker throughput.
  • Cases where the linker can be more aggressive.
  • Cases where the link is too aggressive and causes applications to fail at runtime.
  • The linker provided an excellent result for a large application.

Please create issue with your feedback at either mono/linker or dotnet/core. Also feel free to contact the team at clrlinker@microsoft.com.

And, it wouldn’t be right to announce this linker without a hat tip to Joel Spolsky who we can give the honorary and historical distinction of feature requestor.

Read More

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments