Termux-packages: Package request: Common Lisp programming language compiler

Created on 27 Mar 2016  Â·  59Comments  Â·  Source: termux/termux-packages

Thanks for the amazing terminal app for Android. I purchased the styling add-on today, and it looks great.

I'd like to request a Lisp compiler package:

SBCL is more preferred among Lisp community, but either one would be great.

help wanted package request

Most helpful comment

actually ecl works
im working on packaging it now

All 59 comments

Having SBCL as a Termux package would be great! Will look at adding it in the future - and if anyone else is interested in looking at it in the meantime it would also be great :).

Hi, I am reopening this issue. Package requests will now be labeled and tracked as an issue.

I have a suggestion for an alternate common lisp implementation: ECL, or embeddable Common Lisp, which can be found at https://common-lisp.net/project/ecl/. I think ECL may be a good candidate because it has mainline android support and is a fully standards compliant common lisp implementation while also being very lightweight as well. I would try building it myself but I don't have access to a suitable build environment right now.

Here's an easy howto I've wrote to have binary SBCL work on Termux: https://gist.github.com/vit1-irk/f45bec7f882d319d01c66ce6d54dfc9f

Also I have a failing attempt to build it from sources: https://gist.github.com/vit1-irk/9cec4df75d3f4de65b89a9aaf3b02df1

I managed to compile ECL inside termux on a Nexus 7 (2013 Wifi).

apt install libgmp libgmp-dev clang make git libffi libffi-dev
git clone https://gitlab.com/embeddable-common-lisp/ecl.git
cd ecl
# comment out link_map and r_debug definition around line 123 in dyn_load.c 
vi /data/data/com.termux/files/home/ecl/src/bdwgc/dyn_load.c
./configure  --host=arm-linux-androideabi --with-system-gmp --enable-boehm=included  --with-cxx --with-dffi --enable-shared=no --disable-soname --prefix=/data/data/com.termux/files/usr/local --with-cross-config=`pwd`/src/util/android.cross_config
make install

Using the libgc that comes with termux failed. So did compiling with --enable-shared.

-bash-4.3# ecl 
;;; Loading "/data/data/com.termux/files/home/quicklisp/setup.lisp"
;;; Loading #P"/data/data/com.termux/files/usr/local/lib/ecl-16.1.2/asdf.fasc"
ECL (Embeddable Common-Lisp) 16.1.2 (git:326829fd58b733f6f42e81f2e53a7b8c5860c7c5)
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
Copyright (C) 1993 Giuseppe Attardi
Copyright (C) 2000 Juan J. Garcia-Ripoll
Copyright (C) 2015 Daniel Kochmanski
ECL is free software, and you are welcome to redistribute it
under certain conditions; see file 'Copyright' for details.
Type :h for Help.  
Top level in: #<process TOP-LEVEL>.
> (ql:quickload :swank)
To load "swank":
  Install 1 Quicklisp release:
    slime

You can download a tar file (5.5MB) with the binary here: https://github.com/plops/ecl-termux-binary

I looked a bit into building clisp (needed by xindy, see #966) and it seems to have problems with clang, or at least require an assembly patch. There's an helpful patch located here but it doesn't takes us all the way, make fails due to invalid instructions in an assembly file.

My work so far is located at https://github.com/Grimler91/termux-packages/tree/xindy for anyone interested.

Is anyone working on this for now ?

I tried build it follow this instruction:

https://github.com/termux/termux-packages#setting-up-a-build-environment-using-docker

But it's not working yet, there are errors throw out when compiling and I am trying to solve them.

I am not good at Cross Compiling or C or C++ or Common Lisp or anything related to this, so if anyone is working on this, would you like to share some progress ? I appreciate that very much.

@VitoVan Are you interested in sbcl or clisp?

If you share the compiling errors we could probably (try) to help solve them.

I haven't looked at clisp for quite some time, I was stuck at trying to solve some C_CODE_ALIGNMENT error. Compiling on device also went further than cross compiling, though cross compiling can probably be fixed with the right flags.

Hi @Grimler91 , it's great to have your reply, and Yes, I am interested in sbcl.

I tried copy disabled-packages/sbcl to packages/sbcl and then run ./build-package.sh sbcl and then it failed.

I have totally messed up the whole environment when I'm trying to solve the problems it thrown out, and I will go back and try it again and shared the compiling errors from the beginning.


Before doing that, I have a question for the first sight of sbcl/build.sh here:

TERMUX_PKG_VERSION=1.3.9

And the most recent version of SBCL is 1.4.0, should we change the version number first ?

It looks like ECL is currently available in Termux through Arch Linux PRoot. This script is designed to install Arch Linux in just a few keystrokes. Tapping this link https://sdrausty.github.io/TermuxArch/setupTermuxArch.sh will transfer setupTermuxArch.sh to your device. Simply run bash ~/storage/downloads/setupTermuxArch.sh to install Arch Linux in Termux. To install use pacman -S ecl and this will install ECL on device.

screenshot_20171130-040102

SBCL should work with proot as well as ECL, but it feels inelegant.

If we are going to use proot, then the Emacs / Vi packages from termux is not necessary any more.

Use what works

If we are using "proot" and similar, then why use Termux? Why not use Debian on Android, etc.? - The whole point of Termux is that it is not-quite-so-heavy as a full Linux - and full Linux on Android IS available - and from the three possible Common Lisps, NONE work: neither Clisp, nor ECL, nor SBCL. Don't cheat yourself with "Arch root" etc: the Lisp area here still needs fixing!

actually ecl works
im working on packaging it now

https://github.com/its-pointless/its-pointless.github.io/tree/master/files/dists/termux/extras/binary-i686
here for i686 you can work out where your arch is from here ... but its there

Right so basically at this point i can cross compile ecl for the 4 archs we support. It requires a 32 bit ecl to cross compile for 32 bit termux_archs. Libgc current version in 32bit doesn't play well with docker. So you have to use a recent commit. Also needs the headers and stuff from libatomic_ops which is needed for libgc etc ...
Basically same issue i had with guile...

For the fun of it, I just did a pkg install ecl aaaand... it popped up! As I assume this must be your doing, I just dropped by to say: THANK YOU!

ECL works for me, but not with Slime:

(progn (load "/data/data/com.termux/files/home/.emacs.d/elpa/slime-20171207.1712/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "/data/data/com.termux/files/usr/tmp/slime.7278"))

 ECL (Embeddable Common-Lisp) 16.1.3 (git:UNKNOWN)
 Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
 Copyright (C) 1993 Giuseppe Attardi
 Copyright (C) 2000 Juan J. Garcia-Ripoll
 Copyright (C) 2016 Daniel Kochmanski
 ECL is free software, and you are welcome to redistribute it
 under certain conditions; see file 'Copyright' for details.
Type :h for Help.
Top level in: #<process TOP-LEVEL>.
>
;;; Loading "/data/data/com.termux/files/home/.emacs.d/elpa/slime-20171207.1712/swank-loader.lisp"
;;; Loading #P"/data/data/com.termux/files/usr/lib/ecl-16.1.3/cmp.fas"
pthread_kill failed at suspend

Process inferior-lisp aborted (core dumped)

This is with the following in my .emacs:

(setq inferior-lisp-program "/data/data/com.termux/files/usr/bin/ecl")
(setq slime-contribs '(slime-fancy))

Please let me know if this isn't the right forum for this (and where would be) and I'll repost there. Thanks!

The error pthread_kill failed at suspend is a libgc error that iv mostly worked out. On arm recompiling libgc with -Os instead of -Oz and on i686 i needed to remove a termux patch. As of right now i think that error is no long happening on the versions uploaded as i have replaced them with working versions.
I686 is not using threads...

@its-pointless just tried to upgrade ecl from your repo and to install quicklisp

this libgc problem is still present

> (quicklisp-quickstart:install)

; Fetching #<url "http://beta.quicklisp.org/client/quicklisp.sexp">
; 0.82KB
==================================================
838 bytes in 0.01 seconds (102.29KB/sec)
; Fetching #<url "http://beta.quicklisp.org/client/2017-03-06/quicklisp.tar">
; 250.00KB
==================================================
256,000 bytes in 0.19 seconds (1302.08KB/sec)pthread_kill failed at suspend
Aborted
$

I will have to use a static lib libgc until libgc is updated. I will update here when i get around to it sometime today. I thought fornwall had updated libgc after change of cflags for arm but i was mistaken.

try now i uploaded arm version without threads. which should work. When libgc is updated i will enable threads.
Libgc statically linked doesn't work ....

@its-pointless The package currently hosted at https://github.com/its-pointless/its-pointless.github.io/blob/master/files/dists/termux/extras/binary-arm/ecl_16.1.3_arm.deb does not seem to have threads disabled.

┌─[u0_a89][localhost][~]
└─▪ ecl -load ../tmp/quicklisp.lisp
;;; Loading "/data/data/com.termux/files/home/../tmp/quicklisp.lisp"
;;; Loading #P"/data/data/com.termux/files/usr/lib/ecl-16.1.3/sockets.fas"

  ==== quicklisp quickstart 2015-01-28 loaded ====

    To continue with installation, evaluate: (quicklisp-quickstart:install)

    For installation options, evaluate: (quicklisp-quickstart:help)

ECL (Embeddable Common-Lisp) 16.1.3 (git:UNKNOWN)
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
Copyright (C) 1993 Giuseppe Attardi
Copyright (C) 2000 Juan J. Garcia-Ripoll
Copyright (C) 2016 Daniel Kochmanski
ECL is free software, and you are welcome to redistribute it
under certain conditions; see file 'Copyright' for details.
Type :h for Help.  
Top level in: #<process TOP-LEVEL>.
> (quicklisp-quickstart:install)

; Fetching #<url "http://beta.quicklisp.org/client/quicklisp.sexp">
; 0.82KB
==================================================
838 bytes in 0.01 seconds (68.20KB/sec)
; Fetching #<url "http://beta.quicklisp.org/client/2017-03-06/quicklisp.tar">
; 250.00KB
==================================================
256,000 bytes in 0.01 seconds (16666.67KB/sec)
; Fetching #<url "http://beta.quicklisp.org/client/2015-09-24/setup.lisp">
; 4.94KB
==================================================
5,054 bytes in 0.01 seconds (705.08KB/sec)
; Fetching #<url "http://beta.quicklisp.org/asdf/2.26/asdf.lisp">
; 194.07KB
==================================================
198,729 bytes in 0.01 seconds (13862.24KB/sec)pthread_kill failed at suspend
Aborted

have you upgraded your libgc version on device? It should work if you do if not i will fix this in a second.

@its-pointless

┌─[u0_a89][localhost][~]
└─▪ apt install libgc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libgc is already the newest version (7.6.2).
libgc set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Damn it.
K i will fix

Ok try again now...

Worked this time. I managed to install Quicklisp. Thanks!

(Though thread support will nonetheless be most appreciated, if you manage to get it.)

Okay iv worked out what is going on. Its actually recommeded to remove tkill from libgc since ndk 11 or more accurately api 23 or android 6. So i can actually now embed libgc into ecl so it works in threads. The issue is i don't know if this will work on api 21 aka android 5, i also do not know what effect it may have on other applications if lib is changed.
since its currently causing bugs here it may not work properly anywhere else..

Does it mean that I should not yet download ECL again, or that ECL will break for older androids if you do this change?

I haven't changed it keep as it is for now.

Okay if you want try version with threads get ecl-ext as opposed to ecl. Requires android 6(aka api 23) and above.

Yes, I tried it, and it seems working so far. Thank you!

@its-pointless https://www.reddit.com/r/Common_Lisp/comments/7npeab/
I have made a small HOWTO regarding your ECL-EXT package - I hope you don't mind. (:

just make sure to mention ecl-ext is not available for 64 bit targets because threads already works. Could avoid possible confusion i guess?

I am confused now. Is ECL-EXT 32-bit? Where can I get a 64-bit one?

If you are on arm or i686 its 32 bit
Aarch64 or x86_64 its 64bit
unless you are using a chromebook you are using arm which is 32bit,

Understood. I have updated my blogpost - can you check if it is better now?

Digging up dead tickets: I've also tried my hand at building SBCL from the disabled package.
See my fork at https://github.com/OverkillGuy/termux-packages/tree/sbcl-build.
I seem to have an issue with pthreads constants not defined.
Here's my compile log: sbcl-compile-error.log
I'm going doing the rabbit hole of understanding what the hell is up, yey my first time doing Makefile-spelunking!
aarch64-linux-android-clang -Oz -g -Wall -Wundef -Wsign-compare -Wpointer-arith -O3 -I/data/data/com.termux/files/usr/include -I. -DSBCL_PREFIX=\"'/data/data/com.termux/files/usr'\" -c -o linux-os.o linux-os.c linux-os.c:183:14: warning: implicit declaration of function 'confstr' is invalid in C99 [-Wimplicit-function-declaration] size_t n = confstr (_CS_GNU_LIBPTHREAD_VERSION, NULL, 0); ^ linux-os.c:183:23: error: use of undeclared identifier '_CS_GNU_LIBPTHREAD_VERSION' size_t n = confstr (_CS_GNU_LIBPTHREAD_VERSION, NULL, 0); ^ linux-os.c:186:16: error: use of undeclared identifier '_CS_GNU_LIBPTHREAD_VERSION' confstr (_CS_GNU_LIBPTHREAD_VERSION, buf, n); ^ 1 warning and 2 errors generated. <builtin>: recipe for target 'linux-os.o' failed
Hoping my tiny contribution can inspire others, or something.
Will report if I get any further

use of undeclared identifier '_CS_GNU_LIBPTHREAD_VERSION'

It seems that the C symbol for _CS_GNU_LIBPTHREAD_VERSION was not found for some reason.

I assume that all of your pthread headers are properly included, aren't they?

Indeed, the wrong file seems included? linux-os.c has a variant for arm64 called arm64-linux-os.c, but for some reason, the generic one was compiled. Could be a conf/flag issue.
Good. I don't like digging GNU PTHREAD things.

Recently, it seems that latest ECL (code from git repo) can be built in Termux cleanly without any modification, and it also works with SLIME. Following is related commands:

git clone https://gitlab.com/embeddable-common-lisp/ecl.git
cd ecl
./configure --prefix=$HOME/.local --build=aarch64-linux-android --enable-gmp=included
make
make install

Anyone familiar with cross compilation can also have a try.

Yup I haven't had the least bit of luck getting clisp or esl to compile. The ecl configure fails on a missing makeinfo for the manual, and I couldn't find that anywhere...

makeinfo comes with
pkg install texinfo

I gave up on this big time. It feels impossible to get any kind of Lisp repl on my phone. If it isn't missing makeinfo, then it is the placement of the sh binary (not bash...) etc etc etc. Hard to believe anyone has gotten it to work. Hell, when I git clone plop's binary, tar complains that the tar.gz file is truncated... :/

Why can't it just be part of the packages available through apt?

i suppose i can update the ecl pr. In newer termux for api 24 and up its more straight forward. Its available from my repo you can just download the deb file dpkg -i debfile.deb and its done.

I just realized what the problem is. My phone is only 32 bit. I didn't even realize it's gotten that old! A whole lot of the termux stuff has 32 bit versions, so I've been operating all along with zero problems except this one.

I'll come back to this in a few days after I grab myself a phone that doesn't reek of dinosaur. Figures Lisp would be the thing that forces me to upgrade the hardware.

i will get it working in about 10 minutes

That would be swell. Thanks for all your efforts.

I got ECL and Chicken Scheme installed and working on termux. Have a look here: https://github.com/dbertolotto/termux

ecl from its-pointless worked flawlessly for months but now I have this issue:

The following packages have unmet dependencies: ecl : Depends: libffi-dev but it is not installable Depends: libgc-dev but it is not installable Depends: libgmp-dev but it is not installable E: Unable to correct problems, you have held broken packages.

also I tried
$ pkg install libffi-dev

but

Package libffi-dev is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source However the following packages replace it: libffi

E: Package 'libffi-dev' has no installation candidate

I don't know where to go from here
(other than try and compile it myself on termux)

thanks for any advice

@liltaylor you can easily build ECL yourself

pkg install -y git build-essential texinfo libgmp libgmp-dev
git clone https://gitlab.com/embeddable-common-lisp/ecl.git
cd ecl
#git checkout ECL-16.1.3
git checkout 06f0a93421b261aaa0fbfb2c9d077eebfc366280
./configure --prefix=$PREFIX --build=aarch64-linux-android --enable-gmp=include
make -j6
make install 
cd ~

That specific commit hash worked for me, the tagged version didn't.

just for the record: I have tried compiling, but it wouldn't link because it couldn't find some atomic library functions (though libatomic-dev is installed in my termux).

I am not giving too much time to this now, so, admittedly, it is probably my fault.

Thank you anyway for your help

@liltaylor I guess you are on arm and ran into this: https://github.com/termux/termux-packages/issues/3092

aaaaaand .....it's back!

today I did a "pkg update" and, just for kicks, a "pkg show ecl" and there it was: a new version. installed and it works like a charm.

I must thank its-pointless I guess

@Grimler91
thank you for your comment I only read it now.

I think you are right, my problem was I wouldn't know how to configure ecl's build system so to include those compiler options, I was investigating, but, since I do this kind of things pretty much only on the phone, and in the cramped up space of its screen and keyboard, it was taking a good deal of time and effort.

thank you again, cheers!

Since ECL is buildable inside Termux, how come there is not an official package?

how come there is not an official package?

Building inside Termux and cross-compiling are different things.

I can can compile ecl. Just been lazy so havent made pr

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StephanBeer picture StephanBeer  Â·  3Comments

bbtdev picture bbtdev  Â·  3Comments

thurask picture thurask  Â·  3Comments

newmania picture newmania  Â·  3Comments

zejji picture zejji  Â·  4Comments