Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > 4a0a3d2c41a3220630917306c0b7fefa > files > 93

gcl-2.6.8-0.13.20130121cvs.fc18.i686.rpm

<html lang="en">
<head>
<title>Compilation - GCL SI Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GCL SI Manual">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="prev" href="Special-Forms-and-Functions.html#Special-Forms-and-Functions" title="Special Forms and Functions">
<link rel="next" href="Symbols.html#Symbols" title="Symbols">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Compilation"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Symbols.html#Symbols">Symbols</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Special-Forms-and-Functions.html#Special-Forms-and-Functions">Special Forms and Functions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
</div>

<h2 class="chapter">7 Compilation</h2>

<div class="defun">
&mdash; Function: <b>COMPILE</b> (<var>name &amp;optional </var>(<var>definition nil</var>))<var><a name="index-COMPILE-595"></a></var><br>
<blockquote><p>Package:LISP

        <p>If DEFINITION is NIL, NAME must be the name of a not-yet-compiled
function.  In this case, COMPILE compiles the function, installs the compiled
function as the global function definition of NAME, and returns NAME. 
If DEFINITION is non-NIL, it must be a lambda expression and NAME must be
a symbol.  COMPILE compiles the lambda expression, installs the compiled
function as the function definition of NAME, and returns NAME. 
There is only one exception for this:  If NAME is NIL, then the compiled
function is not installed but is simply returned as the value of COMPILE. 
     In any case, COMPILE creates temporary files whose filenames are
"gazonk***".  By default, i.e. if :LEAVE-GAZONK is not supplied or is
NIL, these files are automatically deleted after compilation.

     </blockquote></div>

<div class="defun">
&mdash; Function: <b>LINK</b> (<var>files image &amp;optional post extra-libs </var>(<var>run-user-init t</var>)<var> &amp;aux raw init</var>)<var><a name="index-LINK-596"></a></var><br>
<blockquote><p>Package:LISP

        <p>On systems where dlopen is used for relocations, one cannot make custom
images containing loaded binary object files simply by loading the files
and executing save-system.  This function is provided for such cases.

        <p>After compiling source files into objects, LINK can be called with a
list of binary and source FILES which would otherwise normally be
loaded in sequence before saving the image to IMAGE.  LINK will use
the system C linker to link the binary files thus supplied with GCL's
objects, using EXTRA-LIBS as well if provided, and producing a
raw_IMAGE executable. This executable is then run to initialize first
GCL's objects, followed by the supplied files, in order, if
RUN-USER-INIT is set.  In such a case, source files are loaded at
their position in the sequence.  Any optional code which should be run
after file initialization can be supplied in the POST variable.  The
image is then saved using save-system to IMAGE.

        <p>This method of creating lisp images may also have the advantage that
all new object files are kept out of the lisp core and placed instead
in the final image's .text section.  This should in principle reduce
the core size, speed up garbage collection, and forego any performance
penalty induced by data cache flushing on some machines.

        <p>In both the RAW and SAVED image, any calls to LOAD binary object files
which have been specified in this list will bypass the normal load
procedure, and simply initialize the already linked in module.  One
can rely on this feature by disabling RUN-USER-INIT, and instead
passing the normal build commands in POST.  In the course of executing
this code, binary modules previously linked into the .text section of
the executable will be initialized at the same point at which they
would have normally been loaded into the lisp core, in the
executable's .data section.  In this way, the user can choose to take
advantage of the aforementioned possible benefits of this linking
method in a relatively transparent way.

        <p>All binary objects specified in FILES must have been compiled with
:SYSTEM-P set to T.

        </blockquote></div>

<div class="defun">
&mdash; Special Form: <b>EVAL-WHEN</b><var><a name="index-EVAL_002dWHEN-597"></a></var><br>
<blockquote><p>Package:LISP

        <p>Syntax:
     <pre class="example">          (eval-when ({situation}*) {form}*)
</pre>
        <p>A situation must be either COMPILE, LOAD, or EVAL.  The interpreter evaluates
only when EVAL is specified.  If COMPILE is specified, FORMs are evaluated
at compile time.  If LOAD is specified, the compiler arranges so that FORMs
be evaluated when the compiled code is loaded.

        </blockquote></div>

<div class="defun">
&mdash; Function: <b>COMPILE-FILE</b> (<var>input-pathname &amp;key output-file </var>(<var>load nil</var>) (<var>message-file nil</var>)<var> ;GCL specific keywords: system-p c-debug c-file h-file data-file</var>)<var><a name="index-COMPILE_002dFILE-598"></a></var><br>
<blockquote><p>Package:LISP

        <p>Compiles the file specified by INPUT-PATHNAME and generates a fasl file
specified by OUTPUT-FILE.  If the filetype is not specified in INPUT-PATHNAME,
then ".lsp" is used as the default file type for the source file.  :LOAD
specifies whether to load the generated fasl file after compilation. 
:MESSAGE-FILE specifies the log file for the compiler messages.  It defaults to
the value of the variable COMPILER:*DEFAULT-MESSAGE-FILE*.  A non-NIL value of
COMPILER::*COMPILE-PRINT* forces the compiler to indicate the form currently
being compiled.  More keyword parameters are accepted, depending on the
version.  Most versions of GCL can receive :O-FILE, :C-FILE, :H-FILE, and
:DATA-FILE keyword parameters, with which you can control the intermediate
files generated by the GCL compiler.  Also :C-DEBUG will pass the -g flag to
the C compiler.

        <p>By top level forms in a file, we mean the value of *top-level-forms* after
doing (TF form) for each form read from a file.  We define TF as follows:

        <p>(defun TF (x)
 (when (consp x)
  (setq x (macroexpand x))
  (when (consp x)
     (cond ((member (car x) '(progn  eval-when))
            (mapcar 'tf (cdr x)))
           (t  (push x *top-level-forms*))))))

        <p>Among the common lisp special forms only DEFUN and DEFMACRO will cause actual
native machine code to be generated.  The rest will be specially treated in an
init section of the .data file.  This is done so that things like putprop,setq,
and many other forms would use up space which could not be usefully freed, if
we were to compile to native machine code.  If you have other `ordinary' top
level forms which you need to have compiled fully to machine code you may
either set compiler::*COMPILE-ORDINARIES* to t, or put them inside a

        <p>(PROGN 'COMPILE ...forms-which-need-to-be-compiled)

        <p>The compiler will take each of them and make a temporary function which will be
compiled and invoked once.  It is permissible to wrap a (PROGN 'COMPILE ..) 
around the whole file.  Currently this construction binds the
compiler::*COMPILE-ORDINARIES* flag to t.  Setting this flag globally to a non
nil value to cause all top level forms to generate machine code.  This might be
useful in a system such as PCL, where a number of top level lambda expressions
are given.  Note that most common lisps will simply ignore the top level atom
'compile, since it has no side effects.

        <p>Defentry, clines, and defcfun also result in machine code being generated.

<h2 class="unnumbered">subsection Evaluation at Compile time</h2>

     <p>In GCL the eval-when behaviour was changed in order to allow
more efficient init code, and also to bring it into line with the resolution
passed by the X3j13 committee.  Evaluation at compile time is controlled by
placing eval-when special forms in the code, or by the value of the variable
compiler::*eval-when-defaults* [default value :defaults].  If that variable
has value :defaults, then the following hold:

        <p>Eval&nbsp;at&nbsp;Compile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type&nbsp;of&nbsp;Top&nbsp;Level&nbsp;Form<!-- /@w --><br>

          <dl>
<dt>Partial:<dd>defstructs, defvar, defparameter
<br><dt>Full:<dd>defmacro, defconstant, defsetf, define-setf-method,
			deftype, package ops, proclaim
<br><dt>None:<dd>defun, others
</dl>

        <p>By `partial' we mean (see the X3J13 Common Lisp document
(doc/compile-file-handling-of-top-level-forms) for more detail), that functions
will not be defined, values will not be set, but other miscellaneous compiler
properties will be set: eg properties to inline expand defstruct accessors and
testers, defstruct properties allowing subsequent defstructs to include this
one, any type hierarch information, special variable information will be set up.

        <p>Example:
     <pre class="example">          (defun foo () 3)
          (defstruct jo a b)
</pre>
        <p>As a side effect of compiling these two forms, foo would not have its function
cell changed.  Neither would jo-a, although it would gain a property which
allows it to expand inline to a structure access.  Thus if it had a previous
definition (as commonly happens from previously loading the file), this previous
definition would not be touched, and could well be inconsistent with the
compiler properties.  Unfortunately this is what the CL standard says to do,
and I am just trying to follow it.

        <p>If you prefer a more intuitive scheme, of evaling all forms in the file, so
that there are no inconsistencies, (previous behaviour of AKCL) you may set
compiler::*eval-when-defaults* to '(compile eval load).

        <p>The variable compiler::*FASD-DATA* [default t] controls whether an ascii output
is used for the data section of the object file.  The data section will be in
ascii if *fasd-data* is nil or if the system-p keyword is supplied to
compile-file and *fasd-data* is not eq to :system-p.

        <p>The old GCL variable *compile-time-too* has disappeared.

        <p>See OPTIMIZE on how to enable warnings of slow constructs.

        </blockquote></div>

<div class="defun">
&mdash; Function: <b>PROCLAIM</b> (<var>decl-spec</var>)<var><a name="index-PROCLAIM-599"></a></var><br>
<blockquote><p>Package:LISP

        <p>Puts the declaration given by DECL-SPEC into effect globally.  See the doc of
DECLARE for possible DECL-SPECs.

        </blockquote></div>

<div class="defun">
&mdash; Function: <b>PROVIDE</b> (<var>module-name</var>)<var><a name="index-PROVIDE-600"></a></var><br>
<blockquote><p>Package:LISP

        <p>Adds the specified module to the list of modules maintained in *MODULES*.

        </blockquote></div>

<div class="defun">
&mdash; Function: <b>COMPILED-FUNCTION-P</b> (<var>x</var>)<var><a name="index-COMPILED_002dFUNCTION_002dP-601"></a></var><br>
<blockquote><p>Package:LISP

        <p>Returns T if X is a compiled function; NIL otherwise.

        </blockquote></div>

<div class="defun">
&mdash; Function: <b>GPROF-START</b> ()<var><a name="index-GPROF_002dSTART-602"></a></var><br>
<blockquote><p>Package:SYSTEM

        <p>GCL now has preliminary support for profiling with gprof, an
externally supplied profiling tool at the C level which typically
accompanies gcc.  Support must be enabled at compile time with
&ndash;enable-gprof.  This function starts the profiling timers and
counters.

        </blockquote></div>

<div class="defun">
&mdash; Function: <b>GPROF-QUIT</b> ()<var><a name="index-GPROF_002dQUIT-603"></a></var><br>
<blockquote><p>Package:SYSTEM

        <p>GCL now has preliminary support for profiling with gprof, an
externally supplied profiling tool at the C level which typically
accompanies gcc.  Support must be enabled at compile time with
&ndash;enable-gprof.  This function reports the profiling results in the
form of a call graph to standard output, and clears the profiling
arrays.  Please note that lisp functions are not (yet) displayed with
their lisp names.  Please see also the PROFILE function.

        </blockquote></div>

<div class="defun">
&mdash; Function: <b>GPROF-SET</b> (<var>begin end</var>)<var><a name="index-GPROF_002dSET-604"></a></var><br>
<blockquote><p>Package:SYSTEM

        <p>GCL now has preliminary support for profiling with gprof, an
externally supplied profiling tool at the C level which typically
accompanies gcc.  Support must be enabled at compile time with
&ndash;enable-gprof.  This function sets the address range used by
GPROF-START in specifying the section of the running program which is
to be profiled.  All subsequent calls to GPROF-START will use this new
address range.  By default, the range is set to begin at the starting
address of the .text section, and to end at the current end of the
running core.  These default values can be restored by calling
GPROF-SET with both argments set to 0.

        </blockquote></div>

<div class="defun">
&mdash; Variable: <b>*DEFAULT-SYSTEM-P*</b><var><a name="index-g_t_002aDEFAULT_002dSYSTEM_002dP_002a-605"></a></var><br>
<blockquote><p>Pakcage:COMPILER
Specifies the default setting of :SYSTEM-P used by COMPILE.  Defaults to NIL. 
</p></blockquote></div>

<div class="defun">
&mdash; Variable: <b>*DEFAULT-C-FILE*</b><var><a name="index-g_t_002aDEFAULT_002dC_002dFILE_002a-606"></a></var><br>
<blockquote><p>Pakcage:COMPILER
Specifies the default setting of :C-FILE used by COMPILE.  Defaults to NIL. 
</p></blockquote></div>

<div class="defun">
&mdash; Variable: <b>*DEFAULT-H-FILE*</b><var><a name="index-g_t_002aDEFAULT_002dH_002dFILE_002a-607"></a></var><br>
<blockquote><p>Pakcage:COMPILER
Specifies the default setting of :H-FILE used by COMPILE.  Defaults to NIL. 
</p></blockquote></div>

<div class="defun">
&mdash; Variable: <b>*DEFAULT-DATA-FILE*</b><var><a name="index-g_t_002aDEFAULT_002dDATA_002dFILE_002a-608"></a></var><br>
<blockquote><p>Pakcage:COMPILER
Specifies the default setting of :DATA-FILE used by COMPILE.  Defaults to NIL. 
</p></blockquote></div>

<div class="defun">
&mdash; Variable: <b>*FEATURES*</b><var><a name="index-g_t_002aFEATURES_002a-609"></a></var><br>
<blockquote><p>Package:LISP
List of symbols that name features of the current version of GCL. 
These features are used to decide the read-time conditionalization facility
provided by '#+' and '#-' read macros.  When the GCL reader encounters
     <pre class="example">          	#+ feature-description form
</pre>
        <p>it reads FORM in the usual manner if FEATURE-DESCRIPTION is true.  Otherwise,
the reader just skips FORM.
     <pre class="example">          	#- feature-description form
</pre>
        <p>is equivalent to
     <pre class="example">          	#- (not feature-description) form
</pre>
        <p>A feature-description may be a symbol, which is true only when it is an
element of *FEATURES*.  Or else, it must be one of the following:
     <pre class="example">          (and feature-desciption-1 ... feature-desciption-n)
          (or  feature-desciption-1 ... feature-desciption-n)
          (not feature-desciption)
</pre>
        <p>The AND description is true only when all of its sub-descriptions are true. 
The OR description is true only when at least one of its sub-descriptions is
true.  The NOT description is true only when its sub-description is false.

        </blockquote></div>

   </body></html>