From: Didier Verna
Subject: [Q] Compiling several times the same file in one Lisp instance
Date: 
Message-ID: <mux1wwy1jdm.fsf@uzeb.lrde.epita.fr>
        Hi !

This might be CMU-CL specific. I've encountered a problem that I fail to
understand. Consider the following file test.cl:


(eval-when (:compile-toplevel)
  (if *optimize*
      (declaim (optimize (speed 3)
			 (compilation-speed 0)
			 (safety 0)
			 (debug 0)))
      (declaim (optimize (speed 0)
			 (compilation-speed 0)
			 (safety 3)
			 (debug 0))))
  (if *inline*
      (declaim (inline fill-array))
      (declaim (notinline fill-array))))

(defun new-array (size)
  (declare (type fixnum size))
  (make-array (* size size)
	      :element-type #+float 'single-float #-float 'fixnum
	      :initial-element #+float 0.0 #-float 0))

(defun fill-array (array value)
  (declare (type (simple-array #+float single-float
			       #-float fixnum (*)) array))
  (declare (type #+float single-float #-float fixnum value))
  (let ((size (array-dimension array 0)))
    (dotimes (i size)
      (setf (aref array i) (+ (aref array i) value))))
  nil)

(defun main ()
  (let ((a (new-array 10)))
    (fill-array a #+float 1.1 #-float 1)))



I want to compile this file with different settings for *optimize*, *inline*
and the :float *feature*. If I compile it on the command-line in two separate
lisp instances, everything goes well:


lisp -eval "(progn (setf *optimize* t *inline* t) (compile-file \"test.cl\" :byte-compile nil))"

lisp -eval "(progn (setf *optimize* nil *inline* nil) (pushnew :float *features*) (compile-file \"test.cl\" :byte-compile nil))"



However, if I automate this compilation, I get strange warnings. The
compilation file is here:

(defvar *optimize* nil)
(defvar *inline* nil)

(defun compile-files ()
  (let ((*optimize* t)
	(*inline* t))
    (compile-file "test.cl" :output-file "test1.x86f"))
  (pushnew :float *features*)
  (compile-file "test.cl" :output-file "test2.x86f" :byte-compile nil))


Running this file with: lisp -load "compile.cl" -eval "(compile-files)"
gives this:

; In: DEFUN MAIN

;   (NEW-ARRAY 10)
; Warning: Result is a (SIMPLE-ARRAY SINGLE-FLOAT
;                       (*)), not a (VALUES &OPTIONAL (SIMPLE-ARRAY FIXNUM #) &REST T).
;
;   (FILL-ARRAY A 1.1)
; Warning: This is not a (VALUES &OPTIONAL FIXNUM &REST T):
;   1.1
;
; Note: Deleting unreachable code.
;
; Compiling Top-Level Form:

; Compilation unit finished.
;   2 warnings
;   1 note



It seems to me that some side effects of the first compilation affect the
second one (related to persistence after compilation ?), but I never loaded
any of those files.



Any help appreciated, thanks !


-- 
Didier Verna, ······@lrde.epita.fr, http://www.lrde.epita.fr/~didier

EPITA / LRDE, 14-16 rue Voltaire   Tel.+33 (1) 44 08 01 85
94276 Le Kremlin-Bic�tre, France   Fax.+33 (1) 53 14 59 22   ······@xemacs.org

From: Alexander
Subject: Re: Compiling several times the same file in one Lisp instance
Date: 
Message-ID: <1142952248.093494.239460@e56g2000cwe.googlegroups.com>
Didier Verna писал(а):

> (eval-when (:compile-toplevel)
>   (if *optimize*
>       (declaim (optimize (speed 3)
> 			 (compilation-speed 0)
> 			 (safety 0)
> 			 (debug 0)))
>       (declaim (optimize (speed 0)
> 			 (compilation-speed 0)
> 			 (safety 3)
> 			 (debug 0))))
>   (if *inline*
>       (declaim (inline fill-array))
>       (declaim (notinline fill-array))))

Is the "(if *opt* (declaim ....))" legal? I tought declaim is top-level
form
http://www.lispworks.com/documentation/HyperSpec/Body/m_declai.htm#declaim
http://www.lispworks.com/documentation/HyperSpec/Body/03_bca.htm.

Why you don't use #+inline(declaim (inline fill-array)) ?
From: Didier Verna
Subject: Re: Compiling several times the same file in one Lisp instance
Date: 
Message-ID: <mux4q1qjz5x.fsf@uzeb.lrde.epita.fr>
"Alexander" <········@gmail.com> wrote:

> Is the "(if *opt* (declaim ....))" legal? I tought declaim is top-level form

        I don't think so. The hyperspec says that /if/ declaim appears at the
top-level, then the effect also occurs at compile-time.


> Why you don't use #+inline(declaim (inline fill-array)) ?

        I could, indeed. That would even be simpler.

-- 
Didier Verna, ······@lrde.epita.fr, http://www.lrde.epita.fr/~didier

EPITA / LRDE, 14-16 rue Voltaire   Tel.+33 (1) 44 08 01 85
94276 Le Kremlin-Bic�tre, France   Fax.+33 (1) 53 14 59 22   ······@xemacs.org
From: Christophe Rhodes
Subject: Re: [Q] Compiling several times the same file in one Lisp instance
Date: 
Message-ID: <sqmzfj26ui.fsf@cam.ac.uk>
Didier Verna <······@lrde.epita.fr> writes:

> This might be CMU-CL specific. I've encountered a problem that I fail to
> understand. Consider the following file test.cl:

I believe it is CMUCL specific, in that it caches derived types of
functions (on the assumption that you might want to call them in
subsequently-compiled files).

Christophe
From: Didier Verna
Subject: Re: [Q] Compiling several times the same file in one Lisp instance
Date: 
Message-ID: <muxy7z2ikhq.fsf@uzeb.lrde.epita.fr>
Christophe Rhodes <·····@cam.ac.uk> wrote:

> I believe it is CMUCL specific, in that it caches derived types of functions
> (on the assumption that you might want to call them in subsequently-compiled
> files).

        Yup. I don't get this with SBCL for instance.

Now the $1000 question is can I trust my freshly recompiled file, despite the
warning...

-- 
Didier Verna, ······@lrde.epita.fr, http://www.lrde.epita.fr/~didier

EPITA / LRDE, 14-16 rue Voltaire   Tel.+33 (1) 44 08 01 85
94276 Le Kremlin-Bic�tre, France   Fax.+33 (1) 53 14 59 22   ······@xemacs.org
From: Christophe Rhodes
Subject: Re: [Q] Compiling several times the same file in one Lisp instance
Date: 
Message-ID: <sqk6amjri1.fsf@cam.ac.uk>
Didier Verna <······@lrde.epita.fr> writes:

> Christophe Rhodes <·····@cam.ac.uk> wrote:
>
>> I believe it is CMUCL specific, in that it caches derived types of functions
>> (on the assumption that you might want to call them in subsequently-compiled
>> files).
>
>         Yup. I don't get this with SBCL for instance.
>
> Now the $1000 question is can I trust my freshly recompiled file, despite the
> warning...

No, you can't.  (My bank details will follow by private mail.)

Christophe