|
|
1
|
+;;; Cross-compile script to build an ARM core using x86 as the
|
|
|
2
|
+;;; compiling system. This is based on the x86 to sparc script.
|
|
|
3
|
+;;;
|
|
|
4
|
+;;; This needs work!
|
|
|
5
|
+
|
|
|
6
|
+(in-package :cl-user)
|
|
|
7
|
+
|
|
|
8
|
+;;; Rename the X86 package and backend so that new-backend does the
|
|
|
9
|
+;;; right thing.
|
|
|
10
|
+(rename-package "X86" "OLD-X86" '("OLD-VM"))
|
|
|
11
|
+(setf (c:backend-name c:*native-backend*) "OLD-X86")
|
|
|
12
|
+
|
|
|
13
|
+(c::new-backend "ARM64"
|
|
|
14
|
+ ;; Features to add here
|
|
|
15
|
+ '(:arm64
|
|
|
16
|
+ :relative-package-names ; Relative package names from Allegro
|
|
|
17
|
+ :conservative-float-type
|
|
|
18
|
+ :hash-new
|
|
|
19
|
+ :random-xoroshiro
|
|
|
20
|
+ :modular-arith ; Modular arithmetic
|
|
|
21
|
+ :double-double ; Double-double float support
|
|
|
22
|
+ :unicode
|
|
|
23
|
+
|
|
|
24
|
+ :linux
|
|
|
25
|
+ :glibc2
|
|
|
26
|
+ :unix
|
|
|
27
|
+ )
|
|
|
28
|
+ ;; Features to remove from current *features* here
|
|
|
29
|
+ '(
|
|
|
30
|
+ ;; Other architectures we aren't using. Particularly important
|
|
|
31
|
+ ;; to get rid of sse2 and x87 so we don't accidentally try to
|
|
|
32
|
+ ;; compile the x87/sse2 float support on sparc, which won't work.
|
|
|
33
|
+ :x86 :x86-bootstrap :sse2 :x87 :i486
|
|
|
34
|
+ :alpha :osf1 :mips
|
|
|
35
|
+ ;; Really old stuff that should have been removed long ago.
|
|
|
36
|
+ :propagate-fun-type :propagate-float-type :constrain-float-type
|
|
|
37
|
+ :pentium :long-float :new-random
|
|
|
38
|
+
|
|
|
39
|
+ ;; Other OSes we're not using
|
|
|
40
|
+ :openbsd :freebsd :mach-o :darwin :bsd
|
|
|
41
|
+
|
|
|
42
|
+ ;; We're not building a small core
|
|
|
43
|
+ :small
|
|
|
44
|
+
|
|
|
45
|
+ ;; Other features not yet supported by the ARM port.
|
|
|
46
|
+ :mp
|
|
|
47
|
+ :gencgc
|
|
|
48
|
+ :heap-overflow-check
|
|
|
49
|
+ :stack-checking
|
|
|
50
|
+
|
|
|
51
|
+ ;; Not implemented yet
|
|
|
52
|
+ :complex-fp-vops
|
|
|
53
|
+ :alien-callback
|
|
|
54
|
+ :linkage-table
|
|
|
55
|
+ :random-mt19937
|
|
|
56
|
+ ))
|
|
|
57
|
+
|
|
|
58
|
+;; Temporarily use large values so that error messages in the logs
|
|
|
59
|
+;; contain more information so we don't have to run the cross-compile
|
|
|
60
|
+;; interactively to get all of the info out.
|
|
|
61
|
+(setf *print-length* 64
|
|
|
62
|
+ *print-level* 64
|
|
|
63
|
+ debug:*debug-print-length* 64
|
|
|
64
|
+ debug:*debug-print-level* 64
|
|
|
65
|
+ ext:*describe-print-length* 64
|
|
|
66
|
+ ext:*describe-print-level* 64
|
|
|
67
|
+ ext:*error-print-length* 64
|
|
|
68
|
+ ext:*error-print-level* 64)
|
|
|
69
|
+
|
|
|
70
|
+
|
|
|
71
|
+;;; Changes needed to bootstrap cross-compiling from x86 to arm
|
|
|
72
|
+
|
|
|
73
|
+;; Set up the linkage space stuff appropriately for arm.
|
|
|
74
|
+(setf (c::backend-foreign-linkage-space-start c::*target-backend*)
|
|
|
75
|
+ #x0f000000
|
|
|
76
|
+ (c::backend-foreign-linkage-entry-size c::*target-backend*)
|
|
|
77
|
+ ;; FIXME!
|
|
|
78
|
+ 16)
|
|
|
79
|
+
|
|
|
80
|
+;; Get new fops so we can process fasls with big-endian unicode
|
|
|
81
|
+;; strings on our little-endian compiling system.
|
|
|
82
|
+;;#+unicode
|
|
|
83
|
+;;(load "target:tools/cross-scripts/cross-unicode-big-endian.lisp")
|
|
|
84
|
+
|
|
|
85
|
+;;; End changes needed to bootstrap cross-compiling from x86 to arm
|
|
|
86
|
+
|
|
|
87
|
+;;; Extern-alien-name for the new backend.
|
|
|
88
|
+(in-package :vm)
|
|
|
89
|
+(defun extern-alien-name (name)
|
|
|
90
|
+ (declare (type simple-string name))
|
|
|
91
|
+ ;;(format t "extern-alien-name: ~S~%" name)
|
|
|
92
|
+ ;;(lisp::maybe-swap-string 'extern-alien-name (copy-seq name))
|
|
|
93
|
+ name)
|
|
|
94
|
+(defconstant c::arm-fasl-file-implementation 13)
|
|
|
95
|
+
|
|
|
96
|
+
|
|
|
97
|
+;; FIXME: Enable this with the correct code when we have more of the
|
|
|
98
|
+;; ARM kernel running.
|
|
|
99
|
+(defun fixup-code-object (code offset fixup kind)
|
|
|
100
|
+ (declare (type index offset))
|
|
|
101
|
+ (error "fixup-code-object not implemented"))
|
|
|
102
|
+(export 'fixup-code-object)
|
|
|
103
|
+
|
|
|
104
|
+;; FIXME: implement this correctly
|
|
|
105
|
+(defun sanctify-for-execution (component)
|
|
|
106
|
+ (error "sanctify-for-execution ~S" component)
|
|
|
107
|
+ nil)
|
|
|
108
|
+(export 'sanctify-for-execution)
|
|
|
109
|
+
|
|
|
110
|
+;; Export all external X86 symbols. This wasn't required before, but I
|
|
|
111
|
+;; (rtoy) think this happened when the compiler magic for EXPORT was
|
|
|
112
|
+;; removed to make EXPORT a regular function without compiler magic.
|
|
|
113
|
+(do-external-symbols (s "OLD-X86")
|
|
|
114
|
+ (export (intern (symbol-name s) "VM") "VM"))
|
|
|
115
|
+
|
|
|
116
|
+;;; Compile the new backend.
|
|
|
117
|
+(pushnew :bootstrap *features*)
|
|
|
118
|
+(pushnew :building-cross-compiler *features*)
|
|
|
119
|
+(load "target:tools/comcom")
|
|
|
120
|
+
|
|
|
121
|
+;;; Load the new backend.
|
|
|
122
|
+(setf (search-list "c:")
|
|
|
123
|
+ '("target:compiler/"))
|
|
|
124
|
+(setf (search-list "vm:")
|
|
|
125
|
+ '("c:arm64/" "c:generic/"))
|
|
|
126
|
+(setf (search-list "assem:")
|
|
|
127
|
+ '("target:assembly/" "target:assembly/arm64/"))
|
|
|
128
|
+
|
|
|
129
|
+;; Load the backend of the compiler.
|
|
|
130
|
+
|
|
|
131
|
+(in-package "C")
|
|
|
132
|
+
|
|
|
133
|
+(load "vm:vm-macs")
|
|
|
134
|
+(load "vm:parms")
|
|
|
135
|
+(load "vm:objdef")
|
|
|
136
|
+(load "vm:interr")
|
|
|
137
|
+(load "assem:support")
|
|
|
138
|
+
|
|
|
139
|
+(load "target:compiler/srctran")
|
|
|
140
|
+(load "vm:vm-typetran")
|
|
|
141
|
+(load "target:compiler/float-tran")
|
|
|
142
|
+(load "target:compiler/saptran")
|
|
|
143
|
+
|
|
|
144
|
+(load "vm:macros")
|
|
|
145
|
+(load "vm:utils")
|
|
|
146
|
+
|
|
|
147
|
+(load "vm:vm")
|
|
|
148
|
+(load "vm:insts")
|
|
|
149
|
+(load "vm:primtype")
|
|
|
150
|
+(load "vm:move")
|
|
|
151
|
+(load "vm:sap")
|
|
|
152
|
+(load "vm:system")
|
|
|
153
|
+(load "vm:char")
|
|
|
154
|
+(load "vm:float")
|
|
|
155
|
+
|
|
|
156
|
+(load "vm:memory")
|
|
|
157
|
+(load "vm:static-fn")
|
|
|
158
|
+(load "vm:arith")
|
|
|
159
|
+(load "vm:cell")
|
|
|
160
|
+(load "vm:subprim")
|
|
|
161
|
+(load "vm:debug")
|
|
|
162
|
+(load "vm:c-call")
|
|
|
163
|
+(load "vm:print")
|
|
|
164
|
+(load "vm:alloc")
|
|
|
165
|
+(load "vm:call")
|
|
|
166
|
+(load "vm:nlx")
|
|
|
167
|
+(load "vm:values")
|
|
|
168
|
+(load "vm:array")
|
|
|
169
|
+(load "vm:pred")
|
|
|
170
|
+(load "vm:type-vops")
|
|
|
171
|
+
|
|
|
172
|
+(load "assem:assem-rtns")
|
|
|
173
|
+
|
|
|
174
|
+(load "assem:array")
|
|
|
175
|
+(load "assem:arith")
|
|
|
176
|
+(load "assem:alloc")
|
|
|
177
|
+
|
|
|
178
|
+(load "c:pseudo-vops")
|
|
|
179
|
+
|
|
|
180
|
+(check-move-function-consistency)
|
|
|
181
|
+
|
|
|
182
|
+(load "vm:new-genesis")
|
|
|
183
|
+
|
|
|
184
|
+;;; OK, the cross compiler backend is loaded.
|
|
|
185
|
+
|
|
|
186
|
+(setf *features* (remove :building-cross-compiler *features*))
|
|
|
187
|
+
|
|
|
188
|
+;;; Info environment hacks.
|
|
|
189
|
+(macrolet ((frob (&rest syms)
|
|
|
190
|
+ `(progn ,@(mapcar #'(lambda (sym)
|
|
|
191
|
+ `(defconstant ,sym
|
|
|
192
|
+ (symbol-value
|
|
|
193
|
+ (find-symbol ,(symbol-name sym)
|
|
|
194
|
+ :vm))))
|
|
|
195
|
+ syms))))
|
|
|
196
|
+ (frob OLD-VM:BYTE-BITS
|
|
|
197
|
+ OLD-VM:WORD-BITS
|
|
|
198
|
+ OLD-VM::WORD-BYTES
|
|
|
199
|
+ OLD-VM:CHAR-BITS
|
|
|
200
|
+ OLD-VM:CHAR-BYTES
|
|
|
201
|
+ OLD-VM:LOWTAG-BITS
|
|
|
202
|
+ #+long-float OLD-VM:SIMPLE-ARRAY-LONG-FLOAT-TYPE
|
|
|
203
|
+ OLD-VM:SIMPLE-ARRAY-DOUBLE-FLOAT-TYPE
|
|
|
204
|
+ OLD-VM:SIMPLE-ARRAY-SINGLE-FLOAT-TYPE
|
|
|
205
|
+ #+long-float OLD-VM:SIMPLE-ARRAY-COMPLEX-LONG-FLOAT-TYPE
|
|
|
206
|
+ OLD-VM:SIMPLE-ARRAY-COMPLEX-DOUBLE-FLOAT-TYPE
|
|
|
207
|
+ OLD-VM:SIMPLE-ARRAY-COMPLEX-SINGLE-FLOAT-TYPE
|
|
|
208
|
+ OLD-VM:SIMPLE-ARRAY-UNSIGNED-BYTE-2-TYPE
|
|
|
209
|
+ OLD-VM:SIMPLE-ARRAY-UNSIGNED-BYTE-4-TYPE
|
|
|
210
|
+ OLD-VM:SIMPLE-ARRAY-UNSIGNED-BYTE-8-TYPE
|
|
|
211
|
+ OLD-VM:SIMPLE-ARRAY-UNSIGNED-BYTE-16-TYPE
|
|
|
212
|
+ OLD-VM:SIMPLE-ARRAY-UNSIGNED-BYTE-32-TYPE
|
|
|
213
|
+ OLD-VM:SIMPLE-ARRAY-SIGNED-BYTE-8-TYPE
|
|
|
214
|
+ OLD-VM:SIMPLE-ARRAY-SIGNED-BYTE-16-TYPE
|
|
|
215
|
+ OLD-VM:SIMPLE-ARRAY-SIGNED-BYTE-30-TYPE
|
|
|
216
|
+ OLD-VM:SIMPLE-ARRAY-SIGNED-BYTE-32-TYPE
|
|
|
217
|
+ OLD-VM:SIMPLE-BIT-VECTOR-TYPE
|
|
|
218
|
+ OLD-VM:SIMPLE-STRING-TYPE OLD-VM:SIMPLE-VECTOR-TYPE
|
|
|
219
|
+ OLD-VM:SIMPLE-ARRAY-TYPE OLD-VM:VECTOR-DATA-OFFSET
|
|
|
220
|
+ OLD-VM:DOUBLE-FLOAT-DIGITS
|
|
|
221
|
+ old-vm:single-float-digits
|
|
|
222
|
+ OLD-VM:DOUBLE-FLOAT-EXPONENT-BYTE
|
|
|
223
|
+ OLD-VM:DOUBLE-FLOAT-NORMAL-EXPONENT-MAX
|
|
|
224
|
+ OLD-VM:DOUBLE-FLOAT-SIGNIFICAND-BYTE
|
|
|
225
|
+ OLD-VM:SINGLE-FLOAT-EXPONENT-BYTE
|
|
|
226
|
+ OLD-VM:SINGLE-FLOAT-NORMAL-EXPONENT-MAX
|
|
|
227
|
+ OLD-VM:SINGLE-FLOAT-SIGNIFICAND-BYTE
|
|
|
228
|
+ )
|
|
|
229
|
+ #+double-double
|
|
|
230
|
+ (frob OLD-VM:SIMPLE-ARRAY-COMPLEX-DOUBLE-DOUBLE-FLOAT-TYPE
|
|
|
231
|
+ OLD-VM:SIMPLE-ARRAY-DOUBLE-DOUBLE-FLOAT-TYPE)
|
|
|
232
|
+ )
|
|
|
233
|
+
|
|
|
234
|
+(let ((function (symbol-function 'kernel:error-number-or-lose)))
|
|
|
235
|
+ (let ((*info-environment* (c:backend-info-environment c:*target-backend*)))
|
|
|
236
|
+ (setf (symbol-function 'kernel:error-number-or-lose) function)
|
|
|
237
|
+ (setf (info function kind 'kernel:error-number-or-lose) :function)
|
|
|
238
|
+ (setf (info function where-from 'kernel:error-number-or-lose) :defined)))
|
|
|
239
|
+
|
|
|
240
|
+(defun fix-class (name)
|
|
|
241
|
+ (let* ((new-value (find-class name))
|
|
|
242
|
+ (new-layout (kernel::%class-layout new-value))
|
|
|
243
|
+ (new-cell (kernel::find-class-cell name))
|
|
|
244
|
+ (*info-environment* (c:backend-info-environment c:*target-backend*)))
|
|
|
245
|
+ (remhash name kernel::*forward-referenced-layouts*)
|
|
|
246
|
+ (kernel::%note-type-defined name)
|
|
|
247
|
+ (setf (info type kind name) :instance)
|
|
|
248
|
+ (setf (info type class name) new-cell)
|
|
|
249
|
+ (setf (info type compiler-layout name) new-layout)
|
|
|
250
|
+ new-value))
|
|
|
251
|
+(fix-class 'c::vop-parse)
|
|
|
252
|
+(fix-class 'c::operand-parse)
|
|
|
253
|
+
|
|
|
254
|
+#+random-mt19937
|
|
|
255
|
+(declaim (notinline kernel:random-chunk))
|
|
|
256
|
+
|
|
|
257
|
+(setf c:*backend* c:*target-backend*)
|
|
|
258
|
+
|
|
|
259
|
+;;; Extern-alien-name for the new backend.
|
|
|
260
|
+(in-package :vm)
|
|
|
261
|
+(defun extern-alien-name (name)
|
|
|
262
|
+ (declare (type simple-string name))
|
|
|
263
|
+ name)
|
|
|
264
|
+(export 'extern-alien-name)
|
|
|
265
|
+
|
|
|
266
|
+
|
|
|
267
|
+(in-package :cl-user)
|
|
|
268
|
+
|
|
|
269
|
+;;; Don't load compiler parts from the target compilation
|
|
|
270
|
+
|
|
|
271
|
+(defparameter *load-stuff* nil)
|
|
|
272
|
+
|
|
|
273
|
+;; hack, hack, hack: Make old-x86::any-reg the same as
|
|
|
274
|
+;; x86::any-reg as an SC. Do this by adding old-x86::any-reg
|
|
|
275
|
+;; to the hash table with the same value as x86::any-reg.
|
|
|
276
|
+
|
|
|
277
|
+(let ((ht (c::backend-sc-names c::*target-backend*)))
|
|
|
278
|
+ (setf (gethash 'old-vm::any-reg ht)
|
|
|
279
|
+ (gethash 'vm::any-reg ht)))
|
|
|
280
|
+ |