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