As you can see in this patch, building CMUCL was different because:
1. It has to load "libspad.so" before it can define FFI functions.
2. After "libspad.so" is loaded, we can't unload it, and saved image
will automatically load it during startup before anything else.
The problem it caused: loadpath of libspad.so is hardcoded inside
binary, so FRICASsys can only run at build directory and designated
install directory. Moving its install location will cause failure to
boot.
For the first issue, CLISP had similar problem. So the similar solution
"cmu-init-foreign-calls" delays FFI functions definition to be after
the loading libspad.so.
For the second issue, we prevent loading of libspad.so in
"build-interpsys", aka we prevent loading of libspad.so in the
creation of "interpsys" and "FRICASsys".
As a result, the build process of CMUCL is more like other Lisps.
- Qian
diff --git a/src/interp/Makefile.in b/src/interp/Makefile.in
index 42798fdb..bdee0c4b 100644
--- a/src/interp/Makefile.in
+++ b/src/interp/Makefile.in
@@ -151,8 +151,6 @@ all-fricassys: ${FRICASSYS}
${FRICASSYS}: ../etc/stamp-databases
echo '(defparameter FRICAS-LISP::*building-fricassys* t)' \
'(load "makeint.lisp") #-:ecl(BOOT::reclaim)' \
- '#+:cmu (setf (ext:search-list "libspad:")' \
- '(list "${FRICAS}/lib/"
"${libdir}/fricas/target/${target}/lib/"))' \
'#+:cmu (setq ext:*top-level-auto-declare* t)' \
'#+:cmu (setq *compile-verbose* nil)' \
'#+:cmu (setq *compile-print* nil)' \
diff --git a/src/interp/util.lisp b/src/interp/util.lisp
index 7ff4d642..b7fc2c64 100644
--- a/src/interp/util.lisp
+++ b/src/interp/util.lisp
@@ -168,7 +168,12 @@ After this function is called the image is clean
and can be saved.
#-:ecl
(progn
(mapcar #'load load-files)
- (interpsys-image-init t))
+ ;; for CMUCL, do not load libspad.so before dumping image,
+ ;; the dumped image will load libspad.so instead.
+ #+:cmu (setq *fricas-load-libspad* nil $openServerIfTrue nil)
+ (interpsys-image-init t)
+ #+:cmu (setq *fricas-load-libspad* t $openServerIfTrue t)
+ )
(if (and (boundp 'FRICAS-LISP::*building-fricassys*)
FRICAS-LISP::*building-fricassys*)
(progn
@@ -264,7 +269,7 @@ After this function is called the image is clean and
can be saved.
(initroot)
#+:poplog (setf POPLOG:*READ-PROMPT* "") ;; Turn off Poplog read prompts
#+:GCL (system:gbc-time 0)
- #+(or :sbcl :clisp :openmcl :lispworks)
+ #+(or :sbcl :clisp :openmcl :lispworks :cmu)
(if *fricas-load-libspad*
(let ((spad-lib (make-absolute-filename "/lib/libspad.so")))
(format t "Checking for foreign routines~%")
@@ -274,7 +279,7 @@ After this function is called the image is clean and
can be saved.
(progn
(setf *fricas-load-libspad* nil)
(format t "foreign routines found~%")
- #+(or :sbcl :openmcl :lispworks)
+ #+(or :sbcl :openmcl :lispworks :cmu)
(|quiet_load_alien| spad-lib)
#+(or :sbcl :openmcl)
(fricas-lisp::init-gmp
@@ -283,6 +288,8 @@ After this function is called the image is clean and
can be saved.
(progn
(eval `(FFI:DEFAULT-FOREIGN-LIBRARY ,spad-lib))
(FRICAS-LISP::clisp-init-foreign-calls))
+ #+:cmu
+ (FRICAS-LISP::cmu-init-foreign-calls)
)
(setf $openServerIfTrue nil))))
#+(or :GCL (and :clisp :ffi) :sbcl :cmu :openmcl :ecl :lispworks)
diff --git a/src/lisp/Makefile.in b/src/lisp/Makefile.in
index 0f78d691..af63805f 100644
--- a/src/lisp/Makefile.in
+++ b/src/lisp/Makefile.in
@@ -138,7 +138,7 @@ do_it.ecl: fricas-lisp.lisp fricas-package.lisp
fricas-config.lisp \
'(make-program "${OUT}/lisp$(EXEEXT)" nil)' | $(FRICAS_LISP)
$(STAMP) $@
-do_it.sbcl do_it.clisp do_it.openmcl do_it.lispworks: \
+do_it.sbcl do_it.clisp do_it.openmcl do_it.lispworks do_it.cmucl: \
fricas-lisp.lisp fricas-package.lisp fricas-config.lisp $(NUM_GMP) \
primitives.lisp
echo '(load "fricas-package.lisp")' \
@@ -150,20 +150,6 @@ do_it.sbcl do_it.clisp do_it.openmcl do_it.lispworks: \
| $(LISP_CMD)
$(STAMP) $@
-do_it.cmucl: fricas-lisp.lisp fricas-package.lisp \
- fricas-config.lisp primitives.lisp
- echo '(load "fricas-package.lisp")' \
- '(load "fricas-config.lisp")' \
- '(setf (ext:search-list "libspad:")' \
- '(quote ("${fricas_target_libdir}/")))' \
- '(ext:load-foreign "libspad:libspad.so")' \
- '(load (compile-file "fricas-lisp.lisp"))' \
- '(load (compile-file "primitives.lisp"))' \
- '(defswitch "-")' \
- '(in-package "FRICAS-LISP") (save-core
"${OUT}/lisp$(EXEEXT)")' \
- | $(FRICAS_LISP)
- $(STAMP) $@
-
# Build GCL takes quite a while, so we don't clean the
# directory in mostlyclean. Rather, we do that in clean.
mostlyclean-local:
diff --git a/src/lisp/fricas-lisp.lisp b/src/lisp/fricas-lisp.lisp
index f549035f..f2429095 100644
--- a/src/lisp/fricas-lisp.lisp
+++ b/src/lisp/fricas-lisp.lisp
@@ -379,6 +379,8 @@ with this hack and will try to convince the GCL
crowd to fix this.
(ccl::open-shared-library s)
#+:lispworks
(fli:register-module s)
+ #+:cmu
+ (ext:load-foreign s)
)
;;; -------------------------------------------------------
@@ -648,9 +650,13 @@ with this hack and will try to convince the GCL
crowd to fix this.
;;;
(defmacro foreign-defs (&rest arguments)
- #-:clisp `(progn ,@arguments)
- #+(and :clisp :ffi) `(defun clisp-init-foreign-calls () ,@arguments)
-)
+ #-(or :clisp :cmu) `(progn ,@arguments)
+ #+(and :clisp :ffi)
+ `(defun clisp-init-foreign-calls () ,@arguments)
+ #+:cmu
+ `(defun cmu-init-foreign-calls ()
+ (eval (quote (progn ,@arguments))))
+ )
(foreign-defs
--
You received this message because you are subscribed to the Google Groups "FriCAS -
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/c73f4a4e-3406-4fd4-88bf-1b9d7cc7b1e3%40gmail.com.
diff --git a/src/interp/Makefile.in b/src/interp/Makefile.in
index 42798fdb..bdee0c4b 100644
--- a/src/interp/Makefile.in
+++ b/src/interp/Makefile.in
@@ -151,8 +151,6 @@ all-fricassys: ${FRICASSYS}
${FRICASSYS}: ../etc/stamp-databases
echo '(defparameter FRICAS-LISP::*building-fricassys* t)' \
'(load "makeint.lisp") #-:ecl(BOOT::reclaim)' \
- '#+:cmu (setf (ext:search-list "libspad:")' \
- '(list "${FRICAS}/lib/" "${libdir}/fricas/target/${target}/lib/"))' \
'#+:cmu (setq ext:*top-level-auto-declare* t)' \
'#+:cmu (setq *compile-verbose* nil)' \
'#+:cmu (setq *compile-print* nil)' \
diff --git a/src/interp/util.lisp b/src/interp/util.lisp
index 7ff4d642..b7fc2c64 100644
--- a/src/interp/util.lisp
+++ b/src/interp/util.lisp
@@ -168,7 +168,12 @@ After this function is called the image is clean and can be saved.
#-:ecl
(progn
(mapcar #'load load-files)
- (interpsys-image-init t))
+ ;; for CMUCL, do not load libspad.so before dumping image,
+ ;; the dumped image will load libspad.so instead.
+ #+:cmu (setq *fricas-load-libspad* nil $openServerIfTrue nil)
+ (interpsys-image-init t)
+ #+:cmu (setq *fricas-load-libspad* t $openServerIfTrue t)
+ )
(if (and (boundp 'FRICAS-LISP::*building-fricassys*)
FRICAS-LISP::*building-fricassys*)
(progn
@@ -264,7 +269,7 @@ After this function is called the image is clean and can be saved.
(initroot)
#+:poplog (setf POPLOG:*READ-PROMPT* "") ;; Turn off Poplog read prompts
#+:GCL (system:gbc-time 0)
- #+(or :sbcl :clisp :openmcl :lispworks)
+ #+(or :sbcl :clisp :openmcl :lispworks :cmu)
(if *fricas-load-libspad*
(let ((spad-lib (make-absolute-filename "/lib/libspad.so")))
(format t "Checking for foreign routines~%")
@@ -274,7 +279,7 @@ After this function is called the image is clean and can be saved.
(progn
(setf *fricas-load-libspad* nil)
(format t "foreign routines found~%")
- #+(or :sbcl :openmcl :lispworks)
+ #+(or :sbcl :openmcl :lispworks :cmu)
(|quiet_load_alien| spad-lib)
#+(or :sbcl :openmcl)
(fricas-lisp::init-gmp
@@ -283,6 +288,8 @@ After this function is called the image is clean and can be saved.
(progn
(eval `(FFI:DEFAULT-FOREIGN-LIBRARY ,spad-lib))
(FRICAS-LISP::clisp-init-foreign-calls))
+ #+:cmu
+ (FRICAS-LISP::cmu-init-foreign-calls)
)
(setf $openServerIfTrue nil))))
#+(or :GCL (and :clisp :ffi) :sbcl :cmu :openmcl :ecl :lispworks)
diff --git a/src/lisp/Makefile.in b/src/lisp/Makefile.in
index 0f78d691..af63805f 100644
--- a/src/lisp/Makefile.in
+++ b/src/lisp/Makefile.in
@@ -138,7 +138,7 @@ do_it.ecl: fricas-lisp.lisp fricas-package.lisp fricas-config.lisp \
'(make-program "${OUT}/lisp$(EXEEXT)" nil)' | $(FRICAS_LISP)
$(STAMP) $@
-do_it.sbcl do_it.clisp do_it.openmcl do_it.lispworks: \
+do_it.sbcl do_it.clisp do_it.openmcl do_it.lispworks do_it.cmucl: \
fricas-lisp.lisp fricas-package.lisp fricas-config.lisp $(NUM_GMP) \
primitives.lisp
echo '(load "fricas-package.lisp")' \
@@ -150,20 +150,6 @@ do_it.sbcl do_it.clisp do_it.openmcl do_it.lispworks: \
| $(LISP_CMD)
$(STAMP) $@
-do_it.cmucl: fricas-lisp.lisp fricas-package.lisp \
- fricas-config.lisp primitives.lisp
- echo '(load "fricas-package.lisp")' \
- '(load "fricas-config.lisp")' \
- '(setf (ext:search-list "libspad:")' \
- '(quote ("${fricas_target_libdir}/")))' \
- '(ext:load-foreign "libspad:libspad.so")' \
- '(load (compile-file "fricas-lisp.lisp"))' \
- '(load (compile-file "primitives.lisp"))' \
- '(defswitch "-")' \
- '(in-package "FRICAS-LISP") (save-core "${OUT}/lisp$(EXEEXT)")' \
- | $(FRICAS_LISP)
- $(STAMP) $@
-
# Build GCL takes quite a while, so we don't clean the
# directory in mostlyclean. Rather, we do that in clean.
mostlyclean-local:
diff --git a/src/lisp/fricas-lisp.lisp b/src/lisp/fricas-lisp.lisp
index f549035f..f2429095 100644
--- a/src/lisp/fricas-lisp.lisp
+++ b/src/lisp/fricas-lisp.lisp
@@ -379,6 +379,8 @@ with this hack and will try to convince the GCL crowd to fix this.
(ccl::open-shared-library s)
#+:lispworks
(fli:register-module s)
+ #+:cmu
+ (ext:load-foreign s)
)
;;; -------------------------------------------------------
@@ -648,9 +650,13 @@ with this hack and will try to convince the GCL crowd to fix this.
;;;
(defmacro foreign-defs (&rest arguments)
- #-:clisp `(progn ,@arguments)
- #+(and :clisp :ffi) `(defun clisp-init-foreign-calls () ,@arguments)
-)
+ #-(or :clisp :cmu) `(progn ,@arguments)
+ #+(and :clisp :ffi)
+ `(defun clisp-init-foreign-calls () ,@arguments)
+ #+:cmu
+ `(defun cmu-init-foreign-calls ()
+ (eval (quote (progn ,@arguments))))
+ )
(foreign-defs