PageRenderTime 34ms CodeModel.GetById 5ms RepoModel.GetById 1ms app.codeStats 0ms

/make-host-2.lisp

http://github.com/dmitryvk/sbcl-win32-threads
Lisp | 99 lines | 53 code | 10 blank | 36 comment | 1 complexity | 2058ecf652b2da75cf9ac3d37df44d8a MD5 | raw file
  1. ;;; Set up the cross-compiler.
  2. (setf *print-level* 5 *print-length* 5)
  3. (load "src/cold/shared.lisp")
  4. (in-package "SB-COLD")
  5. ;;; FIXME: these prefixes look like non-pathnamy ways of defining a
  6. ;;; relative pathname. Investigate whether they can be made relative
  7. ;;; pathnames.
  8. (setf *host-obj-prefix* "obj/from-host/"
  9. *target-obj-prefix* "obj/from-xc/")
  10. (load "src/cold/set-up-cold-packages.lisp")
  11. (load "src/cold/defun-load-or-cload-xcompiler.lisp")
  12. (load-or-cload-xcompiler #'host-load-stem)
  13. (defun proclaim-target-optimization ()
  14. (let ((debug (if (position :sb-show *shebang-features*) 2 1)))
  15. (sb-xc:proclaim
  16. `(optimize
  17. (compilation-speed 1) (debug ,debug)
  18. ;; CLISP's pretty-printer is fragile and tends to cause stack
  19. ;; corruption or fail internal assertions, as of 2003-04-20; we
  20. ;; therefore turn off as many notes as possible.
  21. (sb!ext:inhibit-warnings #-clisp 2 #+clisp 3)
  22. ;; SAFETY = SPEED (and < 3) should provide reasonable safety,
  23. ;; but might skip some unreasonably expensive stuff
  24. ;; (e.g. %DETECT-STACK-EXHAUSTION in sbcl-0.7.2).
  25. (safety 2) (space 1) (speed 2)
  26. ;; sbcl-internal optimization declarations:
  27. ;;
  28. ;; never insert stepper conditions
  29. (sb!c:insert-step-conditions 0)))))
  30. (compile 'proclaim-target-optimization)
  31. (defun in-target-cross-compilation-mode (fun)
  32. "Call FUN with everything set up appropriately for cross-compiling
  33. a target file."
  34. (let (;; In order to increase microefficiency of the target Lisp,
  35. ;; enable old CMU CL defined-function-types-never-change
  36. ;; optimizations. (ANSI says users aren't supposed to
  37. ;; redefine our functions anyway; and developers can
  38. ;; fend for themselves.)
  39. #!-sb-fluid
  40. (sb!ext:*derive-function-types* t)
  41. ;; Let the target know that we're the cross-compiler.
  42. (*features* (cons :sb-xc *features*))
  43. ;; We need to tweak the readtable..
  44. (*readtable* (copy-readtable)))
  45. ;; ..in order to make backquotes expand into target code
  46. ;; instead of host code.
  47. ;; FIXME: Isn't this now taken care of automatically by
  48. ;; toplevel forms in the xcompiler backq.lisp file?
  49. (set-macro-character #\` #'sb!impl::backquote-macro)
  50. (set-macro-character #\, #'sb!impl::comma-macro)
  51. (set-dispatch-macro-character #\# #\+ #'she-reader)
  52. (set-dispatch-macro-character #\# #\- #'she-reader)
  53. ;; Control optimization policy.
  54. (proclaim-target-optimization)
  55. ;; Specify where target machinery lives.
  56. (with-additional-nickname ("SB-XC" "SB!XC")
  57. (funcall fun))))
  58. (compile 'in-target-cross-compilation-mode)
  59. ;; Supress function/macro redefinition warnings under clisp.
  60. #+clisp (setf custom:*suppress-check-redefinition* t)
  61. (setf *target-compile-file* #'sb-xc:compile-file)
  62. (setf *target-assemble-file* #'sb!c:assemble-file)
  63. (setf *in-target-compilation-mode-fn* #'in-target-cross-compilation-mode)
  64. ;;; Run the cross-compiler to produce cold fasl files.
  65. (load "src/cold/compile-cold-sbcl.lisp")
  66. ;;; miscellaneous tidying up and saving results
  67. (let ((filename "output/object-filenames-for-genesis.lisp-expr"))
  68. (ensure-directories-exist filename :verbose t)
  69. (with-open-file (s filename :direction :output :if-exists :supersede)
  70. (write *target-object-file-names* :stream s :readably t)))
  71. ;;; Let's check that the type system was reasonably sane. (It's easy
  72. ;;; to spend a long time wandering around confused trying to debug
  73. ;;; cold init if it wasn't.)
  74. (when (position :sb-test *shebang-features*)
  75. (load "tests/type.after-xc.lisp"))
  76. ;;; If you're experimenting with the system under a cross-compilation
  77. ;;; host which supports CMU-CL-style SAVE-LISP, this can be a good
  78. ;;; time to run it. The resulting core isn't used in the normal build,
  79. ;;; but can be handy for experimenting with the system. (See slam.sh
  80. ;;; for an example.)
  81. (when (position :sb-after-xc-core *shebang-features*)
  82. #+cmu (ext:save-lisp "output/after-xc.core" :load-init-file nil)
  83. #+sbcl (sb-ext:save-lisp-and-die "output/after-xc.core")
  84. #+openmcl (ccl::save-application "output/after-xc.core")
  85. #+clisp (ext:saveinitmem "output/after-xc.core"))
  86. #+cmu (ext:quit)
  87. #+clisp (ext:quit)
  88. #+abcl (ext:quit)