ksh93 / ksh

ksh 93u+m: KornShell lives! | Latest release: https://github.com/ksh93/ksh/releases
Eclipse Public License 2.0
163 stars 28 forks source link

building for termux on android #746

Open numberokta opened 1 month ago

numberokta commented 1 month ago

I want to build ksh93 for termux on android but it gives me this error (compiling with clang)

+ cc -D_BLD_DLL -fPIC -D_BLD_ast -Os -I. -I/data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh-1.0.8/src/lib/libast -Icomp -I/data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh-1.0.8/src/lib/libast/comp -Iinclude -I/data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh-1.0.8/src/lib/libast/include -Istd -I/data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh-1.0.8/src/lib/libast/std -c /data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh-1.0.8/src/lib/libast/comp/catopen.c
/data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh-1.0.8/src/lib/libast/comp/catopen.c:103:17: error: call to undeclared function 'catopen'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  103 |                 if (s && (d = catopen(s, flag)) != (nl_catd)(-1) || !(s = 0) && (d = catopen(name, flag)) != (nl_catd)(-1))
      |                               ^
/data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh-1.0.8/src/lib/libast/comp/catopen.c:103:15: error: incompatible integer to pointer conversion assigning to 'nl_catd' (aka 'void *') from 'int' [-Wint-conversion]
  103 |                 if (s && (d = catopen(s, flag)) != (nl_catd)(-1) || !(s = 0) && (d = catopen(name, flag)) != (nl_catd)(-1))
      |                             ^ ~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh-1.0.8/src/lib/libast/comp/catopen.c:103:70: error: incompatible integer to pointer conversion assigning to 'nl_catd' (aka 'void *') from 'int' [-Wint-conversion]
  103 |                 if (s && (d = catopen(s, flag)) != (nl_catd)(-1) || !(s = 0) && (d = catopen(name, flag)) != (nl_catd)(-1))
      |                                                                                    ^ ~~~~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh-1.0.8/src/lib/libast/comp/catopen.c:107:5: error: call to undeclared function 'catclose'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  107 |                                 catclose(d);
      |                                 ^
/data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh-1.0.8/src/lib/libast/comp/catopen.c:115:6: error: call to undeclared function 'catclose'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  115 |                                         catclose(d);
      |                                         ^
/data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh-1.0.8/src/lib/libast/comp/catopen.c:148:16: error: call to undeclared function 'catgets'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  148 |                 msg = (char*)catgets(((Cc_t*)cat)->cat, set, num, msg);
      |                              ^
/data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh-1.0.8/src/lib/libast/comp/catopen.c:148:9: warning: cast to 'char *' from smaller integer type 'int' [-Wint-to-pointer-cast]
  148 |                 msg = (char*)catgets(((Cc_t*)cat)->cat, set, num, msg);
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh-1.0.8/src/lib/libast/comp/catopen.c:175:10: error: call to undeclared function 'catclose'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  175 |                 return catclose(((Cc_t*)cat)->cat);
      |                        ^
1 warning and 7 errors generated.
mamake [lib/libast]: *** exit code 1 making catopen.o
mamake: *** exit code 1 making lib/libast
mamake: *** exit code 1 making all
package: make failed at Fri Apr 19 11:14:10 +0330 2024 in /data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh-1.0.8/arch/linux.arm64-64

See full build log here

McDutchie commented 1 month ago

Thanks for the report. This should already have been fixed in commit c3fec93fd7ea16feea53d52901c3d1edf7293a70, so the upcoming 1.0.9 release should build on Termux. In the meantime, please try building the current git code and let me know if it works for you:

git clone -b 1.0 https://github.com/ksh93/ksh
cd ksh
bin/package make
bin/package use
numberokta commented 1 month ago

Thanks for your replay, I tested that and it gives this error

ld.lld: error: undefined reference due to --no-allow-shlib-undefined: libandroid_shmget
>>> referenced by /data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh/arch/android.arm64-64/dyn/lib/libast.so

ld.lld: error: undefined reference due to --no-allow-shlib-undefined: libandroid_shmat
>>> referenced by /data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh/arch/android.arm64-64/dyn/lib/libast.so

ld.lld: error: undefined reference due to --no-allow-shlib-undefined: libandroid_shmdt
>>> referenced by /data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh/arch/android.arm64-64/dyn/lib/libast.so

ld.lld: error: undefined reference due to --no-allow-shlib-undefined: libandroid_shmctl
>>> referenced by /data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh/arch/android.arm64-64/dyn/lib/libast.so
cc: error: linker command failed with exit code 1 (use -v to see invocation)
mamake [cmd/builtin]: *** exit code 1 making /data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh/arch/android.arm64-64/dyn/bin/pty
mamake: *** exit code 1 making cmd/builtin
mamake: *** exit code 1 making all
package: make failed at Fri Apr 19 19:08:06 +0330 2024 in /data/data/com.termux/files/home/neuctl/build/termux/ksh/ksh/arch/android.arm64-64
McDutchie commented 1 month ago

Strange. I cannot reproduce that at all. :(

What Android version are you using, and what version of termux, and what version of clang, and did you set CCFLAGS and/or LDFLAGS, and if so, to what values?

numberokta commented 1 month ago

That error happened on Termux 0.118.0+8e3a898 Now i tested with this Android 13 Termux 0.118.0+2f40df9 env: TERMUX_APP__TARGET_SDK="28"

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

I didn't set CCFLAGS and/or LDFLAGS It gives me error (log file) I think the issue is related to the target because i saw --target=armv8l-linux-android26 in log file