Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cpan install failed on Android. #22627

Closed
RajDave-Dev opened this issue Sep 27, 2024 · 50 comments
Closed

Cpan install failed on Android. #22627

RajDave-Dev opened this issue Sep 27, 2024 · 50 comments

Comments

@RajDave-Dev
Copy link

Module: local::lib

Description

As we all know starting from Android 10 execution of binary is forbidden on Android. To overcome this problem we execute the binary with /system/bin/linker64 binaryname arguments. So the problem here is we add prefix of the linker64 to the binary that is executing but when perl try to get its own exe it always return the linker64 not perl I tried to fix this and repaced /proc/self/exe with the perl path but it didn't work.
Steps to Reproduce

You can try this on termux on play store. Although I encountered this error in my app and also in termux.

Expected behavior

Should work as does in termux's GitHub varient.
Perl configuration

# perl -V output goes here
This is perl 5, version 38, subversion 2 (v5.38.2) built for aarch64-android                                                                                                     
Copyright 1987-2023, Larry Wall                                                                                       
Perl may be copied only under the terms of either the Artistic License or the                                         
GNU General Public License, which may be found in the Perl 5 source kit.                                                                                                         
Complete documentation for Perl, including FAQ lists, should be found on                                              
this system using "man perl" or "perldoc perl".  
If you have access to the                                            
Internet, point your browser at https://www.perl.org/, the Perl Home Page.
@richardleach
Copy link
Contributor

To overcome this problem we execute the binary with /system/bin/linker64 binaryname arguments. So the problem here is we add prefix of the linker64 to the binary that is executing but when perl try to get its own exe it always return the linker64 not perl

Please could you show:

  • How you built perl
  • The simplest possible example of the error occuring - what code are you using to trigger and what's the output?

Is the fundamental problem that described by https://github.com/termux/termux-packages/wiki/Termux-and-Android-10 with an open-ended discussion under termux/termux-app#2155 ?

Finally, how does this relate to local::lib please?

@RajDave-Dev
Copy link
Author

  1. I have built perl using the termux's package builder and ran command: ./scripts/run-docker.sh ./build-package.sh perl
  2. Yes it is.
  3. I don't think that it is really related to local::lib

Here is the output of cpan install local::lib

Andio:~ $ cpan install local::lib
Loading internal logger. Log::Log4perl recommended for better logging
Reading '/data/data/com.raj.andio/files/user/home/.cpan/Metadata'
  Database was generated on Fri, 27 Sep 2024 12:29:01 GMT
Running install for module 'local::lib'
Checksum for /data/data/com.raj.andio/files/user/home/.cpan/sources/authors/id/H/HA/HAARG/local-lib-2.000029.tar.gz ok
'YAML' not installed, will not store persistent state
Configuring H/HA/HAARG/local-lib-2.000029.tar.gz with Makefile.PL
error: expected absolute path: "Makefile.PL"
Warning: No success on command[/apex/com.android.runtime/bin/linker64 Makefile.PL]
  HAARG/local-lib-2.000029.tar.gz
  /apex/com.android.runtime/bin/linker64 Makefile.PL -- NOT OK

Here is the strace file
cpan.txt

The problem I think is that when perl wants its own binary path but get the linker64 path, we use linker64 to execute every executable file so linker64 is the argv[0]. At first I was thinking that changing the /proc/self/exe to the perl binary path will solve the problem but it doesn't. So I searched for argv[0] and now I'm going to try changing the argv[0] to argv[1] because argv[0] is always the linker64, I hope that work.

Here Andio is my own app and same problem is occurring in termux's Play Store version.

@RajDave-Dev
Copy link
Author

I tried changing the argv[0] to argv[1] but it doesn't work, I have changed only PL_origargv[] in all files.

@Leont
Copy link
Contributor

Leont commented Sep 28, 2024

I guess that means we should not be using the linux code for making $^X an absolute path on android then. I'd guess that's the procselfexe configuration option that needs to be disabled.

@RajDave-Dev
Copy link
Author

How can we disable it?

@Leont
Copy link
Contributor

Leont commented Sep 28, 2024

How can we disable it?

That depends on how you build it. Adding a -Uprocselfexe argument to Configure might be enough, but you may also have to edit hints/linux-android.sh because that can also fiddle with it.

@RajDave-Dev
Copy link
Author

Okay, I'll try it as well

@RajDave-Dev
Copy link
Author

Now I'm getting this error while compiling 5.41.4, am I Missing any library?
I'm not adding any libs while compiling perl

aarch64-linux-android-clang -DPERL_CORE --sysroot=/home/builder/.termux-build/_cache/android-r27b-api-29-v1/sysroot  -D__USE_BSD=1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -fPIC -Wno-unused-function -c -o locale.o locale.c
locale.c:6252:12: error: use of undeclared identifier '_NL_ADDRESS_POSTAL_FMT'
 6252 |       case _NL_ADDRESS_POSTAL_FMT:
      |            ^
locale.c:6253:12: error: use of undeclared identifier '_NL_ADDRESS_COUNTRY_NAME'
 6253 |       case _NL_ADDRESS_COUNTRY_NAME:
      |            ^
locale.c:6254:12: error: use of undeclared identifier '_NL_ADDRESS_COUNTRY_POST'
 6254 |       case _NL_ADDRESS_COUNTRY_POST:
      |            ^
locale.c:6255:12: error: use of undeclared identifier '_NL_ADDRESS_COUNTRY_AB2'
 6255 |       case _NL_ADDRESS_COUNTRY_AB2:
      |            ^
locale.c:6256:12: error: use of undeclared identifier '_NL_ADDRESS_COUNTRY_AB3'
 6256 |       case _NL_ADDRESS_COUNTRY_AB3:
      |            ^
locale.c:6257:12: error: use of undeclared identifier '_NL_ADDRESS_COUNTRY_CAR'
 6257 |       case _NL_ADDRESS_COUNTRY_CAR:
      |            ^
locale.c:6258:12: error: use of undeclared identifier '_NL_ADDRESS_COUNTRY_NUM'
 6258 |       case _NL_ADDRESS_COUNTRY_NUM:
      |            ^
locale.c:6259:12: error: use of undeclared identifier '_NL_ADDRESS_COUNTRY_ISBN'
 6259 |       case _NL_ADDRESS_COUNTRY_ISBN:
      |            ^
locale.c:6260:12: error: use of undeclared identifier '_NL_ADDRESS_LANG_NAME'
 6260 |       case _NL_ADDRESS_LANG_NAME:
      |            ^
locale.c:6261:12: error: use of undeclared identifier '_NL_ADDRESS_LANG_AB'
 6261 |       case _NL_ADDRESS_LANG_AB:
      |            ^
locale.c:6262:12: error: use of undeclared identifier '_NL_ADDRESS_LANG_TERM'
 6262 |       case _NL_ADDRESS_LANG_TERM:
      |            ^
locale.c:6263:12: error: use of undeclared identifier '_NL_ADDRESS_LANG_LIB'
 6263 |       case _NL_ADDRESS_LANG_LIB:
      |            ^
locale.c:6270:12: error: use of undeclared identifier '_NL_IDENTIFICATION_TITLE'; did you mean 'LC_IDENTIFICATION_INDEX_'?
 6270 |       case _NL_IDENTIFICATION_TITLE:
      |            ^~~~~~~~~~~~~~~~~~~~~~~~
      |            LC_IDENTIFICATION_INDEX_
./locale_table.h:145:5: note: 'LC_IDENTIFICATION_INDEX_' declared here
  145 |     PERL_LOCALE_TABLE_ENTRY(IDENTIFICATION, NULL)
      |     ^
./perl.h:1219:55: note: expanded from macro 'PERL_LOCALE_TABLE_ENTRY'
 1219 | #    define PERL_LOCALE_TABLE_ENTRY(name, call_back)  LC_ ## name ## _INDEX_,
      |                                                       ^
<scratch space>:33:1: note: expanded from here
   33 | LC_IDENTIFICATION_INDEX_
      | ^
locale.c:6271:12: error: use of undeclared identifier '_NL_IDENTIFICATION_SOURCE'; did you mean 'LC_IDENTIFICATION_INDEX_'?
 6271 |       case _NL_IDENTIFICATION_SOURCE:
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~
      |            LC_IDENTIFICATION_INDEX_
./locale_table.h:145:5: note: 'LC_IDENTIFICATION_INDEX_' declared here
  145 |     PERL_LOCALE_TABLE_ENTRY(IDENTIFICATION, NULL)
      |     ^
./perl.h:1219:55: note: expanded from macro 'PERL_LOCALE_TABLE_ENTRY'
 1219 | #    define PERL_LOCALE_TABLE_ENTRY(name, call_back)  LC_ ## name ## _INDEX_,
      |                                                       ^
<scratch space>:33:1: note: expanded from here
   33 | LC_IDENTIFICATION_INDEX_
      | ^
locale.c:6272:12: error: use of undeclared identifier '_NL_IDENTIFICATION_ADDRESS'; did you mean 'LC_IDENTIFICATION_INDEX_'?
 6272 |       case _NL_IDENTIFICATION_ADDRESS:
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |            LC_IDENTIFICATION_INDEX_
./locale_table.h:145:5: note: 'LC_IDENTIFICATION_INDEX_' declared here
  145 |     PERL_LOCALE_TABLE_ENTRY(IDENTIFICATION, NULL)
      |     ^
./perl.h:1219:55: note: expanded from macro 'PERL_LOCALE_TABLE_ENTRY'
 1219 | #    define PERL_LOCALE_TABLE_ENTRY(name, call_back)  LC_ ## name ## _INDEX_,
      |                                                       ^
<scratch space>:33:1: note: expanded from here
   33 | LC_IDENTIFICATION_INDEX_
      | ^
locale.c:6273:12: error: use of undeclared identifier '_NL_IDENTIFICATION_CONTACT'; did you mean 'LC_IDENTIFICATION_INDEX_'?
 6273 |       case _NL_IDENTIFICATION_CONTACT:
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |            LC_IDENTIFICATION_INDEX_
./locale_table.h:145:5: note: 'LC_IDENTIFICATION_INDEX_' declared here
  145 |     PERL_LOCALE_TABLE_ENTRY(IDENTIFICATION, NULL)
      |     ^
./perl.h:1219:55: note: expanded from macro 'PERL_LOCALE_TABLE_ENTRY'
 1219 | #    define PERL_LOCALE_TABLE_ENTRY(name, call_back)  LC_ ## name ## _INDEX_,
      |                                                       ^
<scratch space>:33:1: note: expanded from here
   33 | LC_IDENTIFICATION_INDEX_
      | ^
locale.c:6274:12: error: use of undeclared identifier '_NL_IDENTIFICATION_EMAIL'
 6274 |       case _NL_IDENTIFICATION_EMAIL:
      |            ^
locale.c:6275:12: error: use of undeclared identifier '_NL_IDENTIFICATION_TEL'
 6275 |       case _NL_IDENTIFICATION_TEL:
      |            ^
locale.c:6276:12: error: use of undeclared identifier '_NL_IDENTIFICATION_FAX'
 6276 |       case _NL_IDENTIFICATION_FAX:
      |            ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[1]: *** [Makefile:157: locale.o] Error 1
make[1]: Leaving directory '/home/builder/.termux-build/perl/src'
make: *** [Makefile:87: all] Error 2

@Leont
Copy link
Contributor

Leont commented Sep 29, 2024

Now I'm getting this error while compiling 5.41.4, am I Missing any library?

Locale on Android has always been weird. I think @khwilliamson is better equipped to answer that question. I guess 3c45ca2 needs some refinement.

@khwilliamson
Copy link
Contributor

khwilliamson commented Sep 29, 2024 via email

@RajDave-Dev
Copy link
Author

Where is this langinfo.h or locale.i is located approximately?

I use termux's package builder so I somewhat don't know about it......

@RajDave-Dev
Copy link
Author

I searched langinfo.h in android ndk, I don't find any.

@khwilliamson
Copy link
Contributor

If you run make locale.i from the directory where you compile perl, it will create that .i file, which you can then send to me. Don't bother with langinfo.h for now; I may not need it.

But adding that Configure option should have gotten you (hopefully much) further along. The locale.i is just to help me figure out for the future what we can do to avoid this particular issue

@RajDave-Dev
Copy link
Author

And yeah, I forgot to tell you that after using that configure option -Accflags='-DNO_LOCALE' it still failed with that locale error.

@RajDave-Dev
Copy link
Author

I ran make locale.i after configuration and this is what I get make: *** No rule to make target 'locale.i'. Stop.

@khwilliamson
Copy link
Contributor

Is there a config.h file in that directory. If so, please send it to me

@RajDave-Dev
Copy link
Author

Okay.
Here it is:
config.txt

Renamed this file from config.h to .txt

@khwilliamson
Copy link
Contributor

Attached is the file perl_langinfo.txt. You can just copy that on top of your existing file perl_langinfo.h Note the name change due to github limitations.
perl_langinfo.TXT

@khwilliamson
Copy link
Contributor

I hope this will get you past this problem. Let us know.

@RajDave-Dev
Copy link
Author

I am getting this error.

gcc  -o miniperl miniperlmain.host.o av.host.o scope.host.o doop.host.o doio.host.o dump.host.o gv.host.o hv.host.o mg.host.o reentr.host.o mro_core.host.o perly.host.o pp.host.o pp_hot.host.o pp_ctl.host.o pp_sys.host.o regexec.host.o utf8.host.o sv.host.o taint.host.o toke.host.o util.host.o deb.host.o run.host.o universal.host.o pad.host.o globals.host.o keywords.host.o perlio.host.o numeric.host.o mathoms.host.o locale.host.o pp_pack.host.o pp_sort.host.o caretx.host.o dquote.host.o time64.host.o builtin.host.o peep.host.o class.host.o regcomp.host.o regcomp_debug.host.o regcomp_invlist.host.o regcomp_study.host.o regcomp_trie.host.o opmini.host.o perlmini.host.o -lm -lcrypt -ldl
make[1]: Leaving directory '/home/builder/.termux-build/perl/src'
make dynaloader                                               
make[1]: Entering directory '/home/builder/.termux-build/perl/src'                                                          
sh cflags.SH
cflags.SH: Adding -std=c99.
cflags.SH: Adding -Werror=pointer-arith.                  
cflags.SH: Adding -Werror=vla.
cflags.SH: Adding -Wextra.                                    
cflags.SH: Adding -Wno-long-long.
cflags.SH: Adding -Wno-declaration-after-statement.
cflags.SH: Adding -Wc++-compat.                               
cflags.SH: Adding -Wwrite-strings.
cflags.SH: cc       = aarch64-linux-android-clang             
cflags.SH: ccflags  = --sysroot=/home/builder/.termux-build/_cache/android-r27b-api-29-v1/sysroot  -D__USE_BSD=1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64                               
cflags.SH: stdflags =  -std=c99
cflags.SH: optimize = -O2                                     
cflags.SH: warn     =  -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wwrite-strings                                       
Extracting cflags (with variable substitutions)
./miniperl_top make_patchnum.pl
make[1]: *** [Makefile:209: lib/Config_git.pl] Segmentation fault (core dumped)
make[1]: Leaving directory '/home/builder/.termux-build/perl/src'                                                           
make: *** [Makefile:86: all] Error 2

Here is the strace of the miniperl

execve("./miniperl", ["./miniperl"], 0x7ffe407d4d50 /* 11 vars */) = 0
brk(NULL)                               = 0x55e64506b000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa52de75000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=44571, ...}) = 0
mmap(NULL, 44571, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fa52de6a000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=952616, ...}) = 0
mmap(NULL, 950296, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fa52dd81000
mmap(0x7fa52dd91000, 520192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x10000) = 0x7fa52dd91000
mmap(0x7fa52de10000, 360448, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x8f000) = 0x7fa52de10000
mmap(0x7fa52de68000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe7000) = 0x7fa52de68000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libcrypt.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=198664, ...}) = 0
mmap(NULL, 233888, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fa52dd47000
mmap(0x7fa52dd49000, 86016, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7fa52dd49000
mmap(0x7fa52dd5e000, 102400, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17000) = 0x7fa52dd5e000
mmap(0x7fa52dd77000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2f000) = 0x7fa52dd77000
mmap(0x7fa52dd79000, 29088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fa52dd79000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220\243\2\0\0\0\0\0"..., 832) = 832
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
fstat(3, {st_mode=S_IFREG|0755, st_size=2125328, ...}) = 0
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
mmap(NULL, 2170256, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fa52db35000
mmap(0x7fa52db5d000, 1605632, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x28000) = 0x7fa52db5d000
mmap(0x7fa52dce5000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b0000) = 0x7fa52dce5000
mmap(0x7fa52db5d000, 1605632, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x28000) = 0x7fa52db5d000
mmap(0x7fa52dce5000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b0000) = 0x7fa52dce5000
mmap(0x7fa52dd34000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1fe000) = 0x7fa52dd34000        
mmap(0x7fa52dd3a000, 52624, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fa52dd3a000
close(3)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa52db33000
arch_prctl(ARCH_SET_FS, 0x7fa52db33b80) = 0                   
set_tid_address(0x7fa52db33e50)         = 114956
set_robust_list(0x7fa52db33e60, 24)     = 0
rseq(0x7fa52db344a0, 0x20, 0, 0x53053053) = 0
mprotect(0x7fa52dd34000, 16384, PROT_READ) = 0
mprotect(0x7fa52dd77000, 4096, PROT_READ) = 0                 
mprotect(0x7fa52de68000, 4096, PROT_READ) = 0
mprotect(0x55e643332000, 69632, PROT_READ) = 0
mprotect(0x7fa52dead000, 8192, PROT_READ) = 0                 
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
munmap(0x7fa52de6a000, 44571)           = 0                   
rt_sigaction(SIGFPE, {sa_handler=SIG_IGN, sa_mask=[FPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fa52db7a320}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
getrandom("\x57\x7a\xdf\x85\xc4\x82\x9d\xe5", 8, GRND_NONBLOCK) = 8
brk(NULL)                               = 0x55e64506b000
brk(0x55e64508c000)                     = 0x55e64508c000
getuid()                                = 1000
geteuid()                               = 1000                
getgid()                                = 1000
getegid()                               = 1000
openat(AT_FDCWD, "/dev/urandom", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_GETFD)                       = 0x1 (flags FD_CLOEXEC)
read(3, "\202\253g\247", 4)             = 4
close(3)                                = 0
getuid()                                = 1000
geteuid()                               = 1000
getgid()                                = 1000
getegid()                               = 1000                
openat(AT_FDCWD, "/dev/urandom", O_RDONLY|O_CLOEXEC) = 3
read(3, "\372P\247\253", 4)             = 4
close(3)                                = 0                   
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=3055776, ...}) = 0    
mmap(NULL, 3055776, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fa52d848000
close(3)                                = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x30} ---                                                       
+++ killed by SIGSEGV (core dumped) +++
Segmentation fault (core dumped)

@khwilliamson
Copy link
Contributor

Run Configure, adding to your normal options, the flags -DDEBUGGING -Accflags='-DNO_LOCALE'. And send me the file that Configure generates config.sh Also, start the compilation again, and after it fails, run the following PERL_DEBUG_LOCALE_INIT=1 ./miniperl -DLv and send me the output

@RajDave-Dev
Copy link
Author

Here is the config.sh file:
config.txt

And running the command PERL_DEBUG_LOCALE_INIT=1 ./miniperl -DLv
Gives Segmentation fault (core dumped) and no other output

@khwilliamson
Copy link
Contributor

Try applying this patch setlocale.txt

@RajDave-Dev
Copy link
Author

Still same error

@khwilliamson
Copy link
Contributor

Is the strace the same?

@RajDave-Dev
Copy link
Author

Some lines with the error and options:

gcc  -o miniperl miniperlmain.host.o av.host.o scope.host.o doop.host.o doio.host.o dump.host.o gv.host.o hv.host.o mg.host.o reentr.host.o mro_core.host.o perly.host.o pp.host.o pp_hot.host.o pp_ctl.host.o pp_sys.host.o regexec.host.o utf8.host.o sv.host.o taint.host.o toke.host.o util.host.o deb.host.o run.host.o universal.host.o pad.host.o globals.host.o keywords.host.o perlio.host.o numeric.host.o mathoms.host.o locale.host.o pp_pack.host.o pp_sort.host.o caretx.host.o dquote.host.o time64.host.o builtin.host.o peep.host.o class.host.o regcomp.host.o regcomp_debug.host.o regcomp_invlist.host.o regcomp_study.host.o regcomp_trie.host.o opmini.host.o perlmini.host.o -lm -lcrypt -ldl
make[1]: Leaving directory '/home/builder/.termux-build/perl/src'
make dynaloader
make[1]: Entering directory '/home/builder/.termux-build/perl/src'
sh cflags.SH
cflags.SH: Adding -std=c99.
cflags.SH: Adding -Werror=pointer-arith.
cflags.SH: Adding -Werror=vla.
cflags.SH: Adding -Wextra.
cflags.SH: Adding -Wno-long-long.
cflags.SH: Adding -Wno-declaration-after-statement.
cflags.SH: Adding -Wc++-compat.
cflags.SH: Adding -Wwrite-strings.
cflags.SH: cc       = aarch64-linux-android-clang
cflags.SH: ccflags  = --sysroot=/home/builder/.termux-build/_cache/android-r27b-api-29-v1/sysroot  -D__USE_BSD=1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
cflags.SH: stdflags =  -std=c99
cflags.SH: optimize = -O2
cflags.SH: warn     =  -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wwrite-strings
Extracting cflags (with variable substitutions)
./miniperl_top make_patchnum.pl
make[1]: *** [Makefile:209: lib/Config_git.pl] Segmentation fault (core dumped)
make[1]: Leaving directory '/home/builder/.termux-build/perl/src'
make: *** [Makefile:86: all] Error 2

Strace:
miniperl.strace.txt

@khwilliamson
Copy link
Contributor

I really need to see locale.i. In a log of compiling so far, there should have been a line gcc ... locale.c . Take that line and execute it separately, changing the gcc to gcc -E. And append > locale.i to the end. And send that to me.

@tonycoz
Copy link
Contributor

tonycoz commented Oct 7, 2024

Based on the earlier compilation command-line you should be able to get the preprocessed source with:

aarch64-linux-android-clang -DPERL_CORE --sysroot=/home/builder/.termux-build/_cache/android-r27b-api-29-v1/sysroot  -D__USE_BSD=1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -fPIC -Wno-unused-function -E locale.c >locale.i

You may also want the result of separate runs with -DNO_LOCALE and/or -DDEBUGGING

The Makefile.SH supplied with perl always generates a rule to build .i pre-processed files, so I wonder why it didn't work for you.

@RajDave-Dev
Copy link
Author

Locale.i without any dlocale or debugging.
Command:

aarch64-linux-android-clang -DPERL_CORE --sysroot=/home/builder/.termux-build/_cache/android-r27b-api-29-v1/sysroot  -D__USE_BSD=1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -fPIC -Multifunction -E locale.c >locale.i

File:
locale.txt

Locale.i with -DNO_LOCALE

aarch64-linux-android-clang -DPERL_CORE -DNO_LOCALE --sysroot=/home/builder/.termux-build/_cache/android-r27b-api-29-v1/sysroot  -D__USE_BSD=1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -fPIC -Wno-unused-function -E locale.c >locale.i

File:
locale.dnolocale.txt

Locale.i with -DDEBUGGING

aarch64-linux-android-clang -DPERL_CORE -DDEBUGGING --sysroot=/home/builder/.termux-build/_cache/android-r27b-api-29-v1/sysroot  -D__USE_BSD=1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -fPIC -Wno-unused-function -E locale.c >locale.i

File:
locale.ddebugging.txt

@khwilliamson
Copy link
Contributor

Add to your Configure options -Accflags=-DNO_POSIX_2008_LOCALE If running that fails in the same place, I need the config.sh and locale.i files. I only need the one combination of NO_LOCALE DEBUGGING and NO_POSIX_2008_LOCALE

@RajDave-Dev
Copy link
Author

Here I have used this command to generate locale.i

aarch64-linux-android-clang -DPERL_CORE -DDEBUGGING -DNO_POSIX_2008_LOCALE -DNO_LOCALE --sysroot=/home/builder/packages/build/_cache/android-r27b-api-29-v1/sysroot  -D__USE_BSD=1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -fPIC -Wno-unused-function -E locale.c >locale.i

I have added the --Accflags but clang tells that it doesn't used this flag so I removed --Accflags and only put --DNO_POSIX_2008_LOCALE

Files:
locale.i
config.sh

@khwilliamson
Copy link
Contributor

Several things:

There is only a single - before Accflags and before any of the -D words. Your comments indicate you used a double dash. But the command you used to generate locale.i looks good, and the file contents also look good to me.

Earlier, gcc was being used, and now clang. Is that deliberate?

And do you need threads? Generally, it's best to not use threads when trying to get things set up initially. They are a complication that can be dealt with later.

I think that if you use just the single dash, it will work a lot better, and you should get a lot further in your compilation. The previous version you sent me of locale.i, did not have -DNO_LOCALE actually specified. I don't think -DNO_POSIX_2008_LOCALE is necessary if plain -Accflags=NO_LOCALE is done correctly

You can examine the generated config.sh file and look at the line very near the top that starts config_args=. It should look very much like this

config_args='--target=aarch64-linux-android --with-cc=aarch64-linux-android-clang --with-ranlib=llvm-ranlib -Dosname=android -Dsysroot=/home/builder/packages/build/_cache/android-r27b-api-29-v1/sysroot -Dprefix=/data/data/com.raj.andio/files -Dsh=/data/data/com.raj.andio/files/bin/sh -Dld=aarch64-linux-android-clang -Wl,-rpath=/data/data/com.raj.andio/files/lib -Wl,--enable-new-dtags -Dar=llvm-ar -Duseshrplib -Doptimize=-O2 --with-libs=-lm -Accflags='-DNO_LOCALE' -DDEBUGGING -Uprocselfexe --keeplog --mode=target --target=aarch64-linux-android --targetarch=aarch64-unknown-linux-android'

@RajDave-Dev
Copy link
Author

RajDave-Dev commented Oct 9, 2024

I use termux's package builder scripts.
So i think that gcc is used to build perl to compile the perl files and then cross compile it, and if I forgot to mention that termux uses the https://github.com/arsv/perl-cross and then it copy all the files in perl-cross to the perl's source code.

This is the configure options:

CFLAGS= -D__USE_BSD=1 LDFLAGS= -Wl,-rpath=/data/data/com.raj.andio/files/lib -L/data/data/com.raj.andio/files/lib -lm /home/builder/packages/build/perl-latest/src/configure --target=aarch64-linux-android --with-cc=aarch64-linux-android-clang --with-ranlib=llvm-ranlib -Dosname=android -Dsysroot=/home/builder/packages/build/_cache/android-r27b-api-29-v1/sysroot -Dprefix=/data/data/com.raj.andio/files -Dsh=/data/data/com.raj.andio/files/bin/sh -Dld=aarch64-linux-android-clang -Wl,-rpath=/data/data/com.raj.andio/files/lib -Wl,--enable-new-dtags -Dar=llvm-ar -Duseshrplib -Duseithreads -Dusemultiplicity -Doptimize=-O2 --with-libs=-lm -DNO_LOCALE -DNO_POSIX_2008_LOCALE -DDEBUGGING -Uprocselfexe

Now I am trying without the -Duseithreads -Dusemultiplicity flags.

@RajDave-Dev
Copy link
Author

RajDave-Dev commented Oct 9, 2024

I got the problem, the problem is with the perl-locale you provided. I skip copying the perl-locale file to the source-code's one and that segmentation fault is fixed but after some time it gives error about that locale.c error.

@khwilliamson
Copy link
Contributor

khwilliamson commented Oct 9, 2024

I'm unsure which error you are referring to. If it is the ones like where it says

locale.c:6252:12: error: use of undeclared identifier '_NL_ADDRESS_POSTAL_FMT'
 6252 |       case _NL_ADDRESS_POSTAL_FMT:
      |            ^

then the solution is to use the perl_langinfo.h file I gave in #22627 (comment)

You did uncover a bug there, and that file should fix it.

khwilliamson added a commit to khwilliamson/perl5 that referenced this issue Oct 9, 2024
To save some typing, I assumed that if a system had these glibc-only
locale categories, that it would have all elements that comprise them.
For example with LC_PAPER, the elements are the height and width of a
piece of paper.  It doesn't make any sense to have LC_PAPER without any
dimensions available.

But Android has LC_PAPER without paper dimensions; the same with all the
other elements in the glibc category extensions.  See GH Perl#22627.

I believe that means that these categories are useless on this platform.

But this commit now checks each element for existence individually;
removing the assumption that if the category exists, the element must
too.
@RajDave-Dev
Copy link
Author

RajDave-Dev commented Oct 10, 2024

Sorry by mistake I told perl-locale but it's perl-langinfo.h file.

I was referring to this error #22627 (comment)
The stacktrace is the same to this one without the perl-langinfo.h you provided.

But perl-langinfo.h file you gave that triggers the miniperl's segmentation fault (core dump)

@khwilliamson
Copy link
Contributor

Ok, with the perl_langinfo.h file I gave you that generates the strace problem, send me config.sh and config.i

@RajDave-Dev
Copy link
Author

RajDave-Dev commented Oct 11, 2024

Here is the config.sh
configsh.txt

Here is the config.h
configh.txt

Here is the config.i
configi.txt

Sorry I don't know how to generate config.i and i saw that there is config.h so I ran that locale.c >locale.i command

khwilliamson added a commit to khwilliamson/perl5 that referenced this issue Oct 11, 2024
See GH Perl#22627.

Glibc has a few locale categories that aren't used elsewhere, AFAIK.
Android has a crippled implementation of them, in that it has none of
the items that comprise the categories.

In a typical langinfo.h, these are enum fields, so their existence can't
be checked with an #ifdef, but in Android, everything is a #define, so
much be checked with #ifdef.  To get around this without writing a
Configure probe, this commit just creates #defines when they are missing
the category (which catches the non-Androids) or when using Android.
@khwilliamson
Copy link
Contributor

I'm sorry. I meant I want locale.i But the config.sh file indicates that -Accflags=-DNO_LOCALE wasn't used in your Configure options. Did you forget, or is the cross compilation somehow stripping it. Without that, things aren't going to work

@RajDave-Dev
Copy link
Author

Here is the command I used for creating locale.i

aarch64-linux-android-clang -DPERL_CORE -DDEBUGGING -DNO_POSIX_2008_LOCALE -Accflags=-DNO_LOCALE -DNO_LOCALE --sysroot=/home/builder/packages/build/_cache/android-r27b-api-29-v1/sysroot  -D__USE_BSD=1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -fPIC -Wno-unused-function -E locale.c >locale.i

But it's output is:

clang: warning: argument unused during compilation: '-Accflags=-DNO_LOCALE' [-Wunused-command-line-argument]

Here is the config.sh:
config.sh.txt

Here is the locale.i:
locale.i.txt

Here is the configuration command I have used to configure:

CFLAGS= -D__USE_BSD=1 LDFLAGS= -Wl,-rpath=/data/data/com.raj.andio/files/usr/lib -L/data/data/com.raj.andio/files/usr/lib -lm /home/builder/packages/build/perl-latest/src/configure --target=aarch64-linux-android --with-cc=aarch64-linux-android-clang --with-ranlib=llvm-ranlib -Dosname=android -Dsysroot=/home/builder/packages/build/_cache/android-r27b-api-29-v1/sysroot -Dprefix=/data/data/com.raj.andio/files/usr -Dsh=/data/data/com.raj.andio/files/usr/bin/sh -Dld=aarch64-linux-android-clang -Wl,-rpath=/data/data/com.raj.andio/files/usr/lib -Wl,--enable-new-dtags -Dar=llvm-ar -Duseshrplib -Doptimize=-O2 --with-libs=-lm -DNO_LOCALE -DNO_POSIX_2008_LOCALE -DDEBUGGING -Uprocselfexe -Accflags=-DNO_LOCALE

I have copied your perl-langinfo.h file to its destination.
And the build fails with that miniperl segmentation fault error.

@RajDave-Dev
Copy link
Author

Sorry I'm late, I was changing the installation prefix, because some other packages have some errors.

@khwilliamson
Copy link
Contributor

Please send a copy of the output of the make step. Does the strace output still look the same? If not, send it as well.

@RajDave-Dev
Copy link
Author

Here is the Recent compilation log:

Applying patch: cnf-configure_func.sh.patch
Applying patch: cnf-configure_path.sh.patch
Applying patch: file-spec-unix.pm.patch
File dist/PathTools/lib/File/Spec/Unix.pm is read-only; trying to patch anyway
Applying patch: no-sudo.patch
File cpan/CPAN/lib/CPAN/FirstTime.pm is read-only; trying to patch anyway
Applying patch: perlio.c.patch
File perlio.c is read-only; trying to patch anyway
Applying patch: setlocale.patch
File locale.c is read-only; trying to patch anyway
Generating config.h and xconfig.h
Extracting config.h (with variable substitutions)
Extracting xconfig.h (with variable substitutions)
Generating Makefile.config

Configuration completed for cross build

      build platform:  x86_64-linux
          C compiler:  gcc
              linker:  gcc
                  ar:  ar
              ranlib:  ranlib
             objdump:  objdump

     target platform:  aarch64-android
          C compiler:  aarch64-linux-android-clang
                  ld:  aarch64-linux-android-clang -Wl,-rpath=/data/data/com.raj.andio/files/usr/lib -Wl,--enable-new-dtags
                  ar:  llvm-ar
              ranlib:  llvm-ranlib
             objdump:  llvm-objdump

              prefix:  /data/data/com.raj.andio/files/usr
             sysroot:  /home/builder/packages/build/_cache/android-r27b-api-29-v1/sysroot
 installation prefix:
         executables:  /data/data/com.raj.andio/files/usr/bin
             scripts:  /data/data/com.raj.andio/files/usr/bin
             privlib:  /data/data/com.raj.andio/files/usr/lib/perl5/5.41.4
             archlib:  /data/data/com.raj.andio/files/usr/lib/perl5/5.41.4/aarch64-android
 section 1 man pages:  /data/data/com.raj.andio/files/usr/share/man/man1  (with '1' extension)
 section 3 man pages:  /data/data/com.raj.andio/files/usr/share/man/man3  (with '3' extension)

make crosspatch
make[1]: Entering directory '/home/builder/packages/build/perl-latest/src'
patch -p1 -i cnf/diffs/perl5-5.41.4/posix-makefile.patch && touch cnf/diffs/perl5-5.41.4/posix-makefile.applied
File ext/POSIX/Makefile.PL is read-only; trying to patch anyway
patching file ext/POSIX/Makefile.PL
patch -p1 -i cnf/diffs/perl5-5.41.4/xconfig.patch && touch cnf/diffs/perl5-5.41.4/xconfig.applied
File perl.h is read-only; trying to patch anyway
patching file perl.h
patching file perl_langinfo.h
Hunk #1 succeeded at 4 with fuzz 2.
File locale.c is read-only; trying to patch anyway
patching file locale.c
patch -p1 -i cnf/diffs/perl5-5.41.4/makemaker.patch && touch cnf/diffs/perl5-5.41.4/makemaker.applied
File cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Unix.pm is read-only; trying to patch anyway
patching file cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Unix.pm
patch -p1 -i cnf/diffs/perl5-5.41.4/constant.patch && touch cnf/diffs/perl5-5.41.4/constant.applied
File cpan/ExtUtils-Constant/t/Constant.t is read-only; trying to patch anyway
patching file cpan/ExtUtils-Constant/t/Constant.t
patch -p1 -i cnf/diffs/perl5-5.41.4/dynaloader.patch && touch cnf/diffs/perl5-5.41.4/dynaloader.applied
File ext/DynaLoader/hints/linux.pl is read-only; trying to patch anyway
patching file ext/DynaLoader/hints/linux.pl
patch -p1 -i cnf/diffs/perl5-5.41.4/test-makemaker.patch && touch cnf/diffs/perl5-5.41.4/test-makemaker.applied
File cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Utils.pm is read-only; trying to patch anyway
patching file cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Utils.pm
patch -p1 -i cnf/diffs/perl5-5.41.4/installscripts.patch && touch cnf/diffs/perl5-5.41.4/installscripts.applied
File installman is read-only; trying to patch anyway
patching file installman
File installperl is read-only; trying to patch anyway
patching file installperl
patch -p1 -i cnf/diffs/perl5-5.41.4/test-checkcase.patch && touch cnf/diffs/perl5-5.41.4/test-checkcase.applied
File t/porting/checkcase.t is read-only; trying to patch anyway
patching file t/porting/checkcase.t
patch -p1 -i cnf/diffs/perl5-5.41.4/liblist.patch && touch cnf/diffs/perl5-5.41.4/liblist.applied
File cpan/ExtUtils-MakeMaker/lib/ExtUtils/Liblist/Kid.pm is read-only; trying to patch anyway
patching file cpan/ExtUtils-MakeMaker/lib/ExtUtils/Liblist/Kid.pm
patch -p1 -i cnf/diffs/perl5-5.41.4/findext.patch && touch cnf/diffs/perl5-5.41.4/findext.applied
File win32/FindExt.pm is read-only; trying to patch anyway
patching file win32/FindExt.pm
make[1]: Leaving directory '/home/builder/packages/build/perl-latest/src'
make miniperl
make[1]: Entering directory '/home/builder/packages/build/perl-latest/src'
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o miniperlmain.host.o miniperlmain.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o av.host.o av.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o scope.host.o scope.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o doop.host.o doop.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o doio.host.o doio.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o dump.host.o dump.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o gv.host.o gv.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o hv.host.o hv.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o mg.host.o mg.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o reentr.host.o reentr.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o mro_core.host.o mro_core.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o perly.host.o perly.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o pp.host.o pp.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o pp_hot.host.o pp_hot.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o pp_ctl.host.o pp_ctl.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o pp_sys.host.o pp_sys.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o regexec.host.o regexec.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o utf8.host.o utf8.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o sv.host.o sv.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o taint.host.o taint.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o toke.host.o toke.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o util.host.o util.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o deb.host.o deb.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o run.host.o run.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o universal.host.o universal.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o pad.host.o pad.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -o generate_uudmap generate_uudmap.c
./generate_uudmap uudmap.h bitcount.h mg_data.h
./generate_uudmap uudmap.h bitcount.h mg_data.h
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o globals.host.o globals.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o keywords.host.o keywords.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o perlio.host.o perlio.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o numeric.host.o numeric.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o mathoms.host.o mathoms.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o locale.host.o locale.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o pp_pack.host.o pp_pack.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o pp_sort.host.o pp_sort.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o caretx.host.o caretx.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o dquote.host.o dquote.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o time64.host.o time64.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o builtin.host.o builtin.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o peep.host.o peep.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o class.host.o class.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o regcomp.host.o regcomp.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o regcomp_debug.host.o regcomp_debug.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o regcomp_invlist.host.o regcomp_invlist.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o regcomp_study.host.o regcomp_study.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o regcomp_trie.host.o regcomp_trie.c
cp -f op.c opmini.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -DPERL_EXTERNAL_GLOB -c -o opmini.host.o opmini.c
cp -f perl.c perlmini.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -DPERL_IS_MINIPERL -c -o perlmini.host.o perlmini.c
gcc  -o miniperl miniperlmain.host.o av.host.o scope.host.o doop.hcomp.c                                                            gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o regcomp_debug.host.o regcomp_debug.c                                                comp.c                                                            gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o regcomp_debug.host.o regcomp_debug.c                                                gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o regcomp_invlist.host.o regcomp_invlist.c                                            gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o regcomp_study.host.o regcomp_study.c                                                gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -c -o regcomp_trie.host.o regcomp_trie.c
cp -f op.c opmini.c
gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -DPERL_EXTERNAL_GLOB -c -o opmini.host.o opmini.c
cp -f perl.c perlmini.c                                           gcc -DPERL_CORE -DUSE_CROSS_COMPILE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fwrapv -fno-strict-aliasing -DPERL_IS_MINIPERL -c -o perlmini.host.o perlmini.c                                       gcc  -o miniperl miniperlmain.host.o av.host.o scope.host.o doop.host.o doio.host.o dump.host.o gv.host.o hv.host.o mg.host.o reentr.host.o mro_core.host.o perly.host.o pp.host.o pp_hot.host.o pp_ctl.host.o pp_sys.host.o regexec.host.o utf8.host.o sv.host.o taint.host.o toke.host.o util.host.o deb.host.o run.host.o universal.host.o pad.host.o globals.host.o keywords.host.o perlio.host.o numeric.host.o mathoms.host.o locale.host.o pp_pack.host.o pp_sort.host.o caretx.host.o dquote.host.o time64.host.o builtin.host.o peep.host.o class.host.o regcomp.host.o regcomp_debug.host.o regcomp_invlist.host.o regcomp_study.host.o regcomp_trie.host.o opmini.host.o perlmini.host.o -lm -lcrypt -ldl                                  make[1]: Leaving directory '/home/builder/packages/build/perl-latest/src'
make dynaloader
make[1]: Entering directory '/home/builder/packages/build/perl-latest/src'
sh cflags.SH
cflags.SH: Adding -std=c99.
cflags.SH: Adding -Werror=pointer-arith.
cflags.SH: Adding -Werror=vla.
cflags.SH: Adding -Wextra.
cflags.SH: Adding -Wno-long-long.
cflags.SH: Adding -Wno-declaration-after-statement.               cflags.SH: Adding -Wc++-compat.                                   cflags.SH: Adding -Wwrite-strings.
cflags.SH: cc       = aarch64-linux-android-clang
cflags.SH: ccflags  = --sysroot=/home/builder/packages/build/_cache/android-r27b-api-29-v1/sysroot  -D__USE_BSD=1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DNO_LOCALE                              cflags.SH: stdflags =  -std=c99
cflags.SH: optimize = -O2
cflags.SH: warn     =  -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wwrite-strings
Extracting cflags (with variable substitutions)
./miniperl_top make_patchnum.pl
make[1]: Leaving directory '/home/builder/packages/build/perl-latest/src'

And config log:
log.txt

Strace:
crash.txt

@bulk88
Copy link
Contributor

bulk88 commented Oct 16, 2024

Can someone copy that /usr/lib/locale/locale-archive file off the phone, and memory map it on a real PC 32b or 64b appropriate, and look at the what are the actual byte offsets of the structs inside?

a hello world .c program compiled with Android SDK, no perl core code, that does offsetof() on all the high priority structs might be needed. and a copy of that locale-archive file.

vague memories from some months ago, Android does not use glibc b/c licensing/IP reasons, and instead uses https://en.wikipedia.org/wiki/Newlib plus since Android is a walled garden or soon to be one (native code/mprotect(EXEC) is deprecated but no hard kill date yet), you need to think twice if you are using a supported API or not

perhaps Google forgot to delete that very popular .so file from Ubuntu and your accidentally linking to an abandoned untested out of date .so

In 2020, poking around inside a App store commercial app, written in C++ compiled for ARM, IDK why this was done, but to call basic POSIX/Ubuntu .so functions, they started the JVM/Dex, load the typedefs of those C structs inside the .so, from their C++ code at runtime, and get back JVM FFI method objects, that they then call, instead of using ELF linking. IDK why that was done, lack of time, lack of correct knowlege devs, App store policy, or somehow the ".so" file in the JVM, through FFI, "works" but direct ELF linking doesn't. So either the .h headers are only meant to be fed into an IDL generater, then fed into the JVM, and some kind of thunking or runtime patching magic is happening in the JVM, vs calling the same functions from the C linker. I didn't research it beyond a few hours back then, but a C++ app, creating Java CB objects, then using Java's FFI, to call back into standard Ubuntu FOSS .so files, unusual and curious.

@khwilliamson
Copy link
Contributor

Your make output you sent is from your build platform; using gcc. I don't understand cross compilation very much. I was given this link, but haven't had a chance to read it yet: https://www.netbsd.org/~sno/talks/nrpm/Cross-Compiling-For-Perl-Hackers.pdf
Your output indicates that miniperl was successfully built.

What I need is the log for the clang build on your android device.

@RajDave-Dev
Copy link
Author

Log while compiling clang or other?
I've clang from llvm so if you need that log I have to compile llvm again. Yeah I have llvm-config if you want that I can provide it

@khwilliamson
Copy link
Contributor

I don't understand. I don't need anything to do with compiling clang itself, which is what I interpret you as asking.

I do need the log of the compilation where clang is being used as the compiler of perl.

@RajDave-Dev
Copy link
Author

Sorry, it will take some days. Because my uncle's child splitted tea over my laptop and service centre told that it will take upto 20 days.

khwilliamson added a commit that referenced this issue Oct 21, 2024
See GH #22627.

Glibc has a few locale categories that aren't used elsewhere, AFAIK.
Android has a crippled implementation of them, in that it has none of
the items that comprise the categories.

In a typical langinfo.h, these are enum fields, so their existence can't
be checked with an #ifdef, but in Android, everything is a #define, so
much be checked with #ifdef.  To get around this without writing a
Configure probe, this commit just creates #defines when they are missing
the category (which catches the non-Androids) or when using Android.
@RajDave-Dev
Copy link
Author

I'm sorry to share that the device I previously mentioned, which unfortunately suffered a tea spill, has experienced a hard drive failure. As a result, I've lost my entire codebase. After careful consideration, I've decided not to pursue developing a similar project in the future.

@jkeenan
Copy link
Contributor

jkeenan commented Dec 23, 2024

I'm sorry to share that the device I previously mentioned, which unfortunately suffered a tea spill, has experienced a hard drive failure. As a result, I've lost my entire codebase. After careful consideration, I've decided not to pursue developing a similar project in the future.

Closing this ticket per OP report. Please open a fresh ticket if you want to start anew. Thank you very much.

@jkeenan jkeenan closed this as completed Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants