Debian Codegraph @

src/bare.lsp.in

raw ◀ ▶
1 Debian patch touch this file
1 ;;;; -*- Mode: Lisp; Syntax: Common-Lisp; indent-tabs-mode: nil -*-
2 ;;;; vim: set filetype=lisp tabstop=8 shiftwidth=2 expandtab:
3
4 ;;; @configure_input@
5 ;;;
6 ;;; This file can be loaded either in ECL_MIN or in the final executable
7 ;;; ECL. In both cases, it ensures that we have a working Common-Lisp
8 ;;; environment (either interpreted, as in ECL_MIN, or compiled, as in ECL),
9 ;;; that the compiler is loaded, that we use the headers in this directory,
10 ;;; etc.
11 ;;;
12 ;;; * By redefining "SYS:" ECL will be able to
13 ;;; find headers and libraries in the build directory.
14 ;;;
15 (princ "
16 ;;;
17 ;;; Welcome to bare.lsp. Let's bring this instance up!
18 ;;;")
19
20 (sys:*make-constant '+ecl-optimization-settings+
21 '((optimize (safety 2) (speed 1) (debug 1) (space 1))
22 (ext:check-arguments-type nil)))
23 (sys:*make-constant '+ecl-unsafe-declarations+
24 '(optimize (safety 0) (speed 3) (debug 0) (space 0)))
25 (sys:*make-constant '+ecl-safe-declarations+
26 '(optimize (safety 2) (speed 1) (debug 1) (space 1)))
27
28 (si::pathname-translations "SRC" `(("**;*.*.*" "@true_srcdir@/**/*.*")))
29 (si::pathname-translations "EXT" `(("**;*.*.*" "@true_srcdir@/../contrib/**/*.*")))
30 (si::pathname-translations "BUILD" `(("**;*.*.*" "@true_builddir@/**/*.*")))
31 (si::pathname-translations "SYS" '(("**;*.*.*" "@true_builddir@/**/*.*")))
32
33 ;;;
34 ;;; * Set ourselves in the 'SYSTEM package
35 ;;;
36 (setq *package* (find-package "SYSTEM"))
37 (setq si::*keep-definitions* nil)
38
39 ;;;
40 ;;; * Create bogus commit version number
41 ;;;
42
•43 (setq si::+commit-id+ "294da20f")
44
45 ;;;
46 ;;; * Setup cross compilation
47 ;;;
48
49 (when (member "CROSS" *features* :test #'string-equal)
50 (sys:*make-constant 'most-negative-fixnum (parse-integer "@CL_FIXNUM_MIN@" :junk-allowed t))
51 (sys:*make-constant 'most-positive-fixnum (parse-integer "@CL_FIXNUM_MAX@" :junk-allowed t))
52 (sys:*make-constant 'cl-fixnum-bits @CL_FIXNUM_BITS@)
53 (sys:*make-constant 'array-dimension-limit most-positive-fixnum)
54 (sys:*make-constant 'array-total-size-limit most-positive-fixnum)
55 (sys:*make-constant 'ffi:c-short-min (- (ash 1 (1- @CL_SHORT_BITS@))))
56 (sys:*make-constant 'ffi:c-short-max (1- (ash 1 (1- @CL_SHORT_BITS@))))
57 (sys:*make-constant 'ffi:c-ushort-max (1- (ash 1 @CL_SHORT_BITS@)))
58 (sys:*make-constant 'ffi:c-int-min (- (ash 1 (1- @CL_INT_BITS@))))
59 (sys:*make-constant 'ffi:c-int-max (1- (ash 1 (1- @CL_INT_BITS@))))
60 (sys:*make-constant 'ffi:c-uint-max (1- (ash 1 @CL_INT_BITS@)))
61 (sys:*make-constant 'ffi:c-long-min (- (ash 1 (1- @CL_LONG_BITS@))))
62 (sys:*make-constant 'ffi:c-long-max (1- (ash 1 (1- @CL_LONG_BITS@))))
63 (sys:*make-constant 'ffi:c-ulong-max (1- (ash 1 @CL_LONG_BITS@)))
64 (when (member "LONG-LONG" *features* :test #'string-equal)
65 (sys:*make-constant 'ffi:c-long-long-min (- (ash 1 (1- @ECL_LONG_LONG_BITS@))))
66 (sys:*make-constant 'ffi:c-long-long-max (1- (ash 1 (1- @ECL_LONG_LONG_BITS@))))
67 (sys:*make-constant 'ffi:c-ulong-long-max (1- (ash 1 @ECL_LONG_LONG_BITS@)))))
68
69 ;;;
70 ;;; * Load Common-Lisp base library
71 ;;;
72 (princ "
73 ;;;
74 ;;; About to load lsp/load.lsp
75 ;;; ")
76
77 (if (or (member "ECL-MIN" *features* :test #'string-equal)
78 (member "CROSS" *features* :test #'string-equal))
79 (load "lsp/load.lsp" :verbose nil))
80
81 (defun si::process-command-args () )
82
83 ;;;
84 ;;; * Load PCL-based Common-Lisp Object System
85 ;;;
86 (setf sys::*gc-verbose* nil)
87 #+(or ecl-min cross)
88 (progn
89 (terpri)
90 (princ ";;; Loading clos/load.lsp")
91 (load "clos/load.lsp" :verbose nil))
92
93 #+cmu-format
94 (progn
95 (terpri)
96 (princ ";;; Loading lsp/format.lsp")
97 (load "src:lsp;format.lsp" :verbose nil))
98
99 ;;;
100 ;;; * Load the compiler.
101 ;;;
102
103 ;; Make sure compiler sees what it should see.
104 #-:wants-dlopen (setq *features* (delete :dlopen *features*))
105 #+:wants-dlopen (push :dlopen *features*)
106
107 (terpri)
108 (princ #+(or cross ecl-min) ";;; About to load cmp/load.lsp"
109 #-(or cross ecl-min) ";;; About to load cmp.so")
110
111 (load #+(or cross ecl-min) "@ECL_CMPDIR@/load.lsp"
112 #-(or cross ecl-min) "cmp.so")
113
114 ;;;
115 ;;; * Change the place where temporary files go to
116 ;;;
117 (si::pathname-translations "TMP" '(("**;*.*.*" "@true_builddir@/**/*.*")))
118
119 ;;;
120 ;;; * Remove documentation from compiled files
121 ;;;
122 (setq si::*keep-documentation* nil)
123
124 ;;;
125 ;;; * Timed compilation facility.
126 ;;;
127 (defun compile-if-old (destdir sources &rest options)
128 (ensure-directories-exist destdir :mode #o0777)
129 (mapcar #'(lambda (source)
130 (let ((object (merge-pathnames destdir (compile-file-pathname source :type :object))))
131 (unless (and (probe-file object)
132 (>= (file-write-date object) (file-write-date source)))
133 (format t "~&(compile-file ~S :output-file ~S~{ ~S~})~%"
134 source object options)
135 (apply #'compile-file source :output-file object options))
136 object))
137 sources))
138
139 (defvar *module-symbols* nil)
140 (defvar *module-files* nil)
141
142 (defun build-fake-module (name lisp-files)
143 (let* ((output (make-pathname :type "fasc" :defaults name))
144 (files '()))
145 (unwind-protect
146 (let ((ext:*source-location* nil))
147 (loop for i in lisp-files do (push (open i :direction :input) files))
148 (setf files (nreverse files))
149 (let ((joined (apply #'make-concatenated-stream files)))
150 (ext::bc-compile-file joined :output-file output)))
151 (mapc #'close files))
152 output))
153
154 (make-package "ASDF")
155
156 (defun build-fake-asdf (name static-library compiled-filename &key depends-on)
157 (let ((path (make-pathname :name name :type "asd"))
158 (compiled (make-pathname :host "SYS"
159 :name (pathname-name compiled-filename)
160 :type (pathname-type compiled-filename)))
161 (library (make-pathname :host "SYS"
162 :name (pathname-name static-library)
163 :type (pathname-type static-library))))
164 (with-open-file (*standard-output* path
165 :direction :output :if-exists :supersede
166 :if-does-not-exist :create)
167 (format t "
168 (defsystem ~S :class asdf::prebuilt-system
169 :lib ~S
170 :depends-on ~S
171 :components ((:compiled-file ~S :pathname ~S)))"
172 name library depends-on (string name) compiled))
173 path))
174
175 (defun init-name (name)
176 (concatenate 'string "init_lib_" (string-upcase (substitute #\_ #\- name))))
177
178 (defun build-module (name sources &key additional-files depends-on
179 (builtin nil) (dir "build:")
180 ((:prefix si::*init-function-prefix*) "EXT"))
181 (mapc #'proclaim +ecl-optimization-settings+)
182 (let* ((name (string-downcase name)))
183 (when additional-files
184 (setf *module-files* (append additional-files *module-files*)))
185 (let* ((objects (compile-if-old dir sources :system-p t :c-file t
186 :data-file t :h-file t))
187 (compiled-file-name (string name))
188 (static-library (c::build-static-library name
189 :lisp-files objects
190 :init-name (init-name name))))
191 (push static-library *module-files*)
192 (when builtin
193 (push (intern name) *module-symbols*))
194 #-:wants-dlopen
195 (push (build-fake-module name sources) *module-files*)
196 #+:wants-dlopen
197 (push (setf compiled-file-name (c::build-fasl name :lisp-files objects))
198 *module-files*)
199 (push (if (equalp name "asdf")
200 (build-fake-asdf "prebuilt-asdf" static-library compiled-file-name :depends-on '("cmp"))
201 (build-fake-asdf name static-library compiled-file-name :depends-on depends-on))
202 *module-files*)
203 )))
204
205 ;;;
206 ;;; * Update version number now that SI:SYSTEM is available
207 ;;;
208
209 (let ((commit-id (probe-file "@true_srcdir@/../.git/logs/HEAD")))
210 (when commit-id
211 (let ((last nil))
212 (with-open-file (file commit-id :direction :input :element-type :default
213 :external-format :default)
214 (loop for l = (read-line file nil nil nil)
215 while l
216 do (setf last l)))
217 (when last
218 (handler-case
219 (let* ((start (position #\Space last)))
220 (when start
221 (let ((end (position #\Space last :start (incf start))))
222 (when end
223 (setq si::+commit-id+ (subseq last start end))))))
224 (serious-condition ()))))))
225 ;;;
226 ;;; * Go back to build directory to start compiling
227 ;;;
228 #+ecl-min
229 (setq *features* (cons :stage1 (remove :ecl-min *features*)))
230
231 (terpri)
232 (princ ";;;
233 ;;; Now we are in shape to do something useful.
234 ;;; End of bare.lsp")
235 (terpri)
236 (setf c::*compiler-break-enable* t)