diff options
author | dos-reis <gdr@axiomatics.org> | 2008-08-07 22:27:42 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2008-08-07 22:27:42 +0000 |
commit | 0b7e16bb78d7715409c44bf6b41f9fb234b8f987 (patch) | |
tree | 5213ebcd45ff338825d2d41bb3cea47e44d0e3bb /src | |
parent | b026c698fddcfeba5d125e09583555f6fbffd5e9 (diff) | |
download | open-axiom-0b7e16bb78d7715409c44bf6b41f9fb234b8f987.tar.gz |
* 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.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 25 | ||||
-rw-r--r-- | src/boot/initial-env.lisp | 4 | ||||
-rw-r--r-- | src/boot/translator.boot | 25 | ||||
-rw-r--r-- | src/interp/Makefile.in | 2 | ||||
-rw-r--r-- | src/interp/Makefile.pamphlet | 2 | ||||
-rw-r--r-- | src/interp/boot-pkg.lisp | 3 | ||||
-rw-r--r-- | src/interp/sys-os.boot | 4 | ||||
-rw-r--r-- | src/lib/Makefile.in | 14 | ||||
-rw-r--r-- | src/lisp/Makefile.in | 4 | ||||
-rw-r--r-- | src/lisp/core.lisp.in | 129 |
10 files changed, 145 insertions, 67 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 463f784e..e28e5c9a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,30 @@ 2008-08-07 Gabriel Dos Reis <gdr@cs.tamu.edu> + * 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. + +2008-08-07 Gabriel Dos Reis <gdr@cs.tamu.edu> + * boot/translator.boot (genOptimizeOptions): New. (shoeClLines): Use it. (shorClCLines): Likewise. diff --git a/src/boot/initial-env.lisp b/src/boot/initial-env.lisp index 96785ab6..7c98e734 100644 --- a/src/boot/initial-env.lisp +++ b/src/boot/initial-env.lisp @@ -46,9 +46,7 @@ (:use "AxiomCore") #+:common-lisp (:use "COMMON-LISP") #-:common-lisp (:use "LISP") - (:export "systemRootDirectory" - "systemLibraryDirectory" - "loadNativeModule" + (:export "loadNativeModule" "loadSystemRuntimeCore" "$InteractiveMode" "string2BootTree")) diff --git a/src/boot/translator.boot b/src/boot/translator.boot index 86aada78..8bb98271 100644 --- a/src/boot/translator.boot +++ b/src/boot/translator.boot @@ -837,7 +837,7 @@ defaultBootToLispFile file == getIntermediateLispFile(file,options) == out := NAMESTRING getOutputPathname(options) out ^= nil => - strconc(shoeRemoveStringIfNec($effectiveFaslType,out),'".clisp") + strconc(shoeRemoveStringIfNec($effectiveFaslType,out),'"clisp") defaultBootToLispFile file translateBootFile(progname, options, file) == @@ -859,26 +859,6 @@ associateRequestWithFileType(Option '"translate", '"boot", associateRequestWithFileType(Option '"compile", '"boot", function compileBootHandler) ---% System wide properties - -++ Returns the root directory of the running system. -++ A directory specified on command line takes precedence -++ over directory specified at configuration time. -systemRootDirectory() == - dir := ASSOC(Option '"system", %systemOptions()) => - ensureTrailingSlash rest 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. - -systemLibraryDirectory() == - dir := ASSOC(Option "syslib",%systemOptions()) => - ensureTrailingSlash rest dir - strconc(systemRootDirectory(),'"lib/") - - --% Runtime support ++ Load native dynamically linked module @@ -887,8 +867,11 @@ loadNativeModule m == FUNCALL(bfColonColon("SB-ALIEN","LOAD-SHARED-OBJECT"),m) %hasFeature KEYWORD::CLISP => EVAL [bfColonColon("FFI","DEFAULT-FOREIGN-LIBRARY"), m] + %hasFeature KEYWORD::ECL => + EVAL [bfColonColon("FFI","LOAD-FOREIGN-LIBRARY"), m] coreError '"don't know how to load a dynamically linked module" loadSystemRuntimeCore() == + %hasFeature KEYWORD::ECL or %hasFeature KEYWORD::GCL => nil loadNativeModule strconc(systemLibraryDirectory(), '"libopen-axiom-core",$NativeModuleExt) diff --git a/src/interp/Makefile.in b/src/interp/Makefile.in index 3506cefa..ba30803f 100644 --- a/src/interp/Makefile.in +++ b/src/interp/Makefile.in @@ -180,7 +180,7 @@ all-axiomsys: all-interpsys $(MAKE) $(AXIOMSYS) mostlyclean-local: - @rm -f *.fn *.data *.$(FASLEXT) *.lib + @rm -f *.fn *.data *.$(FASLEXT) *.lib *.$(OBJEXT) clean-local: mostlyclean-local @rm -f *.clisp *.lsp diff --git a/src/interp/Makefile.pamphlet b/src/interp/Makefile.pamphlet index 7771cc63..f7aa8afe 100644 --- a/src/interp/Makefile.pamphlet +++ b/src/interp/Makefile.pamphlet @@ -540,7 +540,7 @@ all-axiomsys: all-interpsys $(MAKE) $(AXIOMSYS) mostlyclean-local: - @rm -f *.fn *.data *.$(FASLEXT) *.lib + @rm -f *.fn *.data *.$(FASLEXT) *.lib *.$(OBJEXT) clean-local: mostlyclean-local @rm -f *.clisp *.lsp diff --git a/src/interp/boot-pkg.lisp b/src/interp/boot-pkg.lisp index 134f0f73..0cf0aa1b 100644 --- a/src/interp/boot-pkg.lisp +++ b/src/interp/boot-pkg.lisp @@ -52,6 +52,9 @@ #-:common-lisp (compile load eval) (defun define-function (f v) (setf (symbol-function f) v))) + +;; The Boot system is certainly completed by now. +(pushnew :open-axiom-boot-complete *features*) ;; Below are some missing functions. There here for lack of better diff --git a/src/interp/sys-os.boot b/src/interp/sys-os.boot index 34836d16..ab729a5c 100644 --- a/src/interp/sys-os.boot +++ b/src/interp/sys-os.boot @@ -38,14 +38,12 @@ -- supporting C runtime libopen-axiom-core. -- -module sys_-os import types import cfuns namespace BOOT +module sys_-os -)if not %hasFeature KEYWORD::GCL loadSystemRuntimeCore() -)endif ++ change current working directory. import changeDirectory for diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in index 3899031e..3dde3af7 100644 --- a/src/lib/Makefile.in +++ b/src/lib/Makefile.in @@ -58,6 +58,11 @@ libopen_axiom_core_objects = $(libopen_axiom_core_SOURCES:.c=.lo) endif libspad_objects = $(libspad_SOURCES:.c=.lo) +oa_installed_corelib = $(axiom_target_libdir)/libopen-axiom-core.$(LIBEXT) +ifeq (@oa_use_dynamic_lib@,yes) +oa_installed_corelib += $(axiom_target_libdir)/libopen-axiom-core$(SHREXT) +endif + subdir = src/lib/ .PHONY: all all-lib @@ -67,14 +72,15 @@ subdir = src/lib/ all: all-ax all-ax all-lib: stamp -stamp: $(axiom_target_libdir)/libopen-axiom-core$(SHREXT) \ - libopen-axiom-core.$(LIBEXT) libspad.$(LIBEXT) +stamp: $(oa_installed_corelib) libspad.$(LIBEXT) rm -f stamp $(STAMP) stamp -$(axiom_target_libdir)/libopen-axiom-core$(SHREXT): \ - $(libopen_axiom_core_objects) +$(axiom_target_libdir)/libopen-axiom-core.%: libopen-axiom-core.% $(mkdir_p) $(axiom_target_libdir) + cp -p $< $@ + +libopen-axiom-core$(SHREXT): $(libopen_axiom_core_objects) $(LINK_SHRLIB) $(oa_shrlib_flags) -o $@ \ $(libopen_axiom_core_objects) \ @axiom_c_runtime_extra@ -lm 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 |