[PATCH] fix build with CLISP (no ffi)

4 views
Skip to first unread message

Qian Yun

unread,
Nov 18, 2023, 9:05:15 PM11/18/23
to fricas-devel
Currently, the only FFI function used during build (without-x11)
is |remove_directory| in |erase_lib|, and there has a Lisp fallback.

So the autotools variable "fricas_has_directory_operations"
means we have those C functions, while Lisp symbol
:fricas_has_remove_directory means we can use them.
This is not true for CLISP built without FFI.

Following patch fixes that.

An additional advantage: it is now easier to port FriCAS to
another Lisp. We can add the missing #+ Lisp functions first,
and add the FFI functions later.

- Qian

diff --git a/src/lisp/Makefile.in b/src/lisp/Makefile.in
index af63805f..014dcc51 100644
--- a/src/lisp/Makefile.in
+++ b/src/lisp/Makefile.in
@@ -102,8 +102,8 @@ fricas-config.lisp:
echo '(defparameter algebra-optimization' \
'(quote $(fricas_algebra_optimization)))' >> $@
if [ x$(fricas_has_directory_operations) = xyes ] ; then \
- echo '(if (not (member :fricas_has_remove_directory' \
- ' *features*)) ' \
+ echo '#-(and :clisp (not :ffi))' \
+ '(if (not (member :fricas_has_remove_directory
*features*)) ' \
'(push :fricas_has_remove_directory *features*))' \
>> $@ ; \
fi

Waldek Hebisch

unread,
Nov 19, 2023, 5:27:10 AM11/19/23
to fricas...@googlegroups.com
On Sun, Nov 19, 2023 at 10:05:10AM +0800, Qian Yun wrote:
> Currently, the only FFI function used during build (without-x11)
> is |remove_directory| in |erase_lib|, and there has a Lisp fallback.
>
> So the autotools variable "fricas_has_directory_operations"
> means we have those C functions, while Lisp symbol
> :fricas_has_remove_directory means we can use them.
> This is not true for CLISP built without FFI.

Why would anyone use CLISP built without FFI? I consider any
Lisp without well-working FFI as deficient and I intend to
use FFI in FriCAS algebra.

--
Waldek Hebisch

Qian Yun

unread,
Nov 19, 2023, 5:35:18 AM11/19/23
to fricas...@googlegroups.com
In your commit 055f3a40 (or svn r490), 2009-01-18, said
"Allow build even if Clisp lacks FFI.". Old mail says it
was needed for sage interface (back when they were using
CLISP instead of ECL, it seems).

Poplog doesn't support FFI, I've not tried it so I don't
know if it will build.

I plan to add CLASP support soon, it has a very basic FFI,
(no driect support for c-string, only pointers.) which is
intended to be used together with CFFI.

- Qian

Waldek Hebisch

unread,
Nov 19, 2023, 6:11:51 AM11/19/23
to fricas...@googlegroups.com
On Sun, Nov 19, 2023 at 06:35:14PM +0800, Qian Yun wrote:
> In your commit 055f3a40 (or svn r490), 2009-01-18, said
> "Allow build even if Clisp lacks FFI.". Old mail says it
> was needed for sage interface (back when they were using
> CLISP instead of ECL, it seems).

Yes, but for many years sage has Lisp with FFI.

> Poplog doesn't support FFI, I've not tried it so I don't
> know if it will build.

Poplog supports FFI. Poplog Clisp does not support FFI,
but we can get what is needed by digging a bit deeper.
Currently main issue with Poplog is that Poplog compiles
on load and does not support .fasl files, which means
our normal Makefiles do not work (I used pre-build Lisp
files with Poplog). Comparably FFI is easy to resolve.

> I plan to add CLASP support soon, it has a very basic FFI,
> (no driect support for c-string, only pointers.) which is
> intended to be used together with CFFI.

Then you will need copy loop that you replaced by implementation
provided functions for other Lisps.

--
Waldek Hebisch

Qian Yun

unread,
Nov 19, 2023, 6:27:00 AM11/19/23
to fricas...@googlegroups.com


On 11/19/23 18:27, Waldek Hebisch wrote:
Currently FFI is only used by hyperdoc/drawing, and remove_directory.
It is not used (directly) by algebra. Except for GMP, which is only
available for sbcl and clozurecl.

For one thing, a pure lisp build of FriCAS can be interesting --
it might get distributed by quicklisp, for example. (A very very
long way to go there.)

On the other hand, current hand-written FFI doesn't scale well --
if we want to "support for using external mathematical routines
from Spad", then CFFI and C2FFI is the way to go.

I had a FLINT binding working some time ago. (via C2FFI).

- Qian
Reply all
Reply to author
Forward
0 new messages