From 0b7e16bb78d7715409c44bf6b41f9fb234b8f987 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Thu, 7 Aug 2008 22:27:42 +0000 Subject: * lisp/core.lisp.in (boot-completed-p): New. (|$useDynamicLink|): Likewise. (|$effectiveFaslType|): Hold extension of linkable FASL. (|$NativeModuleExt|): Tidy. (|$CoreLibName|): New. (|$ExtraRuntimeLibraries|): Likewise. (extra-runtime-libs): Likewise. (complete-fasl-list-for-link): Likewise. (|link|) [ECL]: Link against system libraries. (|compileLispFile|): Tidy. (begin-compile-time): New. (end-compile-time): Likewise. (compile-time-p): Likewise. (import-module): Use it. * lisp/Makefile.in ($(OUT)/lisp$(EXEEXT)): Use oa_c_runtime_extra. * lib/Makefile.in (oa_installed_corelib): New. * boot/initial-env.lisp: Don't export systemRootDirectory and systemLibraryDirectory from here. * boot/translator.boot (systemRootDirectory): Move to lisp/core.lisp. (systemLibraryDirectory): Likewise. (loadSystemRuntimeCore): Do nothing for GCL and ECL. * interp/boot-pkg.lisp: Inform that Boot system is compleye. --- src/lisp/Makefile.in | 4 +- src/lisp/core.lisp.in | 129 +++++++++++++++++++++++++++++++++++++------------- 2 files changed, 99 insertions(+), 34 deletions(-) (limited to 'src/lisp') diff --git a/src/lisp/Makefile.in b/src/lisp/Makefile.in index 0c24a2c9..be8f7f0a 100644 --- a/src/lisp/Makefile.in +++ b/src/lisp/Makefile.in @@ -92,7 +92,7 @@ ifeq (@axiom_lisp_flavor@,gcl) ' (si::sgc-on nil))' \ ' (setq si::*top-level-hook* (read-from-string \"|AxiomCore|::|topLevel|\")))"' \ ' si::*system-directory* (quote (list ".lsp")))' \ - ' "$(lisp_c_objects) @axiom_c_runtime_extra@"))' \ + ' "$(lisp_c_objects) $(oa_c_runtime_extra)"))' \ | ./base-lisp$(EXEEXT) $(mkdir_p) $(OUT) cp -p lisp$(EXEEXT) $(OUT) @@ -131,6 +131,8 @@ edit = sed \ -e 's|@build[@]|$(build)|g' \ -e 's|@target[@]|$(target)|g' \ -e 's|@SHREXT[@]|$(SHREXT)|g' \ + -e 's|@LIBEXT[@]|$(LIBEXT)|g' \ + -e 's|@oa_c_runtime_extra[@]|$(oa_c_runtime_extra)|g' \ -e 's|@void_type[@]|$(void_type)|g' \ -e 's|@char_type[@]|$(char_type)|g' \ -e 's|@int_type[@]|$(int_type)|g' \ diff --git a/src/lisp/core.lisp.in b/src/lisp/core.lisp.in index 96ae877f..76b9753c 100644 --- a/src/lisp/core.lisp.in +++ b/src/lisp/core.lisp.in @@ -93,6 +93,8 @@ "compileLispFile" "compileLispHandler" "Option" + "systemRootDirectory" + "systemLibraryDirectory" "pathBasename" @@ -124,9 +126,21 @@ '(@axiom_optimize_options@)) (proclaim '(optimize @axiom_optimize_options@)) + +;; Return true if the Boot system is complete bootstrapped. +(defun boot-completed-p nil + (member :open-axiom-boot-complete *features*)) + ;; ;; -*- Hosting Lisp System -*- -;; +;; + +;; Almost every supported Lisp use dynamic link for FFI. +;; ECL's support is partial. GCL-2.6.x hasn't discovered it yet. +(defconstant |$useDynamicLink| + #+:ecl si::*use-dffi* + #+:gcl nil + #-(or :ecl :gcl) t) ;; The top level read-eval-print loop function of the base ;; Lisp system we are using. This is a very brittle way @@ -145,17 +159,31 @@ (pathname-type (compile-file-pathname "foo.lisp"))) (defconstant |$effectiveFaslType| - ;#+:ecl (pathname-type (compile-file-pathname "foo.lisp" :system-p t)) - ;; until ECL is fixed, return a hard coded value - #+:ecl "o" + #+:ecl (pathname-type (compile-file-pathname "foo.lisp" :system-p t)) #-:ecl |$faslType|) ;; Extension of file containers for native shared libraries. (defconstant |$NativeModuleExt| - "@SHREXT@") + (cond (|$useDynamicLink| "@SHREXT@") + (t ".@LIBEXT@"))) + +;; Base name of the native core runtime library +(defconstant |$CoreLibName| + "open-axiom-core") + +;; C runtime needed by the target system; e.g. -lm or -lwinsock +(defconstant |$ExtraRuntimeLibraries| + "@oa_c_runtime_extra@") + +(defun extra-runtime-libs nil + (if (boot-completed-p) + (list (concatenate 'string "-L" (|systemLibraryDirectory|)) + (concatenate 'string "-l" |$CoreLibName|) + |$ExtraRuntimeLibraries|) + (list |$ExtraRuntimeLibraries|))) ;; -;; -*- OpenAxiom source file extensions -*- +;; -*- OpenAxiom filesystem -*- ;; (defconstant |$BootFileType| "boot") @@ -170,6 +198,27 @@ |$LispFileType|) (t file-type)))) +;; Returns the root directory of the running system. +;; A directory specified on command line takes precedence +;; over directory specified at configuration time. +(defun |systemRootDirectory| nil + (let ((dir (assoc (|Option| '|system|) (|%systemOptions|)))) + (if (not (null dir)) + (|ensureTrailingSlash| (cdr dir)) + |$systemInstallationDirectory|))) + +;; Returns the directory containing the core runtime support +;; libraries, either as specified on command line, or as inferred +;; from the system root directory. +(defun |systemLibraryDirectory| nil + (let ((dir (assoc (|Option| '|syslib|) (|%systemOptions|)))) + (if (not (null dir)) + (|ensureTrailingSlash| (cdr dir)) + (concatenate 'string (|systemRootDirectory|) "lib/")))) + + +(defun complete-fasl-list-for-link (fasls) + (mapcar #'|compileFilePathname| fasls)) ;; ;; -*- OpenAxiom Driver Table -*- @@ -184,7 +233,8 @@ ;; --compile: boot or lisp files ;; --translate: boot files ;; --make: boot, lisp, or fasl files -(defparameter |$driverTable| (make-hash-table :test #'equal :size 5)) +(defparameter |$driverTable| + (make-hash-table :test #'equal :size 5)) ;; Look up the driver that can handle REQUEST. Returns nil when @@ -493,8 +543,9 @@ (unless entry-point (setq entry-point #'si::top-level)) (c:build-program core-image - :lisp-files (mapcar #'|compileFilePathname| - lisp-files) + :lisp-files + (complete-fasl-list-for-link lisp-files) + :ld-flags (extra-runtime-libs) :epilogue-code `(funcall ,entry-point)) (|coreQuit|))) @@ -645,6 +696,7 @@ ;; compilation process for ECL: ;; (1) compile as object code; ;; (2) build a FASL from the result of (1). + (defun |compileLispFile| (file out-file) ;; When OUT-FILE does not have a specified parent directory, it is ;; implied that the compiled file is placed in the current directory. @@ -658,29 +710,30 @@ (make-pathname :name (pathname-name out-file) :type (pathname-type out-file) :directory (list (|currentDirectoryName|))))) - - (multiple-value-bind (result warning-p failure-p) - #-:ecl (compile-file file :output-file out-file) - #+:ecl (multiple-value-prog1 - (compile-file file - :output-file out-file - :system-p t) - (c::build-fasl - (compile-file-pathname out-file) - :lisp-files `(,out-file))) - (unless result - (|coreError| "compilation of Lisp code failed")) - (cond ((and failure-p) - ;; Since we believe the source code must - ;; be fixed, we don't want to leave - ;; the generated FASL behing us, as that - ;; would confuse both user and tools. - (delete-file result) - (|coreError| "Lisp code contained errors")) - - (warning-p - (|warn| "Lisp code contained warnings"))) - result)) + (unwind-protect + (progn + (begin-compile-time) + (multiple-value-bind (result warning-p failure-p) + #-:ecl (compile-file file :output-file out-file) + #+:ecl (compile-file file :output-file out-file :system-p t) + #+:ecl (if (and result (not failure-p) + (null (c::build-fasl (compile-file-pathname out-file) + :lisp-files `(,out-file) + :ld-flags (extra-runtime-libs)))) + (setq result nil)) + (cond ((null result) + (|coreError| "compilation of Lisp code failed")) + (failure-p + ;; Since we believe the source code must + ;; be fixed, we don't want to leave + ;; the generated FASL behing us, as that + ;; would confuse both users and tools. + (delete-file result) + (|coreError| "Lisp code contained errors")) + (warning-p + (|warn| "Lisp code contained warnings"))) + result)) + (end-compile-time))) (defun |compileLispHandler| (prog-name options in-file) (declare (ignore prog-name)) @@ -813,7 +866,8 @@ `(progn (eval-when #+:common-lisp (:compile-toplevel :load-toplevel :execute) #-:common-lisp (compile load eval) - (|importModule| ,module)))) + (if (compile-time-p) + (|importModule| ,module))))) (defmacro boot-import (module) `(eval-when (:compile-toplevel) @@ -826,6 +880,15 @@ (defun |%hasFeature| (f) (member f *features* :test #'eq)) +(defun begin-compile-time nil + (push :open-axiom-compile-time *features*)) + +(defun end-compile-time nil + (pop *features*)) + +(defun compile-time-p nil + (member :open-axiom-compile-time *features*)) + ;; -*- Lisp Implementatiom-dependent Supports -*- #+ :sbcl -- cgit v1.2.3