Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.93k stars 552 forks source link

Cpan install failed on Android. #22627

Open RajDave-Dev opened 2 weeks ago

RajDave-Dev commented 2 weeks ago

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 commented 2 weeks ago

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:

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

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

RajDave-Dev commented 2 weeks ago
  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 commented 2 weeks ago

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

Leont commented 2 weeks ago

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 commented 2 weeks ago

How can we disable it?

Leont commented 2 weeks ago

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 commented 2 weeks ago

Okay, I'll try it as well

RajDave-Dev commented 2 weeks ago

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 commented 2 weeks ago

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 3c45ca2e154f5fdc7ce2a0fdf51b192da3a1ae98 needs some refinement.

khwilliamson commented 2 weeks ago

On 9/29/24 04:09, Leon Timmermans wrote:

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 https://github.com/khwilliamson is better equipped to answer that question. I guess 3c45ca2 https://github.com/Perl/perl5/commit/3c45ca2e154f5fdc7ce2a0fdf51b192da3a1ae98 needs some refinement.

Those symbols if not available on the system are defined in perl_langinfo.h, which is included unconditionally in perl.h

I recall that Android's locale implementation was crippled, though that was a long time ago.

For the time being, to get you going sooner and avoid likely other locale-related issues,I suggest adding the following to your Configure options

-Accflags='-DNO_LOCALE'

You could generate a locale.i and send it to me, and/or look for a langinfo.h system hdr and send it to me

— Reply to this email directly, view it on GitHub https://github.com/Perl/perl5/issues/22627#issuecomment-2381295213, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2DH34JAX3ADAXWTZTTVTZY7GWLAVCNFSM6AAAAABO7JWKU6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBRGI4TKMRRGM. You are receiving this because you were mentioned.Message ID: @.***>

RajDave-Dev commented 2 weeks ago

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 commented 2 weeks ago

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

khwilliamson commented 1 week ago

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 commented 1 week ago

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 commented 1 week ago

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

khwilliamson commented 1 week ago

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

RajDave-Dev commented 1 week ago

Okay. Here it is: config.txt

Renamed this file from config.h to .txt

khwilliamson commented 1 week ago

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 commented 1 week ago

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

RajDave-Dev commented 1 week ago

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 commented 1 week ago

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 commented 1 week ago

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 commented 1 week ago

Try applying this patch setlocale.txt

RajDave-Dev commented 1 week ago

Still same error

khwilliamson commented 1 week ago

Is the strace the same?

RajDave-Dev commented 1 week ago

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 commented 6 days ago

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 commented 6 days ago

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 commented 5 days ago

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 commented 5 days ago

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 commented 4 days ago

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 commented 4 days ago

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 commented 4 days ago

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 commented 4 days ago

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 commented 4 days ago

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 https://github.com/Perl/perl5/issues/22627#issuecomment-2390376575

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

RajDave-Dev commented 4 days ago

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

I was referring to this error https://github.com/Perl/perl5/issues/22627#issuecomment-2381104160 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 commented 3 days ago

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

RajDave-Dev commented 2 days ago

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 commented 2 days ago

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 commented 22 hours ago

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 commented 22 hours ago

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