termux-play-store / termux-packages

Packages for the current Termux build on Google Play.
Other
18 stars 0 forks source link

[Bug]: iconv.h missing #2

Closed timstrom closed 2 months ago

timstrom commented 3 months ago

Problem description

iconv.h is missing.

That may be caused by the following command

TERMUX_PKG_RM_AFTER_INSTALL="include/iconv.h"

in termux-packages/packages/libiconv/build.sh

iconv.h seems not to be provided by other packages.

What steps will reproduce the bug?

apt install libiconv

What is the expected behavior?

No response

System information

Termux Variables:
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_EXEC__PROC_SELF_EXE=/data/data/com.termux/files/usr/bin/termux-info
TERMUX_VERSION=0.127
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://termux.net stable main
Updatable packages:
All packages up to date
termux-tools version:
3.0.6
Android version:
14
Kernel build information:
Linux localhost 5.15.137-android14-11-gbf4f9bc41c3b-ab11664771 #1 SMP PREEMPT Wed Apr 3 07:16:23 UTC 2024 aarch64 Android
Device manufacturer:
Google
Device model:
Pixel 8 Pro
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
fornwall commented 3 months ago

Thanks for the clear report!

iconv.h is meant to be included with the ndk-sysroot package, and should now be fixed in https://github.com/termux-play-store/termux-packages/commit/4b91078ea8486367568143b7e434c90b60a4428e - update to the latest 26d-1 version of ndk-sysroot with pkg up.

Let me know how it works! Note that iconv is currently provided by the system libc (in the Google Play build of Termux, which targets newer Android versions), so no external libraries are necessary.

timstrom commented 3 months ago

Thank you for the quick response.

There seems to be something 'wrong' with the system iconv.h from ndk-sysroot.

I am trying to compile the statistic program R (R-4.4.1.tar.gz).

This works on F-Droid Termux, when I use the following command to configure the Makefile:

CC=clang CXX=clang++ FC=flang-new LD=lld ./configure --with-x=no --enable-R-shlib --prefix=$PREFIX/local/R-4.4.1

If I use the same command on play-store Termux, the configure script stops with the following error:

checking for iconv.h... yes checking for iconv... yes checking whether iconv accepts "UTF-8", "latin1", "ASCII" and "UCS-*"... no configure: error: a suitable iconv is essential

The configure script and make run successfully when I install the libiconv package from F-Droid Termux locally:

dpkg -i -force-overwrite libiconv_1.17_aarch64.deb

fornwall commented 3 months ago

@timstrom Thanks a lot for the detailed steps - will look into this shortly!

fornwall commented 3 months ago

Indeed, the iconv functionality provided by the bionic libc is quite limited: https://android.googlesource.com/platform/bionic.git/+/refs/heads/main/libc/bionic/iconv.cpp, only

  if (__match_encoding(s, "utf8")) {
    *encoding = UTF_8;
  } else if (__match_encoding(s, "ascii") || __match_encoding(s, "usascii")) {
    *encoding = US_ASCII;
  } else if (__match_encoding(s, "utf16le")) {
    *encoding = UTF_16_LE;
  } else if (__match_encoding(s, "utf16be")) {
    *encoding = UTF_16_BE;
  } else if (__match_encoding(s, "utf32le")) {
    *encoding = UTF_32_LE;
  } else if (__match_encoding(s, "utf32be")) {
    *encoding = UTF_32_BE;
  } else if (__match_encoding(s, "wchart")) {
    *encoding = WCHAR_T;
  } else {
    return false;
  }

While the test program run by R:s configure is:

int main (void) {
  iconv_t cd;
  cd = iconv_open("latin1","UTF-8");
  if(cd == (iconv_t)(-1)) {printf("latin1 UTF-8\n"); exit(1); }
  iconv_close(cd);
  cd = iconv_open("UTF-8","latin1");
  if(cd == (iconv_t)(-1)) exit(1);
  iconv_close(cd);
  cd = iconv_open("","latin1");
  if(cd == (iconv_t)(-1)) exit(1);
  iconv_close(cd);
  cd = iconv_open("","UTF-8");
  if(cd == (iconv_t)(-1)) exit(1);
  iconv_close(cd);
  cd = iconv_open("latin1", "");
  if(cd == (iconv_t)(-1)) exit(1);
  iconv_close(cd);
  cd = iconv_open("UTF-8","");
  if(cd == (iconv_t)(-1)) exit(1);
  iconv_close(cd);
  cd = iconv_open("ASCII","");
  if(cd == (iconv_t)(-1)) exit(1);
  iconv_close(cd);
  cd = iconv_open("UCS-2LE","");
  if(cd == (iconv_t)(-1)) exit(1);
  iconv_close(cd);
  cd = iconv_open("", "UCS-2LE");
  if(cd == (iconv_t)(-1)) exit(1);
  iconv_close(cd);
  cd = iconv_open("UCS-2BE","");
  if(cd == (iconv_t)(-1)) exit(1);
  iconv_close(cd);
  cd = iconv_open("", "UCS-2BE");
  if(cd == (iconv_t)(-1)) exit(1);
  iconv_close(cd);
  cd = iconv_open("UCS-4LE","");
  if(cd == (iconv_t)(-1)) exit(1);
  iconv_close(cd);
  cd = iconv_open("", "UCS-4LE");
  if(cd == (iconv_t)(-1)) exit(1);
  iconv_close(cd);
  cd = iconv_open("UCS-4BE","");
  if(cd == (iconv_t)(-1)) exit(1);
  iconv_close(cd);
  cd = iconv_open("", "UCS-4BE");
  if(cd == (iconv_t)(-1)) exit(1);
  iconv_close(cd);
  exit(0);
}

Will most likely go back to letting the more fully featured GNU libiconv package provide iconv, instead of the more limited built-in bionic functionality.

timstrom commented 3 months ago

Thanks. Would make it easier to compile the R package.

fornwall commented 2 months ago

@timstrom https://github.com/termux-play-store/termux-packages/commit/8e8d2b7c2bdab62616192cec184edd16e1dec1a8 changes back so that iconv.h is provided by the libiconv package - if you run pkg up, does it work better?

timstrom commented 2 months ago

iconv.h of the libiconv package works for the configuration of the Makefile.

But Since June 20 it is not longer possible to compile (make) the R-packages. I get errors like

sh: /data/data/com.termux/files/usr/bin/make: Permission denied sh: /data/data/com.termux/files/usr/bin/make: Permission denied

May be, it is caused by the upgrades of termux.exec or termux-tools on June 20.

Some libraries can be compiled, others not.

Make finishes with the following error message:

`begin installing recommended package MASS

fornwall commented 2 months ago

Since June 20 it is not longer possible to compile (make) the R-packages. I get errors like sh: /data/data/com.termux/files/usr/bin/make: Permission denied sh: /data/data/com.termux/files/usr/bin/make: Permission denied May be, it is caused by the upgrades of termux.exec or termux-tools on June 20.

@timstrom Thanks a lot! I think the just released version 1.4 of termux-exec fixes the issue you've seen here, when you have the time please run pkg up to update and check how it works!

timstrom commented 2 months ago

It works. Thank you.

fornwall commented 2 months ago

Thanks for following up!