The purpose of this patch is to support fricas installation
on homebrew. (Avoid binary signing issue on macos, see [1], [2].)
I've tested this patch on SBCL/CLISP/ClozureCL/CMUCL.
This Lisp core approach does not apply for ECL/GCL.
I've test it on Linux, and SBCL/CLozureCL on Windows.
It's awkward on Windows because it is not standalone
executable, but it works if you manually use Lisp
to load the core file.
After this patch is merged, I'll integrate this patch
into homebrew formula, so that macos users should install
fricas without issues.
- Best,
- Qian
[1]
https://github.com/Homebrew/homebrew-core/pull/205760#issuecomment-2689683141
[2] https://github.com/fricas/fricas/issues/202
--
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 visit
https://groups.google.com/d/msgid/fricas-devel/c2e91e47-37b3-4e94-9cb7-e59624240143%40gmail.com.
diff --git a/Makefile.in b/Makefile.in
index c4409633..566dd035 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -105,7 +105,7 @@ install-src:
done ; \
done
$(mkinstalldirs) '$(DESTDIR)$(libdir)/fricas/$(reltarget)/bin'
- for A in bin/FRICASsys bin/clef bin/htadd bin/hypertex \
+ for A in bin/FRICASsys bin/FRICASsys.core bin/clef bin/htadd bin/hypertex \
bin/sman bin/viewAlone lib/ex2ht lib/hthits lib/session \
lib/spadbuf lib/spadclient lib/view2D lib/view3D \
lib/viewman ; do \
diff --git a/configure b/configure
index b33e7820..f31601b5 100755
--- a/configure
+++ b/configure
@@ -680,6 +680,7 @@ fricas_has_directory_operations
fricas_all_prerequisites
fricas_algebra_optimization
fricas_debug_compiler
+fricas_image_flags
fricas_quiet_flags
fricas_gcl_rsym_hack
GMP_EXT
@@ -694,6 +695,7 @@ fricas_lisp_version
fricas_lisp_flavor
fricas_fasl_type2
fricas_fasl_type
+FRICAS_SAVE_EXEC
FRICAS_LISP
PREGENERATED
AWK_FOR_TARGET
@@ -777,6 +779,7 @@ ac_user_opts='
enable_option_checking
with_pre_generated
with_lisp
+enable_lisp_core
with_lisp_flavor
with_gmp
with_gmp_include
@@ -1425,6 +1428,9 @@ Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --enable-lisp-core build FriCAS as a Lisp core image instead of
+ standalone executable, only support SBCL, CLISP,
+ ClozureCL, CMUCL
--enable-gmp use gmp for bignums with SBCL or Clozure CL
--enable-debug-compiler (for BOOT or SPAD compiler developers) add debug
information to every component of a compiler
@@ -4648,6 +4654,19 @@ else
:
fi
+FRICAS_SAVE_EXEC=t
+# Check whether --enable-lisp-core was given.
+if test ${enable_lisp_core+y}
+then :
+ enableval=$enable_lisp_core; case $enableval in
+ yes) FRICAS_SAVE_EXEC=nil ;;
+ no) FRICAS_SAVE_EXEC=t ;;
+ *) as_fn_error $? "--enable-lisp-core only allows yes or no as an argument" "$LINENO" 5 ;;
+ esac
+fi
+
+
+
# Check whether --with-lisp-flavor was given.
if test ${with_lisp_flavor+y}
@@ -5008,18 +5027,22 @@ case $fricas_lisp_flavor in
fricas_eval_flags='--eval'
sbcl_memory_size=`echo "(princ (sb-ext:dynamic-space-size))" | $fricas_lisp $fricas_quiet_flags`
test $sbcl_memory_size -gt 4294967296 || fricas_quiet_flags="--dynamic-space-size 4096 $fricas_quiet_flags"
+ fricas_image_flags='--core'
;;
cmucl)
fricas_quiet_flags='-batch -nositeinit -noinit'
fricas_eval_flags='-eval'
+ fricas_image_flags='-core'
;;
clisp)
fricas_quiet_flags='--quiet -norc'
fricas_eval_flags='-x'
+ fricas_image_flags='-M'
;;
openmcl)
fricas_quiet_flags='--no-init'
fricas_eval_flags='--eval'
+ fricas_image_flags='-I'
;;
lispworks)
fricas_quiet_flags=
@@ -5029,6 +5052,7 @@ case $fricas_lisp_flavor in
esac
+
fricas_debug_compiler='no'
# Check whether --enable-debug-compiler was given.
diff --git a/configure.ac b/configure.ac
index d7d97c0b..7255fa30 100644
--- a/configure.ac
+++ b/configure.ac
@@ -196,6 +196,17 @@ else
:
fi
+FRICAS_SAVE_EXEC=t
+AC_ARG_ENABLE([lisp-core],
+ [AS_HELP_STRING([--enable-lisp-core],
+ [build FriCAS as a Lisp core image instead of standalone executable, only support SBCL, CLISP, ClozureCL, CMUCL])],
+ [case $enableval in
+ yes) FRICAS_SAVE_EXEC=nil ;;
+ no) FRICAS_SAVE_EXEC=t ;;
+ *) AC_MSG_ERROR([--enable-lisp-core only allows yes or no as an argument]) ;;
+ esac])
+AC_SUBST(FRICAS_SAVE_EXEC)
+
AC_ARG_WITH([lisp-flavor],
[AS_HELP_STRING([--with-lisp-flavor=F],
[obsolete and ignored])],
@@ -452,18 +463,22 @@ case $fricas_lisp_flavor in
fricas_eval_flags='--eval'
sbcl_memory_size=`echo "(princ (sb-ext:dynamic-space-size))" | $fricas_lisp $fricas_quiet_flags`
test $sbcl_memory_size -gt 4294967296 || fricas_quiet_flags="--dynamic-space-size 4096 $fricas_quiet_flags"
+ fricas_image_flags='--core'
;;
cmucl)
fricas_quiet_flags='-batch -nositeinit -noinit'
fricas_eval_flags='-eval'
+ fricas_image_flags='-core'
;;
clisp)
fricas_quiet_flags='--quiet -norc'
fricas_eval_flags='-x'
+ fricas_image_flags='-M'
;;
openmcl)
fricas_quiet_flags='--no-init'
fricas_eval_flags='--eval'
+ fricas_image_flags='-I'
;;
lispworks)
fricas_quiet_flags=
@@ -472,6 +487,7 @@ case $fricas_lisp_flavor in
*) AC_MSG_ERROR([We do not know how to build FriCAS with this Lisp: $fricas_lisp]) ;;
esac
AC_SUBST(fricas_quiet_flags)
+AC_SUBST(fricas_image_flags)
fricas_debug_compiler='no'
diff --git a/src/interp/Makefile.in b/src/interp/Makefile.in
index 0900684a..740047fe 100644
--- a/src/interp/Makefile.in
+++ b/src/interp/Makefile.in
@@ -4,6 +4,9 @@ subdir = src/interp/
DOC=$(fricas_target_docdir)/src/interp
fricas_debug_compiler=@fricas_debug_compiler@
+fricas_quiet_flags = @fricas_quiet_flags@
+fricas_image_flags = @fricas_image_flags@
+FRICAS_SAVE_EXEC = @FRICAS_SAVE_EXEC@
LISP_ID_STRING=$(FRICAS_LISP_FLAVOR) $(FRICAS_LISP_VERSION)
@@ -141,7 +144,7 @@ ${SAVESYS}:
'(load "makeint.lisp") #-:ecl(BOOT::reclaim)' \
'#+:ecl(FRICAS-LISP::make-program "$(BASE)$@" nil)' \
'#+:gcl(progn (setq si::*code-block-reserve* "")(si::gbc t)(setq si::*code-block-reserve* (make-array 10000000 :element-type (quote character) :static t) si::*optimize-maximum-pages* t))' \
- '#-:ecl(BOOT::spad-save "$(BASE)$@" t)' | \
+ '#-:ecl(BOOT::spad-save "$(BASE)$@" t t)' | \
DAASE='$(fricas_src_datadir)' ${BOOTSYS}
ls $@
@ echo 6 ${SAVESYS} created
@@ -162,8 +165,12 @@ ${FRICASSYS}: ../etc/stamp-databases
'#+:cmu (setq *compile-print* nil)' \
'#+:cmu (declaim (optimize (ext:inhibit-warnings 3)))' \
'#+:ecl(FRICAS-LISP::make-program "$(BASE)$@" nil)' \
- '#-:ecl(BOOT::spad-save "$(BASE)$@" t)' \
+ '#-:ecl(BOOT::spad-save "$(BASE)$@" t $(FRICAS_SAVE_EXEC))' \
| DAASE="$(BASE)$(fricas_targetdir)" ${BOOTSYS}
+ if test x"$(FRICAS_SAVE_EXEC)" = xnil ; then \
+ echo -e '#! /bin/sh\n$(FRICAS_LISP) $(fricas_image_flags) $${FRICAS}/bin/FRICASsys.core $(fricas_quiet_flags) "$$@"' > $(BASE)$@ ; \
+ chmod a+x $(BASE)$@ ; \
+ fi
@ echo 6a ${FRICASSYS} created
exposed.lsp: $(fricas_src_algdir)/exposed.lsp
diff --git a/src/interp/util.lisp b/src/interp/util.lisp
index e722b256..d37acfda 100644
--- a/src/interp/util.lisp
+++ b/src/interp/util.lisp
@@ -228,11 +228,14 @@ After this function is called the image is clean and can be saved.
)
-(defun spad-save (save-file do-restart)
+(defun spad-save (save-file do-restart save-exec)
+ ;; if the parameter "save-exec" is t, FriCAS will be saved as a standalone
+ ;; executable; if nil, FriCAS will be saved as a Lisp core file.
(setq |$SpadServer| nil)
(setq $openServerIfTrue t)
- (FRICAS-LISP::save-core-restart save-file
- (if do-restart #'boot::|fricas_restart| nil))
+ (FRICAS-LISP::save-core-restart
+ (if save-exec save-file (strconc save-file ".core"))
+ (if do-restart #'boot::|fricas_restart| nil) save-exec)
)
(defun |mkAutoLoad| (cname)
diff --git a/src/lisp/fricas-lisp.lisp b/src/lisp/fricas-lisp.lisp
index b616bf8b..d7cd2167 100644
--- a/src/lisp/fricas-lisp.lisp
+++ b/src/lisp/fricas-lisp.lisp
@@ -80,7 +80,7 @@ with this hack and will try to convince the GCL crowd to fix this.
)
;; Save current image on disk as executable and quit.
-(defun save-core-restart (core-image restart)
+(defun save-core-restart (core-image restart save-exec)
#+:GCL
(progn
(if restart
@@ -101,7 +101,7 @@ with this hack and will try to convince the GCL crowd to fix this.
(lisp::%top-level))))
(ext::save-lisp
(unix::unix-maybe-prepend-current-directory core-image)
- :init-function top-fun :executable t :print-herald nil))
+ :init-function top-fun :executable save-exec :print-herald nil))
#+:sbcl
(let* ((restart-fun
(if restart
@@ -121,14 +121,14 @@ with this hack and will try to convince the GCL crowd to fix this.
)
(uninstall-gmp-multiplication)
(apply #'sb-ext::save-lisp-and-die
- (append `(,core-image :toplevel ,top-fun :executable t)
+ (append `(,core-image :toplevel ,top-fun :executable ,save-exec)
save-options-arg))
)
#+:clisp
(if restart
- (ext::saveinitmem core-image :INIT-FUNCTION restart :QUIET t
- :NORC t :executable t)
- (ext::saveinitmem core-image :executable t :NORC t :QUIET t))
+ (ext::saveinitmem core-image :executable save-exec :NORC t :QUIET t
+ :INIT-FUNCTION restart)
+ (ext::saveinitmem core-image :executable save-exec :NORC t :QUIET t))
#+:openmcl
(let* ((ccl-dir (or *ccl-default-directory*
(|getEnv| "CCL_DEFAULT_DIRECTORY")))
@@ -142,7 +142,7 @@ with this hack and will try to convince the GCL crowd to fix this.
(ccl::toplevel-loop))))
(setf *ccl-default-directory* ccl-dir)
(CCL::save-application core-image :toplevel-function top-fun
- :PREPEND-KERNEL t)
+ :PREPEND-KERNEL save-exec)
(QUIT))
#+:lispworks
(progn
@@ -160,7 +160,7 @@ with this hack and will try to convince the GCL crowd to fix this.
)
(defun save-core (core-image)
- (save-core-restart core-image nil))
+ (save-core-restart core-image nil t))
;; Load Lisp files (any LOADable file), given as a list of file names.
;; The file names are strings, as appropriate for LOAD.