Help: `make install` fails on Termux

I'm trying to compile Racket 8.4(cs) on my Android phone with Termux, because the version provided in their repo is too old (7.4 bc).

I used ./configure --prefix=$PREFIX and it seems good, make also succeeded with no errors.
Everything went well until I reached make install part, where it fails:

make[4]: Entering directory '/data/data/com.termux/files/home/downloads/racket-8.4/src/cs/c'
/data/data/com.termux/files/usr/bin/racket -Z ../../../../../build/config -X "/data/data/com.termux/files/usr/share/racket/collects" -G "/data/data/com.termux/files/usr/etc/racket"  -Z ../../../../../build/config  -N "raco" -l- setup --no-user
ffi-lib: could not load foreign library
  path: [all opened]
  system error: unknown error
  context...:
   /data/data/com.termux/files/usr/share/racket/collects/ffi/unsafe.rkt:249:2: get-ffi-obj*
   body of "/data/data/com.termux/files/usr/share/racket/collects/net/win32-ssl.rkt"
   body of "/data/data/com.termux/files/usr/share/racket/collects/setup/main.rkt"
make[4]: *** [Makefile:500: do-setup-install] Error 1

Both minimal and full packages fail at the same place with this confusing error.
I also tried snapshot build, which errors even earlier at the beginning of make part.

Is there anything I can do in order to solve this?

3 Likes

Hi @spore
I’m sorry I don’t have an answer but have you tried a bc build? I’m just guessing from the text of your error message and the last time I saw this it was on bc.
Let us know how you get on.
Best regards
Stephen

I've tried BC and the only thing I can remember now is that it also failed...

Edit: Ok I will try it again and record the output.
Commands:

./configure --prefix=$PREFIX --enable-bconly
make
make install

And it failed at (roughly) the same place, giving output:

make[2]: Entering directory '/data/data/com.termux/files/home/downloads/racket-8.4/src/bc'
./racket3m -X "/data/data/com.termux/files/usr/share/racket/collects" -G "/data/data/com.termux/files/usr/etc/racket"  -Z ../../../../build/config  --no-user-path -N "raco" -l- setup --no-user
ffi-lib: couldn't open #f (unknown error)
   context...:
    /data/data/com.termux/files/usr/share/racket/collects/ffi/unsafe.rkt:131:0: get-ffi-lib
make[2]: *** [Makefile:476: install-setup-3m] Error 1

Which is equally confusing and not giving any additional information...

Sorry that wasn’t much help. I think someone on the discord was using tmux on Android but it was a year ago at least. Might be worth asking on there.

1 Like

I've been getting basically that same error trying to build 8.6 minimal on android with the default configuration:

Same function, same modules on the stack, no clue why we're trying to use win32-ssl.rkt on Android because the stacktrace just blames module bodies for the calls???

3 Likes

raco setup loads various pieces of code, which includes net/git-checkout which eventually depends on net/win32-ssl.rkt. The relevant code isn't inside any functions so it wouldn't have anything more in the stack trace.

The most likely thing that could go wrong here is that system-type is producing the wrong value. Can you try running the racket binary on that command line and seeing what it produces for (system-type)?

2 Likes

raco setup loads various pieces of code, which includes net/git-checkout which eventually depends on net/win32-ssl.rkt. The relevant code isn't inside any functions so it wouldn't have anything more in the stack trace.

I mean, those frames might be sensible, but line numbers sure would be handy. (I suppose it would be a bit much to hope for a debugger at this point during startup, but I can dream ...)

The most likely thing that could go wrong here is that system-type is producing the wrong value. Can you try running the racket binary on that command line and seeing what it produces for (system-type)?

~/.../src/build $ /data/data/com.termux/files/home/racket-8.6/bin/racket -I racket/kernel/init
Welcome to Racket v8.6 [cs].
> (system-type)
'unix

If I understand correctly, in this particular context, get-ffi-obj* is being asked to build functions that will (given that we don't have a secur32.dll) fail when they are called.

It really doesn't look like the function has been called yet ...

Tangentially, does Termux provide a /bin/sh, or is the shell at /system/bin/sh?

Right, it looks like what's going on is that trying to define ffi bindings to symbols that are not found is erroring. Can you try this program?

#lang racket/base

(require ffi/unsafe ffi/unsafe/define ffi/winapi)


(define-ffi-definer define-secur32 #f
  #:default-make-fail make-not-available)

(define-secur32 InitSecurityInterfaceW
  (_fun #:abi winapi -> _pointer))

I'm able to reproduce on Termux. For your program I'm getting:

ffi-lib: could not load foreign library
  path: [all opened]
  system error: unknown error
  context...:
   /data/data/com.termux/files/home/build/racket-8.6/collects/ffi/unsafe.rkt:249:2: get-ffi-obj*
   body of "/data/data/com.termux/files/home/build/racket-8.6/src/build/foo.rkt"

Also attempting to just load malloc I get the same:

Welcome to Racket v8.6 [cs].
> (require ffi/unsafe ffi/unsafe/define)
> (define-ffi-definer define-libc #f)
> (define-libc malloc (_fun _uint -> _pointer))
ffi-lib: could not load foreign library
  path: [all opened]
  system error: unknown error
  context...:
   body of top-level
   /data/data/com.termux/files/home/build/racket-8.6/collects/ffi/unsafe.rkt:249:2: get-ffi-obj*
   /data/data/com.termux/files/home/build/racket-8.6/collects/racket/repl.rkt:11:26