CIL(Linker)
π CIL(Linker) π
okay so bestie, welcome to the monolinker page β the CIL(Linker) manual, literally the glow-up guide for your assemblies. sit down, grab a boba, and let's get into it π§β¨
β¨ NAME β¨
Mono CIL Linker β that's the whole name, no notes π
πΈ SYNOPSIS πΈ
monolinker [-o output_directory][-l i18n_assemblies][-c skip | copy |
link] -x descriptor | -a assembly | -i info_file ...
π¦ DESCRIPTION π¦
so monolinker is a CIL Linker. what does that even mean? okay so basically it's a tool you use to ship only the absolute bare minimum set of functions that a set of programs might need to run, instead of dragging the entire full libraries along with you. minimalism era, we love to see it π
The linker analyzes the intermediate code (CIL) that every compiler targeting the Mono platform produces β think mcs, gmcs, vbnc, booc or whatever else you got. It walks through all the code you hand it and removes every unused method and class. The way it does this is a mark and sweep operation on all the code that's referenced. mark, sweep, slay. π₯
The output that monolinker generates can later be processed by the mkbundle tool to generate small native self-contained executables. cute AND functional β¨
not me needing to say this but: do not confuse this with the Assembly Linker (al), which creates assemblies from manifests, modules and resource files. different tool, different vibe, don't mix them up π
π OPTIONS π
-dsearch_directory β tell the linker which directory to look in when it's hunting for assemblies. like, "the girlies are over here" π-ooutput_directory β specify the output directory. default is'output'.
okay important: if you set this directory to '.', please make sure you're not about to write over important assemblies of yours. no cap, protect your files π
-btrue | falseβ whether to generate debug symbols or not. default isfalse.-gtrue | falseβ whether to generate a new guid for each linked module, or reuse the existing one. default istrue.-li18n_assemblies β specify what to do with the region-specific assemblies.
Mono has a few assemblies that contain everything region specific:
I18N.CJK.dll
I18N.MidEast.dll
I18N.Other.dll
I18N.Rare.dll
I18N.West.dll
By default they all get copied to the output directory, but you can pick which ones you want with this command. The choice can be: none, all, cjk, mideast, other, rare or west. You can combine values with a comma. pick your faves, build your own roster π
-caction β specify the action to apply to the core assemblies.
Core assemblies are the assemblies that belong to the base class library, like mscorlib.dll, System.dll or System.Windows.Forms.dll.
The linker supports three operations on these assemblies, and you pick one:
skipβ this tells the linker to skip them and do nothing with them. hands off, not my business πcopyβ this tells the linker to copy them to the output directory.linkβ this tells the linker to apply the linking process and reduce their size. the full glam treatment β¨
-paction assembly β specify per assembly which action to apply. one rule for everybody? no ma'am, custom rules per assembly π-xdescriptor β use an XML descriptor as a source for the linker.
Here's an example that shows all the possibilities of this format:
<linker>
<assembly fullname="Library">
<type fullname="Foo" />
<type fullname="Bar" preserve="nothing" required="false" />
<type fullname="Baz" preserve="fields" required="false" />
<type fullname="Gazonk">
<method signature="System.Void .ctor(System.String)" />
<field signature="System.String _blah" />
<field name="someFieldName" />
</type>
</assembly>
</linker>
In this example, the linker will link the types Foo, Bar, Baz and Gazonk.
The preserve attribute makes sure that all the fields of the type Baz will always be linked, no matter if they're used or not β but that neither the fields nor the methods of Bar will be linked if they're not used. Not specifying a preserve attribute implies that we're preserving everything in the specified type. all of it, every crumb π
The required attribute specifies that if the type is not marked, during the mark operation, it will not be linked.
The type Gazonk will be linked, as well as its constructor taking a string as a parameter, and it's _blah field.
You can have multiple assembly nodes. go off, stack them up π
-aassemblies β use an assembly as a source for the linker.
The linker will walk through all the methods of the assembly to generate only what is necessary for this assembly to run.
-iinfo_file β use a.infoxml file as a source for the linker.
An info file is a file produced by the tool mono-api-info. The linker will use it to generate an assembly that contains only what the public API defined in the info file needs.
-s[StepBefore:]StepFullName,StepAssembly[:StepAfter]
You can ask the linker to execute custom steps by using the -s command. This command takes the standard TypeFullName,Assembly format to locate the step. You can customize its position in the pipeline by either adding it before a step, or after. main character energy, choosing your own placement π
Example:
using System;
using Mono.Linker;
using Mono.Linker.Steps;
namespace Foo {
public class FooStep : IStep {
public void Process (LinkContext context)
{
foreach (IStep step in context.Pipeline.GetSteps ()) {
Console.WriteLine (step.GetType ().Name);
}
}
}
}
If you compile this custom against monolinker to a Foo.dll assembly, you can use the -s switch as follows. To add the FooStep at the end of the pipeline:
monolinker -s Foo.FooStep,Foo -a program.exe
This commanand will add the FooStep after the MarkStep:
monolinker -s MarkStep:Foo.FooStep,Foo -a program.exe
This command will add the FooStep before the MarkStep:
monolinker -s Foo.FooStep,Foo:MarkStep -a program.exe
This command will add the FooStep before the MarkStep
-mCustomParam ParamValue β specify a parameter for a custom step. custom step, custom param, custom everything π
π COPYRIGHT π
Copyright (C) 2007 Novell, Inc (http://www.novell.com)
π BUGS π
Bugs report are welcome at https://github.com/mono/linker/issues
Product Mono Tools, Component linker.
fr fr, if something's busted, tell the girlies at the issue tracker π«Ά
π MAILING LISTS π
Mailing lists are listed at http://www.mono-project.com/community/help/mailing-lists/
β WEB SITE β
http://www.mono-project.com/docs/tools+libraries/tools/linker/
π§ AUTHORS π§
The linker has been written by Jb Evain, and have been partially founded by the Google Summer of Code. iconic origin story honestly π
πΈ LICENSE πΈ
The linker is licensed under the MIT/X11 license. Please read the accompayning MIT.X11 file for details.
π SEE ALSO π
al(1), mkbundle(1), mono(1), mcs(1)
okay that's the whole thing bestie, you're officially a linker expert π
β¨ this was the monolinker page from the CIL(Linker) manual β go forth and link responsibly, ily π«Άπ
π¦ where this page comes from
- alpine 3.24: mono-doc 6.14.1-r1 Β· MIT
- epel 10: mono-devel 6.14.1-1.el10_2 Β· MIT
- fedora 44: mono-devel 6.14.1-3.fc44 Β· MIT
- fedora 44: mono-devel 6.14.1-3.fc44 Β· MIT
- fedora 44: mono-devel 6.14.1-4.fc44 Β· MIT
- fedora 44: mono-devel 6.14.1-4.fc44 Β· MIT
- nixos 26.05: mono 6.14.1
- nixpkgs unstable: mono 6.14.1
- Copyright (C) 2007 Novell, Inc (http://www.novell.com)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms