1CIL(Linker) CIL(Linker)
2
3
4
6 Mono CIL Linker
7
9 monolinker [-o output_directory][-l i18n_assemblies][-c skip | copy |
10 link] -x descriptor | -a assembly | -i info_file ...
11
13 monolinker is a CIL Linker. The linker is a tool one can use to only
14 ship the minimal possible set of functions that a set of programs might
15 require to run as opposed to the full libraries.
16
17 The linker analyses the intermediate code (CIL) produced by every com‐
18 piler targeting the Mono platform like mcs, gmcs, vbnc, booc or others.
19 It will walk through all the code that it is given to it, and remove
20 all the unused methods and classes. This is done using a mark and
21 sweep operation on all the code that it is referenced.
22
23 The generated output from the monolinker can be later processed by the
24 mkbundle tool to generate small native self-contained executables.
25
26 Do not confuse this with the Assembly Linker (al) which creates assem‐
27 blies from manifests, modules and resource files.
28
30 -d search_directory
31 Specify a directory to the linker where to look for assemblies.
32
33 -o output_directory
34 Specify the output directory, default is 'output'.
35
36 If you specify the directory `.', please ensure that you won't
37 write over important assemblies of yours.
38
39 -b true | false
40 Specify whether to generate debug symbols or not, default is
41 false.
42
43 -g true | false
44 Specify whether to generate a new guid for each linked module or
45 reuse the existing one, default is true.
46
47 -l i18n_assemblies
48 Specify what to do with the region specific assemblies
49
50 Mono have a few assemblies which contains everything region spe‐
51 cific:
52 I18N.CJK.dll
53 I18N.MidEast.dll
54 I18N.Other.dll
55 I18N.Rare.dll
56 I18N.West.dll
57
58 By default, they will all be copied to the output directory, but
59 you can specify which one you want using this command. The
60 choice can either be: none, all, cjk, mideast, other, rare or
61 west. You can combine the values with a comma.
62
63 -c action
64 Specify the action to apply to the core assemblies.
65
66 Core assemblies are the assemblies that belongs to the base
67 class library, like mscorlib.dll, System.dll or System.Win‐
68 dows.Forms.dll.
69
70 The linker supports three operations on these assemblies, you
71 can specify one of the following actions:
72
73 skip This instructs the linker to skip them and do nothing
74 with them.
75
76 copy This instructs the linker to copy them to the output
77 directory,
78
79 link This instructs the linker to apply the linking process
80 and reduce their size.
81
82
83 -p action assembly
84 Specify per assembly which action to apply.
85
86 -x descriptor
87 Use an XML descriptor as a source for the linker.
88
89 Here is an example that shows all the possibilities of this for‐
90 mat:
91
92 <linker>
93 <assembly fullname="Library">
94 <type fullname="Foo" />
95 <type fullname="Bar" preserve="nothing" required="false" />
96 <type fullname="Baz" preserve="fields" required="false" />
97 <type fullname="Gazonk">
98 <method signature="System.Void .ctor(System.String)" />
99 <field signature="System.String _blah" />
100 </type>
101 </assembly>
102 </linker>
103
104 In this example, the linker will link the types Foo, Bar, Baz
105 and Gazonk.
106
107 The preserve attribute ensures that all the fields of the type
108 Baz will be always be linked, not matter if they are used or
109 not, but that neither the fields or the methods of Bar will be
110 linked if they are not used. Not specifying a preserve attribute
111 implies that we are preserving everything in the specified type.
112
113 The required attribute specifies that if the type is not marked,
114 during the mark operation, it will not be linked.
115
116 The type Gazonk will be linked, as well as its constructor tak‐
117 ing a string as a parameter, and it's _blah field.
118
119 You can have multiple assembly nodes.
120
121 -a assemblies
122 use an assembly as a source for the linker.
123
124 The linker will walk through all the methods of the assembly to
125 generate only what is necessary for this assembly to run.
126
127 -i info_file
128 use a .info xml file as a source for the linker.
129
130 An info file is a file produced by the tool mono-api-info. The
131 linker will use it to generate an assembly that contains only
132 what the public API defined in he info file needs.
133
134 -s [StepBefore:]StepFullName,StepAssembly[:StepAfter]
135
136 You can ask the linker to execute custom steps by using the -s
137 command. This command takes the standard TypeFullName,Assembly
138 format to locate the step. You can customize its position in the
139 pipeline by either adding it before a step, or after.
140
141 Example:
142
143 using System;
144
145 using Mono.Linker;
146 using Mono.Linker.Steps;
147
148 namespace Foo {
149
150 public class FooStep : IStep {
151
152 public void Process (LinkContext context)
153 {
154 foreach (IStep step in context.Pipeline.GetSteps ()) {
155 Console.WriteLine (step.GetType ().Name);
156 }
157 }
158 }
159 }
160
161 If you compile this custom against monolinker to a Foo.dll
162 assembly, you can use the -s switch as follows. To add the
163 FooStep at the end of the pipeline:
164
165 monolinker -s Foo.FooStep,Foo -a program.exe
166
167 This commanand will add the FooStep after the MarkStep:
168
169 monolinker -s MarkStep:Foo.FooStep,Foo -a program.exe
170
171 This command will add the FooStep before the MarkStep:
172
173 monolinker -s Foo.FooStep,Foo:MarkStep -a program.exe
174
175 This command will add the FooStep before the MarkStep
176
177 -m CustomParam ParamValue
178 Specify a parameter for a custom step.
179
181 Copyright (C) 2007 Novell, Inc (http://www.novell.com)
182
184 Bugs report are welcome at http://bugzilla.ximian.com
185
186 Product Mono Tools, Component linker.
187
189 Mailing lists are listed at http://www.mono-project.com/Mailing_Lists
190
192 http://www.mono-project.com/Linker
193
195 The linker has been written by Jb Evain, and have been partially
196 founded by the Google Summer of Code.
197
199 The linker is licensed under the MIT/X11 license. Please read the
200 accompayning MIT.X11 file for details.
201
203 al(1),mkbundle(1),mono(1),mcs(1).
204
205
206
207 monolinker CIL(Linker)