dslm4515 / Musl-LFS

Linux From Scratch using Musl as Libc
GNU General Public License v3.0
170 stars 21 forks source link

Perl 5.34.0 Fails to Build for toolchain #47

Open dslm4515 opened 3 years ago

dslm4515 commented 3 years ago

Perl-5.34.0 configures fine after unpacking perl-cross-1.3.6 over it, but build segfaults:

make[1]: Leaving directory '/mnt/mlfs/sources/perl-5.34.0'                                                                                      
make dynaloader                                                                                                                                 
make[1]: Entering directory '/mnt/mlfs/sources/perl-5.34.0'                                                                                     
sh cflags.SH                                                                                                                                    
./miniperl_top make_patchnum.pl                                                                                                                 
cp -f ext/re/re.pm lib/re.pm                                                                                                                    
cp -f dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp lib/ExtUtils/xsubpp                                                                             
Updating 'git_version.h' and 'lib/Config_git.pl'                                                                                                cflags.SH: Adding -Werror=pointer-arith.                                                                                                        
cflags.SH: Adding -Wextra.                                                                                                                      
cflags.SH: Adding -Wc++-compat.                                                                                                                 
cflags.SH: Adding -Wwrite-strings.                                                                                                              
cflags.SH: Adding -Werror=declaration-after-statement.                                                                                          
cflags.SH: cc       = x86_64-mlfs-linux-musl-gcc                                                                                                
cflags.SH: ccflags  = -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64                                                                                
cflags.SH: stdflags =                                                                                                                           
cflags.SH: optimize = -fwrapv -fno-strict-aliasing                                                                                              
cflags.SH: warn     =  -Wall -Werror=pointer-arith -Wextra -Wc++-compat -Wwrite-strings -Werror=declaration-after-statement                     
Extracting cflags (with variable substitutions)
./miniperl_top configpm
make[1]: *** [Makefile:207: lib/Config.pm] Segmentation fault
make[1]: Leaving directory '/mnt/mlfs/sources/perl-5.34.0'
make: *** [Makefile:80: all] Error 2 

kernel log shows:

miniperl[29079]: segfault at 57343900 ip 00000000005794f5 sp 00007ffefe3ed200 error 4 in miniperl[405000+2cd000]
Code: 40 01 0f b6 c0 89 85 34 ff ff ff c7 85 e4 fe ff ff 00 00 00 00 48 8b 85 c8 f9 ff ff 48 8b 40 10 48 39 45 88 73 0c 48 8b 45 88 <0f> b6 00 0f b6 c0 eb 05 b8 f6 ff ff ff 89 85 64 ff ff ff 81 bd 34
dslm4515 commented 3 years ago

If I use perl-5.32.0 & perl-cross-1.3.4 instead, build completes without error.

dslm4515 commented 3 years ago

Tried perl-5.35.0 with perl-cross-1.3.6 ... also segfaults like perl-5.34.0

dslm4515 commented 3 years ago

Perl-5.32.1 & perl-cross-1.3.5 compiles fine.

Looks like a change after 5.32.1 breaks under musl.

dslm4515 commented 3 years ago

Perl 5.34.0 compiles fine in chroot. For now, perl-5.32.1 with perl-cross-1.3.6 can be built for the toolchain and perl-5.34.0 can be built during chroot (final/target system). Could be an issue with perl-cross

dslm4515 commented 2 years ago

Attempted to try perl-cross(commit b1b85b6) with perl 5.35.1:

make crosspatch
make[1]: Entering directory '/mnt/oml/sources/perl-5.35.1'
make[1]: Nothing to be done for 'crosspatch'.
make[1]: Leaving directory '/mnt/oml/sources/perl-5.35.1'
make miniperl
make[1]: Entering directory '/mnt/oml/sources/perl-5.35.1'
make[1]: 'miniperl' is up to date.
make[1]: Leaving directory '/mnt/oml/sources/perl-5.35.1'
make dynaloader
make[1]: Entering directory '/mnt/oml/sources/perl-5.35.1'
./miniperl_top configpm
Use of uninitialized value $t in string eq at configpm line 345.
Use of uninitialized value $s in numeric eq (==) at configpm line 345.
Use of uninitialized value $s in numeric eq (==) at configpm line 348.
Use of uninitialized value $s in numeric eq (==) at configpm line 348.
Use of uninitialized value $s in concatenation (.) or string at configpm line 358.
Use of uninitialized value in pattern match (m//) at configpm line 428.
Use of uninitialized value $osname in string eq at configpm line 461.
Use of uninitialized value $osname in string eq at configpm line 462.
Use of uninitialized value $osname in sprintf at configpm line 465.
Use of uninitialized value $osname in sprintf at configpm line 465.
Use of uninitialized value $osname in sprintf at configpm line 465.
written lib/Config.pod
updated lib/Config.pm
updated lib/Config_heavy.pl
syntax error at lib/Config_heavy.pl line 1458, near "x;"
Compilation failed in require at configpm line 1144.
make[1]: *** [Makefile:207: lib/Config.pm] Error 255
make[1]: Leaving directory '/mnt/oml/sources/perl-5.35.1'
make: *** [Makefile:80: all] Error 2
dslm4515 commented 2 years ago

Looking at 'synatx error' of lib/Config_heavy.pl line 1458 ... looks different when compared to a 5.32.1 build:

version='5.35.1'
version_patchlevel_string='version 35 subversion 1'
versiononly='undef'
vi=''
xlibpth=''
yacc='yacc'
yaccflags=''
zcat=''
zip='zip'
!END!
our $byteorder = '?'x;
s/(byteorder=)(['"]).*?\2/$1$2$Config::byteorder$2/m;

my $config_sh_len = length $_;

our $Config_SH_expanded = "\n$_" . << 'EOVIRTUAL';
ccwarnflags=' -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wc++-compat -Wwrite-strings -Werror=declaration-after-statement'
EOVIRTUAL
eval {
        # do not have hairy conniptions if this isnt available
        require 'Config_git.pl';
        $Config_SH_expanded .= $Config::Git_Data;
        1;
} or warn "Warning: failed to load Config_git.pl, something strange about this perl...\n";
dslm4515 commented 2 years ago

If restart the build... copy perl-cross over perl-5.35.1 source, then configure perl-5.35.1 source, and only do:

make miniperl

Build fails on make dynaloader.

Quickly built perl-5.32.1 and copied it's miniperl to perl-5.35.1 source tree... now make dynaloader succeeds. But if i do make then build still fails with a segfault:

Generating a Unix-style Makefile
Writing Makefile for Unicode::Collate
cd dist/threads-shared/ && ../../miniperl_top -I../../lib Makefile.PL \
 INSTALLDIRS=perl INSTALLMAN1DIR=none INSTALLMAN3DIR=none \
 PERL_CORE=1 LIBPERL_A=libperl.a PERL="../../miniperl_top"
Generating a Unix-style Makefile
Writing Makefile for threads
./miniperl_top autodoc.pl
make[1]: *** [Makefile:383: pod/perlintern.pod] Segmentation fault
make[1]: *** Waiting for unfinished jobs....
Generating a Unix-style Makefile
Writing Makefile for threads::shared
make[1]: Leaving directory '/mnt/oml/sources/perl-5.35.1'
make: *** [Makefile:81: all] Error 2
oml:/mnt/oml/sources/perl-5.35.1
dslm4515 commented 2 years ago

make target order:

Copied miniperl and miniperl_top from perl-5.32.1 after building miniperl... in hopes to avoid segfault

dslm4515 commented 2 years ago

Looks like an issue with how miniperl and miniperl_top is cross-compiled

dslm4515 commented 2 months ago

I may update build method to build only enough of /tools to enter a chroot and finish the rest of toolchain under chroot... just like in CMLFS ... this would avoid cross-compiling perl.