$spadroot and (|getEnv| "FRICAS"), again

10 views
Skip to first unread message

Qian Yun

unread,
Oct 14, 2022, 8:19:10 AM10/14/22
to fricas-devel
(This is a follow up discussion of https://github.com/fricas/fricas/pull/96)

I'd like to discuss this again, to avoid problem like
https://github.com/fricas/fricas/issues/110,
aka to load "libspad.so" when "FRICAS" is not set.

First, the binary (instead of shell script) FRICASsys should
work when "FRICAS" is not set.

Second, during a fricas session, we can safely assume that
the environment variable "FRICAS" does not change.

Third, if so, the we can use "FRICAS" from C side and use
"$spadroot" in Lisp side and still be consistent.

Finally, if we are considering the use case of using FRICASsys
alone, aka using the Lisp image without the C part, then it
is clear that we should (|getEnv| "FRICAS") once, if it does not
exist, use some other default value, and store it into an
variable ($spadroot) and use that variable later.

- Qian

Qian Yun

unread,
Oct 21, 2022, 10:16:03 PM10/21/22
to fricas-devel
The subset of pr#96 to solve issue#110 is this:

diff --git a/src/interp/util.lisp b/src/interp/util.lisp
index 63cd20f3..2a6219cd 100644
--- a/src/interp/util.lisp
+++ b/src/interp/util.lisp
@@ -77,7 +77,7 @@ at load time.
;;; It is set up in the {\bf reroot} function.
(defvar $library-directory-list ())

-;;; Prefix a filename with the {\bf FRICAS} shell variable.
+;;; Prefix a filename with the {\bf $spadroot} variable.
(defun make-absolute-filename (name)
(concatenate 'string $spadroot name))

@@ -88,13 +88,10 @@ the system. In particular, these variables are
sensitive to the
be {\bf \$spadroot}. The {\bf reroot} function will change the
system to use a new root directory and will have the same effect
as changing the {\bf FRICAS} shell variable and rerunning the system
-from scratch. A correct call looks like:
-\begin{verbatim}
-(in-package "BOOT")
-(reroot "${FRICAS}")
-\end{verbatim}
-where the [[${FRICAS}]] variable points to installed tree.
+from scratch.
|#
+(defvar $spadroot "")
+
(defun reroot (dir)
(setq $spadroot dir)
(setq $directory-list
@@ -267,10 +264,9 @@ After this function is called the image is clean
and can be saved.
#+:GCL (system:gbc-time 0)
#+(or :sbcl :clisp :openmcl :lispworks)
(if *fricas-load-libspad*
- (let* ((ax-dir (|getEnv| "FRICAS"))
- (spad-lib (concatenate 'string ax-dir "/lib/libspad.so")))
+ (let ((spad-lib (make-absolute-filename "/lib/libspad.so")))
(format t "Checking for foreign routines~%")
- (format t "FRICAS=~S~%" ax-dir)
+ (format t "FRICAS=~S~%" $spadroot)
(format t "spad-lib=~S~%" spad-lib)
(if (|fricas_probe_file| spad-lib)
(progn
@@ -280,7 +276,7 @@ After this function is called the image is clean and
can be saved.
(|quiet_load_alien| spad-lib)
#+(or :sbcl :openmcl)
(fricas-lisp::init-gmp
- (concatenate 'string ax-dir "/lib/gmp_wrap.so"))
+ (make-absolute-filename "/lib/gmp_wrap.so"))
#+(and :clisp :ffi)
(progn
(eval `(FFI:DEFAULT-FOREIGN-LIBRARY ,spad-lib))

Qian Yun

unread,
Nov 6, 2022, 10:37:41 PM11/6/22
to fricas-devel
Hi, I'd like a review for this patch.

After this patch, I can move on to "load GMP on Windows".

- Qian

Grégory Vanuxem

unread,
Nov 10, 2022, 9:45:26 PM11/10/22
to fricas...@googlegroups.com
Hello,

Can  you  give a diff

Please
__
Hreg

--
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 fricas-devel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/a7abd54b-cc5e-c97c-2045-9dea36cf8d29%40gmail.com.

Grégory Vanuxem

unread,
Nov 10, 2022, 9:50:20 PM11/10/22
to fricas...@googlegroups.com
Greg.  Sorry 
Reply all
Reply to author
Forward
0 new messages