@@ -694,21 +694,21 @@ my %defconfig = (
694
694
cosmo_id => ' 9c5a7795add7add5a214afce27d896084e0861c5' ,
695
695
dest => ' perl-small-vista.com' ,
696
696
},
697
- ' full' => { desc => ' moving target: full' , base => ' v5.36.0-full-v0.1.0' , perl_id => ' 45c18985158e73ccd50b82a59117bec67b199f20 ' , cosmo_id => ' eb69a42863ef602a951249b801ceed5f74cbb11c' , ' +perl_extra_flags' => [' -Dprivlib=/zip/lib/perl5' , ' -Darchlib=/zip/lib/perl5/x86_64-cosmo' , ' -Dsitelib=/zip/lib/perl5/site_perl' , ' -Dsitearch=/zip/lib/perl5/site_perl/x86_64-cosmo' ]},
698
- ' full-vista' => { desc => ' moving target: full for vista' , base => ' v5.36.0-full-v0.1.0-vista' , perl_id => ' 45c18985158e73ccd50b82a59117bec67b199f20 ' , ' +perl_extra_flags' => [' -Dprivlib=/zip/lib/perl5' , ' -Darchlib=/zip/lib/perl5/x86_64-cosmo' , ' -Dsitelib=/zip/lib/perl5/site_perl' , ' -Dsitearch=/zip/lib/perl5/site_perl/x86_64-cosmo' ]},
699
- ' small' => { desc => ' moving target: small' , base => ' v5.36.0-small-v0.1.0' , perl_id => ' 45c18985158e73ccd50b82a59117bec67b199f20 ' , cosmo_id => ' eb69a42863ef602a951249b801ceed5f74cbb11c' , ' +perl_extra_flags' => [' -Dprivlib=/zip/lib/perl5' , ' -Darchlib=/zip/lib/perl5/x86_64-cosmo' , ' -Dsitelib=/zip/lib/perl5/site_perl' , ' -Dsitearch=/zip/lib/perl5/site_perl/x86_64-cosmo' ]},
700
- ' small-vista' => { desc => ' moving target: small for vista' , base => ' v5.36.0-small-v0.1.0-vista' , perl_id => ' 45c18985158e73ccd50b82a59117bec67b199f20 ' , ' +perl_extra_flags' => [' -Dprivlib=/zip/lib/perl5' , ' -Darchlib=/zip/lib/perl5/x86_64-cosmo' , ' -Dsitelib=/zip/lib/perl5/site_perl' , ' -Dsitearch=/zip/lib/perl5/site_perl/x86_64-cosmo' ]},
697
+ ' full' => { desc => ' moving target: full' , base => ' v5.36.0-full-v0.1.0' , perl_id => ' ca87f329eeb075c0fe7ac803eb933f36af45a69b ' , cosmo_id => ' eb69a42863ef602a951249b801ceed5f74cbb11c' , ' +perl_extra_flags' => [' -Dprivlib=/zip/lib/perl5' , ' -Darchlib=/zip/lib/perl5/x86_64-cosmo' , ' -Dsitelib=/zip/lib/perl5/site_perl' , ' -Dsitearch=/zip/lib/perl5/site_perl/x86_64-cosmo' ]},
698
+ ' full-vista' => { desc => ' moving target: full for vista' , base => ' v5.36.0-full-v0.1.0-vista' , perl_id => ' ca87f329eeb075c0fe7ac803eb933f36af45a69b ' , ' +perl_extra_flags' => [' -Dprivlib=/zip/lib/perl5' , ' -Darchlib=/zip/lib/perl5/x86_64-cosmo' , ' -Dsitelib=/zip/lib/perl5/site_perl' , ' -Dsitearch=/zip/lib/perl5/site_perl/x86_64-cosmo' ]},
699
+ ' small' => { desc => ' moving target: small' , base => ' v5.36.0-small-v0.1.0' , perl_id => ' ca87f329eeb075c0fe7ac803eb933f36af45a69b ' , cosmo_id => ' eb69a42863ef602a951249b801ceed5f74cbb11c' , ' +perl_extra_flags' => [' -Dprivlib=/zip/lib/perl5' , ' -Darchlib=/zip/lib/perl5/x86_64-cosmo' , ' -Dsitelib=/zip/lib/perl5/site_perl' , ' -Dsitearch=/zip/lib/perl5/site_perl/x86_64-cosmo' ]},
700
+ ' small-vista' => { desc => ' moving target: small for vista' , base => ' v5.36.0-small-v0.1.0-vista' , perl_id => ' ca87f329eeb075c0fe7ac803eb933f36af45a69b ' , ' +perl_extra_flags' => [' -Dprivlib=/zip/lib/perl5' , ' -Darchlib=/zip/lib/perl5/x86_64-cosmo' , ' -Dsitelib=/zip/lib/perl5/site_perl' , ' -Dsitearch=/zip/lib/perl5/site_perl/x86_64-cosmo' ]},
701
701
# development configs
702
702
' dbg' => { base => ' full' , perl_extra_flags => [' -Doptimize=-g3 -gdwarf-4' , ' -de' ], cosmo_mode => ' dbg' , cosmo_id => ' 52f1db7220935cfcf2c8e583678f5ccc4b5bbacd' },
703
703
dontuse_threads => {
704
704
desc => " not recommended, threaded build is buggy" ,
705
- base => ' v5.36.0- full-v0.1.0 ' ,
705
+ base => ' full' ,
706
706
perl_extra_flags => [' -Doptimize=-Os' , ' -Dusethreads' , ' -de' ],
707
707
perl_id => ' cosmo-apperl'
708
708
},
709
709
perl_cosmo_dev => {
710
710
desc => " For developing cosmo platform perl without apperl additions" ,
711
- base => ' v5.36.0- full-v0.1.0 ' ,
711
+ base => ' full' ,
712
712
perl_id => ' cosmo'
713
713
},
714
714
perl_cosmo_dev_on_vista => {
@@ -718,7 +718,7 @@ my %defconfig = (
718
718
},
719
719
perl_apperl_dev => {
720
720
desc => " For developing apperl" ,
721
- base => ' v5.36.0- full-v0.1.0 ' ,
721
+ base => ' full' ,
722
722
perl_id => ' cosmo-apperl'
723
723
}
724
724
}
@@ -899,7 +899,7 @@ sub Set {
899
899
chdir ($SiteConfig -> {perl_repo }) or die " Failed to enter perl repo" ;
900
900
print " make veryclean\n " ;
901
901
system (" make" , " veryclean" );
902
- foreach my $todelete (' miniperl.com' , ' perl.com' , ' miniperl.elf' , ' perl.elf' ) {
902
+ foreach my $todelete (' miniperl.com' , ' perl.com' , ' miniperl.elf' , ' miniperl.com.dbg ' , ' perl.elf' , ' perl.com.dbg ' ) {
903
903
print " rm $todelete \n " ;
904
904
unlink ($todelete ) || $! {ENOENT } or die " failed to delete $todelete " ;
905
905
}
@@ -1061,13 +1061,22 @@ sub Build {
1061
1061
}
1062
1062
1063
1063
# pack
1064
- my $APPNAME = basename($PERL_APE );
1065
- my $APPPATH = " $TEMPDIR /$APPNAME " ;
1064
+ my $APPPATH = " $TEMPDIR /" .basename($PERL_APE );
1066
1065
my $packAPE = sub {
1067
- print " cp $PERL_APE $APPPATH \n " ;
1068
- copy($PERL_APE , $APPPATH ) or die " copy failed: $! " ;
1069
- print " chmod 755 $APPPATH \n " ;
1070
- chmod (0755, $APPPATH ) or die $! ;
1066
+ my $copyexe = sub {
1067
+ my ($srcpath , $destpath ) = @_ ;
1068
+ print " cp $srcpath $destpath \n " ;
1069
+ copy($srcpath , $destpath ) or die " copy failed: $! " ;
1070
+ print " chmod 755 $destpath \n " ;
1071
+ chmod (0755, $destpath ) or die $! ;
1072
+ };
1073
+ $copyexe -> ($PERL_APE , $APPPATH );
1074
+ my $srcdbg = " $PERL_APE .dbg" ;
1075
+ if (! -f $srcdbg ) {
1076
+ $srcdbg = $PERL_APE ;
1077
+ $srcdbg =~ s / com$/ elf/ ;
1078
+ }
1079
+ $copyexe -> ($srcdbg , " $APPPATH .dbg" );
1071
1080
if ((! exists $UserProjectConfig -> {nobuild_perl_bin }) || scalar (keys %{$itemconfig -> {zip_extra_files }})) {
1072
1081
print " cd $ZIP_ROOT \n " ;
1073
1082
chdir ($ZIP_ROOT ) or die " failed to enter ziproot" ;
@@ -1076,7 +1085,6 @@ sub Build {
1076
1085
};
1077
1086
$packAPE -> ();
1078
1087
1079
-
1080
1088
# install modules
1081
1089
if (exists $itemconfig -> {install_modules }) {
1082
1090
my $perlman1 = " $TEMPDIR$proxyConfig {installman1dir}" ;
@@ -1085,7 +1093,7 @@ sub Build {
1085
1093
my $perllib = " $TEMPDIR$proxyConfig {installprivlib}" ;
1086
1094
my $perlarchlib = " $TEMPDIR$proxyConfig {installarchlib}" ;
1087
1095
my $mmopt = sub {
1088
- my @mmopt = (" PERL_LIB=$perllib " , " PERL_ARCHLIB=$perlarchlib " , " MAP_TARGET=perl.elf " ,
1096
+ my @mmopt = (" PERL_LIB=$perllib " , " PERL_ARCHLIB=$perlarchlib " , " MAP_TARGET=perl.com.dbg " ,
1089
1097
" INSTALLDIRS=perl" ,
1090
1098
" INSTALLARCHLIB=$perlarchlib " ,
1091
1099
" INSTALLPRIVLIB=$perllib " ,
@@ -1151,8 +1159,8 @@ sub Build {
1151
1159
# install into the src tree
1152
1160
_command_or_die(' make' , ' install' );
1153
1161
# build a new perl binary, convert to APE, and repack zip
1154
- _command_or_die(' make' , ' perl.elf ' );
1155
- _command_or_die(dirname($proxyConfig {cc })." /x86_64-linux-musl-objcopy" , ' -S' , ' -O' , ' binary' , ' perl.elf ' , ' perl.com' );
1162
+ _command_or_die(' make' , ' perl.com.dbg ' );
1163
+ _command_or_die(dirname($proxyConfig {cc })." /x86_64-linux-musl-objcopy" , ' -S' , ' -O' , ' binary' , ' perl.com.dbg ' , ' perl.com' );
1156
1164
$PERL_APE = abs_path(' ./perl.com' );
1157
1165
}
1158
1166
else {
@@ -1178,16 +1186,24 @@ sub Build {
1178
1186
close ($fh );
1179
1187
}
1180
1188
1181
- print " mv $APPPATH $OUTPUTDIR /perl.com\n " ;
1182
- move($APPPATH , " $OUTPUTDIR /perl.com" ) or die " move failed: $! " ;
1189
+ foreach my $file (' perl.com' , ' perl.com.dbg' ) {
1190
+ my $srcpath = " $TEMPDIR /$file " ;
1191
+ my $destpath = " $OUTPUTDIR /$file " ;
1192
+ print " mv $srcpath $destpath \n " ;
1193
+ move($srcpath , $destpath ) or die " move failed: $! " ;
1194
+ }
1183
1195
1184
1196
# copy to user specified location
1185
1197
if (exists $itemconfig -> {dest }) {
1186
1198
print " cd " .START_WD." \n " ;
1187
1199
chdir (START_WD) or die " Failed to restore cwd" ;
1188
- my @args = (" $UserProjectConfig ->{apperl_output}/$CurAPPerlName /perl.com" , $itemconfig -> {dest });
1189
- print ' cp ' .join (' ' , @args )." \n " ;
1190
- cp(@args ) or die " copy failed: $! " ;
1200
+ foreach my $srcfile (' perl.com' , ' perl.com.dbg' ) {
1201
+ my $destfile = $itemconfig -> {dest };
1202
+ $destfile .= ' .dbg' if ($srcfile =~ / dbg$ / );
1203
+ my @args = (" $UserProjectConfig ->{apperl_output}/$CurAPPerlName /$srcfile " , $destfile );
1204
+ print ' cp ' .join (' ' , @args )." \n " ;
1205
+ cp(@args ) or die " copy failed: $! " ;
1206
+ }
1191
1207
}
1192
1208
}
1193
1209
@@ -1847,7 +1863,7 @@ to be able to build and install them into your APPerl. It supports
1847
1863
folder paths and paths to tarballs such as the one's directly
1848
1864
downloaded from CPAN.
1849
1865
1850
- For example to install L <Geo::Calc:XS> , download its tarball from CPAN
1866
+ For example to install B <Geo::Calc:XS > , download its tarball from CPAN
1851
1867
and add to to my_src_build_config in apperl-project.json:
1852
1868
1853
1869
"install_modules" : ["Geo-Calc-XS-0.33.tar.gz"]
@@ -1937,6 +1953,26 @@ Build and test it.
1937
1953
apperlm build
1938
1954
./helloext.com
1939
1955
1956
+ =head1 DEBUGGING
1957
+
1958
+ APPerl binaries as with other Actually Portable Executables built with
1959
+ the Cosmopolitan Libc have some nice debug features:
1960
+
1961
+ Syscall logging can be performed just by running with C<--strace > as
1962
+ the first argument:
1963
+
1964
+ ./perl.com --strace /zip/bin/perldoc perlcosmo
1965
+
1966
+ Function call logging can be performed if you have the accompanying
1967
+ C<.com.dbg > file in the same directory as your APPerl binary:
1968
+
1969
+ ./perl.com --ftrace /zip/bin/perldoc perlcosmo
1970
+
1971
+ In theory, it should be possible to use C<gdb > with APPerl binaries,
1972
+ but the author has had great difficulty getting this to work. The
1973
+ C<dbg > APPerl config is available to build Cosmopolitan with C<MODE=dbg >
1974
+ and Perl with C<-Doptimize=-g3 -gdwarf-4 > .
1975
+
1940
1976
=head1 SUPPORT AND DOCUMENTATION
1941
1977
1942
1978
APPerl web page: L<https://computoid.com/APPerl/>
0 commit comments