ciao-lang / ciao

Ciao is a modern Prolog implementation that builds up from a logic-based simple kernel designed to be portable, extensible, and modular.
https://ciao-lang.org
GNU Lesser General Public License v3.0
268 stars 20 forks source link

Errors while compiling in Termux #49

Closed llsant closed 2 years ago

llsant commented 2 years ago

While trying to compile in Termux version 0.133 I get the following error:

Termux: ~/ciao >> ./ciao-boot.sh => builder: building [boot] compiling ciaoengine (engine for ciaoc.sta) /data/data/com.termux/files/home/ciao/build-boot/eng/ciaoengine/src/concurrency.c:400:7: error: too few arguments to function call, expected 2, have 1 Thread_Cancel(goal_ref->thread_handle); ^~~~~~~~~~

Looking at the Android definition of the macro in core/engine/os_threads.h, line 499, it reads:

define Thread_Cancel(id) pthread_kill(Id)

According to the project maintainers, they could compile it without any problem in an older version of termux, but after upgrading they have been able to reproduce the issue. I have done some research and I still can't figure out why in an older version of termux it was possible to call pthread_kill with one parameter. According to POSIX documentation, there should be two parameters: id and signal. It's well known that Bionic libc, which Android and Termux use, doesn't have pthread_cancel and some other functions, but the parameter count issue doesn't seem to be documented anywhere.

I have been able to compile it by just changing the line to:

define Thread_Cancel(id) pthread_kill(Id, SIGKILL)

But we should still figure out what happened in old versions of termux. Problem is, it's probably not due to the app itself, but due to the unupgraded packages. And there's no way to downgrade termux packages (only the app), which makes it harder to debug the problem.

Version information:

Termux 0.133

clang version 13.0.0 Target: aarch64-unknown-linux-android24 Thread model: posix InstalledDir: /data/data/com.termux/files/usr/bin

Package ndk-sysroot version 23b-4 provides /usr/include/signal.h, which defines in line 167:

int pthread_kill(pthread_t pthread, int signal); // 2 parameter version

jfmc commented 2 years ago

Thank you for your report and patch. It has been merged (with minor modifications). Please reopen if there is any problem.