Debian Codegraph @

info/gcl-si/Compilation.html

raw ◀ ▶
Source reconstructed at patch state 0 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <title>Compilation (GCL SI Manual)</title>
7
8 <meta name="description" content="Compilation (GCL SI Manual)">
9 <meta name="keywords" content="Compilation (GCL SI Manual)">
10 <meta name="resource-type" content="document">
11 <meta name="distribution" content="global">
12 <meta name="Generator" content="makeinfo">
13 <link href="index.html" rel="start" title="Top">
14 <link href="Function-and-Variable-Index.html" rel="index" title="Function and Variable Index">
15 <link href="Function-and-Variable-Index.html#SEC_Contents" rel="contents" title="Table of Contents">
16 <link href="index.html" rel="up" title="Top">
17 <link href="Symbols.html" rel="next" title="Symbols">
18 <link href="Special-Forms-and-Functions.html" rel="prev" title="Special Forms and Functions">
19 <style type="text/css">
20 <!--
21 a.summary-letter {text-decoration: none}
22 blockquote.indentedblock {margin-right: 0em}
23 div.display {margin-left: 3.2em}
24 div.example {margin-left: 3.2em}
25 div.lisp {margin-left: 3.2em}
26 kbd {font-style: oblique}
27 pre.display {font-family: inherit}
28 pre.format {font-family: inherit}
29 pre.menu-comment {font-family: serif}
30 pre.menu-preformatted {font-family: serif}
31 span.nolinebreak {white-space: nowrap}
32 span.roman {font-family: initial; font-weight: normal}
33 span.sansserif {font-family: sans-serif; font-weight: normal}
34 ul.no-bullet {list-style: none}
35 -->
36 </style>
37
38
39 </head>
40
41 <body lang="en">
42 <span id="Compilation"></span><div class="header">
43 <p>
44 Next: <a href="Symbols.html" accesskey="n" rel="next">Symbols</a>, Previous: <a href="Special-Forms-and-Functions.html" accesskey="p" rel="prev">Special Forms and Functions</a>, Up: <a href="index.html" accesskey="u" rel="up">Top</a> &nbsp; [<a href="Function-and-Variable-Index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Function-and-Variable-Index.html" title="Index" rel="index">Index</a>]</p>
45 </div>
46 <hr>
47 <span id="Compilation-1"></span><h2 class="chapter">7 Compilation</h2>
48
49 <dl>
50 <dt id="index-COMPILE">Function: <strong>COMPILE</strong> <em>(name &amp;optional (definition nil))</em></dt>
51 <dd><p>Package:LISP
52 </p>
53 <p>If DEFINITION is NIL, NAME must be the name of a not-yet-compiled
54 function. In this case, COMPILE compiles the function, installs the compiled
55 function as the global function definition of NAME, and returns NAME.
56 If DEFINITION is non-NIL, it must be a lambda expression and NAME must be
57 a symbol. COMPILE compiles the lambda expression, installs the compiled
58 function as the function definition of NAME, and returns NAME.
59 There is only one exception for this: If NAME is NIL, then the compiled
60 function is not installed but is simply returned as the value of COMPILE.
61 In any case, COMPILE creates temporary files whose filenames are
62 &quot;gazonk***&quot;. By default, i.e. if :LEAVE-GAZONK is not supplied or is
63 NIL, these files are automatically deleted after compilation.
64 </p>
65
66 </dd></dl>
67
68 <dl>
69 <dt id="index-LINK">Function: <strong>LINK</strong> <em>(files image &amp;optional post extra-libs (run-user-init t) &amp;aux raw init)</em></dt>
70 <dd><p>Package:LISP
71 </p>
72 <p>On systems where dlopen is used for relocations, one cannot make custom
73 images containing loaded binary object files simply by loading the files
74 and executing save-system. This function is provided for such cases.
75 </p>
76 <p>After compiling source files into objects, LINK can be called with a
77 list of binary and source FILES which would otherwise normally be
78 loaded in sequence before saving the image to IMAGE. LINK will use
79 the system C linker to link the binary files thus supplied with GCL&rsquo;s
80 objects, using EXTRA-LIBS as well if provided, and producing a
81 raw_IMAGE executable. This executable is then run to initialize first
82 GCL&rsquo;s objects, followed by the supplied files, in order, if
83 RUN-USER-INIT is set. In such a case, source files are loaded at
84 their position in the sequence. Any optional code which should be run
85 after file initialization can be supplied in the POST variable. The
86 image is then saved using save-system to IMAGE.
87 </p>
88 <p>This method of creating lisp images may also have the advantage that
89 all new object files are kept out of the lisp core and placed instead
90 in the final image&rsquo;s .text section. This should in principle reduce
91 the core size, speed up garbage collection, and forego any performance
92 penalty induced by data cache flushing on some machines.
93 </p>
94
95 <p>In both the RAW and SAVED image, any calls to LOAD binary object files
96 which have been specified in this list will bypass the normal load
97 procedure, and simply initialize the already linked in module. One
98 can rely on this feature by disabling RUN-USER-INIT, and instead
99 passing the normal build commands in POST. In the course of executing
100 this code, binary modules previously linked into the .text section of
101 the executable will be initialized at the same point at which they
102 would have normally been loaded into the lisp core, in the
103 executable&rsquo;s .data section. In this way, the user can choose to take
104 advantage of the aforementioned possible benefits of this linking
105 method in a relatively transparent way.
106 </p>
107 <p>All binary objects specified in FILES must have been compiled with
108 :SYSTEM-P set to T.
109 </p>
110 </dd></dl>
111
112 <dl>
113 <dt id="index-EVAL_002dWHEN">Special Form: <strong>EVAL-WHEN</strong></dt>
114 <dd><p>Package:LISP
115 </p>
116 <p>Syntax:
117 </p><div class="example">
118 <pre class="example">(eval-when ({situation}*) {form}*)
119 </pre></div>
120
121 <p>A situation must be either COMPILE, LOAD, or EVAL. The interpreter evaluates
122 only when EVAL is specified. If COMPILE is specified, FORMs are evaluated
123 at compile time. If LOAD is specified, the compiler arranges so that FORMs
124 be evaluated when the compiled code is loaded.
125 </p>
126
127 </dd></dl>
128
129 <dl>
130 <dt id="index-COMPILE_002dFILE">Function: <strong>COMPILE-FILE</strong> <em>(input-pathname &amp;key output-file (load nil) (message-file nil) ;GCL specific keywords: system-p c-debug c-file h-file data-file)</em></dt>
131 <dd><p>Package:LISP
132 </p>
133
134 <p>Compiles the file specified by INPUT-PATHNAME and generates a fasl file
135 specified by OUTPUT-FILE. If the filetype is not specified in INPUT-PATHNAME,
136 then &quot;.lsp&quot; is used as the default file type for the source file. :LOAD
137 specifies whether to load the generated fasl file after compilation.
138 :MESSAGE-FILE specifies the log file for the compiler messages. It defaults to
139 the value of the variable COMPILER:*DEFAULT-MESSAGE-FILE*. A non-NIL value of
140 COMPILER::*COMPILE-PRINT* forces the compiler to indicate the form currently
141 being compiled. More keyword parameters are accepted, depending on the
142 version. Most versions of GCL can receive :O-FILE, :C-FILE, :H-FILE, and
143 :DATA-FILE keyword parameters, with which you can control the intermediate
144 files generated by the GCL compiler. Also :C-DEBUG will pass the -g flag to
145 the C compiler.
146 </p>
147
148 <p>By top level forms in a file, we mean the value of *top-level-forms* after
149 doing (TF form) for each form read from a file. We define TF as follows:
150 </p>
151 <p>(defun TF (x)
152 (when (consp x)
153 (setq x (macroexpand x))
154 (when (consp x)
155 (cond ((member (car x) &rsquo;(progn eval-when))
156 (mapcar &rsquo;tf (cdr x)))
157 (t (push x *top-level-forms*))))))
158 </p>
159 <p>Among the common lisp special forms only DEFUN and DEFMACRO will cause actual
160 native machine code to be generated. The rest will be specially treated in an
161 init section of the .data file. This is done so that things like putprop,setq,
162 and many other forms would use up space which could not be usefully freed, if
163 we were to compile to native machine code. If you have other &lsquo;ordinary&rsquo; top
164 level forms which you need to have compiled fully to machine code you may
165 either set compiler::*COMPILE-ORDINARIES* to t, or put them inside a
166 </p>
167 <p>(PROGN &rsquo;COMPILE ...forms-which-need-to-be-compiled)
168 </p>
169 <p>The compiler will take each of them and make a temporary function which will be
170 compiled and invoked once. It is permissible to wrap a (PROGN &rsquo;COMPILE ..)
171 around the whole file. Currently this construction binds the
172 compiler::*COMPILE-ORDINARIES* flag to t. Setting this flag globally to a non
173 nil value to cause all top level forms to generate machine code. This might be
174 useful in a system such as PCL, where a number of top level lambda expressions
175 are given. Note that most common lisps will simply ignore the top level atom
176 &rsquo;compile, since it has no side effects.
177 </p>
178 <p>Defentry, clines, and defcfun also result in machine code being generated.
179 </p>
180 </dd></dl>
181
182 <span id="subsection-Evaluation-at-Compile-time"></span><h2 class="unnumbered">subsection Evaluation at Compile time</h2>
183
184 <p>In GCL the eval-when behaviour was changed in order to allow
185 more efficient init code, and also to bring it into line with the resolution
186 passed by the X3j13 committee. Evaluation at compile time is controlled by
187 placing eval-when special forms in the code, or by the value of the variable
188 compiler::*eval-when-defaults* [default value :defaults]. If that variable
189 has value :defaults, then the following hold:
190 </p>
191 <p>Eval&nbsp;at&nbsp;Compile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type&nbsp;of&nbsp;Top&nbsp;Level&nbsp;Form<!-- /@w --><br>
192 </p>
193 <dl compact="compact">
194 <dt>Partial:</dt>
195 <dd><p>defstructs, defvar, defparameter
196 </p></dd>
197 <dt>Full:</dt>
198 <dd><p>defmacro, defconstant, defsetf, define-setf-method,
199 deftype, package ops, proclaim
200 </p></dd>
201 <dt>None:</dt>
202 <dd><p>defun, others
203 </p></dd>
204 </dl>
205
206
207 <p>By &lsquo;partial&rsquo; we mean (see the X3J13 Common Lisp document
208 (doc/compile-file-handling-of-top-level-forms) for more detail), that functions
209 will not be defined, values will not be set, but other miscellaneous compiler
210 properties will be set: eg properties to inline expand defstruct accessors and
211 testers, defstruct properties allowing subsequent defstructs to include this
212 one, any type hierarch information, special variable information will be set up.
213 </p>
214 <p>Example:
215 </p><div class="example">
216 <pre class="example">(defun foo () 3)
217 (defstruct jo a b)
218 </pre></div>
219
220 <p>As a side effect of compiling these two forms, foo would not have its function
221 cell changed. Neither would jo-a, although it would gain a property which
222 allows it to expand inline to a structure access. Thus if it had a previous
223 definition (as commonly happens from previously loading the file), this previous
224 definition would not be touched, and could well be inconsistent with the
225 compiler properties. Unfortunately this is what the CL standard says to do,
226 and I am just trying to follow it.
227 </p>
228 <p>If you prefer a more intuitive scheme, of evaling all forms in the file, so
229 that there are no inconsistencies, (previous behaviour of AKCL) you may set
230 compiler::*eval-when-defaults* to &rsquo;(compile eval load).
231 </p>
232 <p>The variable compiler::*FASD-DATA* [default t] controls whether an ascii output
233 is used for the data section of the object file. The data section will be in
234 ascii if *fasd-data* is nil or if the system-p keyword is supplied to
235 compile-file and *fasd-data* is not eq to :system-p.
236 </p>
237 <p>The old GCL variable *compile-time-too* has disappeared.
238 </p>
239 <p>See OPTIMIZE on how to enable warnings of slow constructs.
240 </p>
241 <dl>
242 <dt id="index-PROCLAIM">Function: <strong>PROCLAIM</strong> <em>(decl-spec)</em></dt>
243 <dd><p>Package:LISP
244 </p>
245 <p>Puts the declaration given by DECL-SPEC into effect globally. See the doc of
246 DECLARE for possible DECL-SPECs.
247 </p>
248
249 </dd></dl>
250
251
252
253
254
255
256 <dl>
257 <dt id="index-PROVIDE">Function: <strong>PROVIDE</strong> <em>(module-name)</em></dt>
258 <dd><p>Package:LISP
259 </p>
260 <p>Adds the specified module to the list of modules maintained in *MODULES*.
261 </p>
262
263 </dd></dl>
264
265 <dl>
266 <dt id="index-COMPILED_002dFUNCTION_002dP">Function: <strong>COMPILED-FUNCTION-P</strong> <em>(x)</em></dt>
267 <dd><p>Package:LISP
268 </p>
269 <p>Returns T if X is a compiled function; NIL otherwise.
270 </p>
271
272 </dd></dl>
273
274 <dl>
275 <dt id="index-GPROF_002dSTART">Function: <strong>GPROF-START</strong> <em>()</em></dt>
276 <dd><p>Package:SYSTEM
277 </p>
278 <p>GCL now has preliminary support for profiling with gprof, an
279 externally supplied profiling tool at the C level which typically
280 accompanies gcc. Support must be enabled at compile time with
281 &ndash;enable-gprof. This function starts the profiling timers and
282 counters.
283 </p>
284 </dd></dl>
285
286
287 <dl>
288 <dt id="index-GPROF_002dQUIT">Function: <strong>GPROF-QUIT</strong> <em>()</em></dt>
289 <dd><p>Package:SYSTEM
290 </p>
291 <p>GCL now has preliminary support for profiling with gprof, an
292 externally supplied profiling tool at the C level which typically
293 accompanies gcc. Support must be enabled at compile time with
294 &ndash;enable-gprof. This function reports the profiling results in the
295 form of a call graph to standard output, and clears the profiling
296 arrays. Please note that lisp functions are not (yet) displayed with
297 their lisp names. Please see also the PROFILE function.
298 </p>
299 </dd></dl>
300
301
302 <dl>
303 <dt id="index-GPROF_002dSET">Function: <strong>GPROF-SET</strong> <em>(begin end)</em></dt>
304 <dd><p>Package:SYSTEM
305 </p>
306 <p>GCL now has preliminary support for profiling with gprof, an
307 externally supplied profiling tool at the C level which typically
308 accompanies gcc. Support must be enabled at compile time with
309 &ndash;enable-gprof. This function sets the address range used by
310 GPROF-START in specifying the section of the running program which is
311 to be profiled. All subsequent calls to GPROF-START will use this new
312 address range. By default, the range is set to begin at the starting
313 address of the .text section, and to end at the current end of the
314 running core. These default values can be restored by calling
315 GPROF-SET with both argments set to 0.
316 </p>
317 </dd></dl>
318
319
320 <dl>
321 <dt id="index-_002aDEFAULT_002dSYSTEM_002dP_002a">Variable: <strong>*DEFAULT-SYSTEM-P*</strong></dt>
322 <dd><p>Pakcage:COMPILER
323 Specifies the default setting of :SYSTEM-P used by COMPILE. Defaults to NIL.
324 </p></dd></dl>
325
326 <dl>
327 <dt id="index-_002aDEFAULT_002dC_002dFILE_002a">Variable: <strong>*DEFAULT-C-FILE*</strong></dt>
328 <dd><p>Pakcage:COMPILER
329 Specifies the default setting of :C-FILE used by COMPILE. Defaults to NIL.
330 </p></dd></dl>
331
332 <dl>
333 <dt id="index-_002aDEFAULT_002dH_002dFILE_002a">Variable: <strong>*DEFAULT-H-FILE*</strong></dt>
334 <dd><p>Pakcage:COMPILER
335 Specifies the default setting of :H-FILE used by COMPILE. Defaults to NIL.
336 </p></dd></dl>
337
338 <dl>
339 <dt id="index-_002aDEFAULT_002dDATA_002dFILE_002a">Variable: <strong>*DEFAULT-DATA-FILE*</strong></dt>
340 <dd><p>Pakcage:COMPILER
341 Specifies the default setting of :DATA-FILE used by COMPILE. Defaults to NIL.
342 </p></dd></dl>
343
344 <dl>
345 <dt id="index-_002aFEATURES_002a">Variable: <strong>*FEATURES*</strong></dt>
346 <dd><p>Package:LISP
347 List of symbols that name features of the current version of GCL.
348 These features are used to decide the read-time conditionalization facility
349 provided by &rsquo;#+&rsquo; and &rsquo;#-&rsquo; read macros. When the GCL reader encounters
350 </p><div class="example">
351 <pre class="example"> #+ feature-description form
352 </pre></div>
353 <p>it reads FORM in the usual manner if FEATURE-DESCRIPTION is true. Otherwise,
354 the reader just skips FORM.
355 </p><div class="example">
356 <pre class="example"> #- feature-description form
357 </pre></div>
358 <p>is equivalent to
359 </p><div class="example">
360 <pre class="example"> #- (not feature-description) form
361 </pre></div>
362 <p>A feature-description may be a symbol, which is true only when it is an
363 element of *FEATURES*. Or else, it must be one of the following:
364 </p><div class="example">
365 <pre class="example">(and feature-desciption-1 ... feature-desciption-n)
366 (or feature-desciption-1 ... feature-desciption-n)
367 (not feature-desciption)
368 </pre></div>
369 <p>The AND description is true only when all of its sub-descriptions are true.
370 The OR description is true only when at least one of its sub-descriptions is
371 true. The NOT description is true only when its sub-description is false.
372 </p>
373
374 </dd></dl>
375
376
377
378 <hr>
379 <div class="header">
380 <p>
381 Next: <a href="Symbols.html" accesskey="n" rel="next">Symbols</a>, Previous: <a href="Special-Forms-and-Functions.html" accesskey="p" rel="prev">Special Forms and Functions</a>, Up: <a href="index.html" accesskey="u" rel="up">Top</a> &nbsp; [<a href="Function-and-Variable-Index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Function-and-Variable-Index.html" title="Index" rel="index">Index</a>]</p>
382 </div>
383
384
385
386 </body>
387 </html>