ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/App-Staticperl/staticperl.pod
(Generate patch)

Comparing App-Staticperl/staticperl.pod (file contents):
Revision 1.45 by root, Mon Jun 27 21:56:51 2011 UTC vs.
Revision 1.53 by root, Wed Jan 11 19:20:57 2012 UTC

1=head1 NAME 1=head1 NAME
2 2
3staticperl - perl, libc, 100 modules, all in one 500kb file 3staticperl - perl, libc, 100 modules, all in one standalone 500kb file
4 4
5=head1 SYNOPSIS 5=head1 SYNOPSIS
6 6
7 staticperl help # print the embedded documentation 7 staticperl help # print the embedded documentation
8 staticperl fetch # fetch and unpack perl sources 8 staticperl fetch # fetch and unpack perl sources
11 staticperl install # build and then install perl 11 staticperl install # build and then install perl
12 staticperl clean # clean most intermediate files (restart at configure) 12 staticperl clean # clean most intermediate files (restart at configure)
13 staticperl distclean # delete everything installed by this script 13 staticperl distclean # delete everything installed by this script
14 staticperl perl ... # invoke the perlinterpreter 14 staticperl perl ... # invoke the perlinterpreter
15 staticperl cpan # invoke CPAN shell 15 staticperl cpan # invoke CPAN shell
16 staticperl instmod path... # install unpacked modules 16 staticperl instsrc path... # install unpacked modules
17 staticperl instcpan modulename... # install modules from CPAN 17 staticperl instcpan modulename... # install modules from CPAN
18 staticperl mkbundle <bundle-args...> # see documentation 18 staticperl mkbundle <bundle-args...> # see documentation
19 staticperl mkperl <bundle-args...> # see documentation 19 staticperl mkperl <bundle-args...> # see documentation
20 staticperl mkapp appname <bundle-args...> # see documentation 20 staticperl mkapp appname <bundle-args...> # see documentation
21 21
84With F<staticperl>, the burden is mostly with the developer - only direct 84With F<staticperl>, the burden is mostly with the developer - only direct
85compile-time dependencies and L<AutoLoader> are handled automatically. 85compile-time dependencies and L<AutoLoader> are handled automatically.
86This means the modules to include often need to be tweaked manually. 86This means the modules to include often need to be tweaked manually.
87 87
88All this does not preclude more permissive modes to be implemented in 88All this does not preclude more permissive modes to be implemented in
89the future, but right now, you have to resolve state hidden dependencies 89the future, but right now, you have to resolve hidden dependencies
90manually. 90manually.
91 91
92=item * PAR works out of the box, F<staticperl> does not. 92=item * PAR works out of the box, F<staticperl> does not.
93 93
94Maintaining your own custom perl build can be a pain in the ass, and while 94Maintaining your own custom perl build can be a pain in the ass, and while
202=item F<staticperl cpan> [args...] 202=item F<staticperl cpan> [args...]
203 203
204Starts an interactive CPAN shell that you can use to install further 204Starts an interactive CPAN shell that you can use to install further
205modules. Installs the perl first if necessary, but apart from that, 205modules. Installs the perl first if necessary, but apart from that,
206no magic is involved: you could just as well run it manually via 206no magic is involved: you could just as well run it manually via
207F<~/.staticperl/perl/bin/cpan>. 207F<~/.staticperl/perl/bin/cpan>, except that F<staticperl> additionally
208sets the environment variable C<$PERL> to the path of the perl
209interpreter, which is handy in subshells.
208 210
209Any additional arguments are simply passed to the F<cpan> command. 211Any additional arguments are simply passed to the F<cpan> command.
210 212
211=item F<staticperl instcpan> module... 213=item F<staticperl instcpan> module...
212 214
547 549
548Just like C<--add>, except that it treats the file as binary and adds it 550Just like C<--add>, except that it treats the file as binary and adds it
549without any postprocessing (perl files might get stripped to reduce their 551without any postprocessing (perl files might get stripped to reduce their
550size). 552size).
551 553
552If you specify an alias you should probably add a C<&> prefix to avoid 554If you specify an alias you should probably add a C</> prefix to avoid
553clashing with embedded perl files (whose paths never start with C<&>), 555clashing with embedded perl files (whose paths never start with C</>),
554and/or use a special directory prefix, such as C<&res/name>. 556and/or use a special directory prefix, such as C</res/name>.
555 557
556You can later get a copy of these files by calling C<staticperl::find 558You can later get a copy of these files by calling C<static::find
557"alias">. 559"alias">.
558 560
559An alternative way to embed binary files is to convert them to perl and 561An alternative way to embed binary files is to convert them to perl and
560use C<do> to get the contents - this method is a bit cumbersome, but works 562use C<do> to get the contents - this method is a bit cumbersome, but works
561both inside and outside of a staticperl bundle: 563both inside and outside of a staticperl bundle, without extra ado:
562 564
563 # a "binary" file, call it "bindata.pl" 565 # a "binary" file, call it "bindata.pl"
564 <<'SOME_MARKER' 566 <<'SOME_MARKER'
565 binary data NOT containing SOME_MARKER 567 binary data NOT containing SOME_MARKER
566 SOME_MARKER 568 SOME_MARKER
567 569
568 # load the binary 570 # load the binary
569 chomp (my $data = do "bindata.pl"); 571 chomp (my $data = do "bindata.pl");
572
573=item C<--allow-dynamic>
574
575By default, when F<mkbundle> hits a dynamic perl extension (e.g. a F<.so>
576or F<.dll> file), it will stop with a fatal error.
577
578When this option is enabled, F<mkbundle> packages the shared
579object into the bundle instead, with a prefix of F<!>
580(e.g. F<!auto/List/Util/Util.so>). What you do with that is currently up
581to you, F<staticperl> has no special support for this at the moment, apart
582from working around the lack of availability of F<PerlIO::scalar> while
583bootstrapping, at a speed cost.
584
585One way to deal with this is to write all files starting with F<!> into
586some directory and then C<unshift> that path onto C<@INC>.
587
588#TODO: example
570 589
571=back 590=back
572 591
573=item Step 2: filter all files using C<--include> and C<--exclude> options. 592=item Step 2: filter all files using C<--include> and C<--exclude> options.
574 593
733standalone applications, and this option removes those known to cause 752standalone applications, and this option removes those known to cause
734trouble. 753trouble.
735 754
736Specifically, these are removed: 755Specifically, these are removed:
737 756
738C<PERL_HASH_SEED_DEBUG> and C<PERL_DEBUG_MSTATS> can cause underaible 757C<PERL_HASH_SEED_DEBUG> and C<PERL_DEBUG_MSTATS> can cause undesirable
739output, C<PERL5OPT>, C<PERL_DESTRUCT_LEVEL>, C<PERL_HASH_SEED> and 758output, C<PERL5OPT>, C<PERL_DESTRUCT_LEVEL>, C<PERL_HASH_SEED> and
740C<PERL_SIGNALS> can alter execution significantly, and C<PERL_UNICODE>, 759C<PERL_SIGNALS> can alter execution significantly, and C<PERL_UNICODE>,
741C<PERLIO_DEBUG> and C<PERLIO> can affect input and output. 760C<PERLIO_DEBUG> and C<PERLIO> can affect input and output.
742 761
743The variables C<PERL_LIB> and C<PERL5_LIB> are always ignored because the 762The variables C<PERL_LIB> and C<PERL5_LIB> are always ignored because the
930F<~/.staticperlrc> to override them. 949F<~/.staticperlrc> to override them.
931 950
932Most of the variables override (or modify) the corresponding F<Configure> 951Most of the variables override (or modify) the corresponding F<Configure>
933variable, except C<PERL_CCFLAGS>, which gets appended. 952variable, except C<PERL_CCFLAGS>, which gets appended.
934 953
935You should have a look near the beginning of the F<staticperl> script - 954The default for C<PERL_OPTIMIZE> is C<-Os> (assuming gcc), and for
936staticperl tries to default C<PERL_OPTIMIZE> to some psace-saving options 955C<PERL_LIBS> is C<-lm -lcrypt>, which should be good for most (but not
937suitable for newer gcc versions. For other compilers or older versions you 956all) systems.
957
958For other compilers or more customised optimisation settings, you need to
938need to adjust these, for example, in your F<~/.staticperlrc>. 959adjust these, e.g. in your F<~/.staticperlrc>.
960
961With gcc on x86 and amd64, you can get more space-savings by using:
962
963 -Os -ffunction-sections -fdata-sections -finline-limit=8 -mpush-args
964 -mno-inline-stringops-dynamically -mno-align-stringops
965
966And on x86 and pentium3 and newer (basically everything you might ever
967want to run on), adding these is even better for space-savings (use
968-mtune=core2 or something newer for much faster code, too):
969
970 -fomit-frame-pointer -march=pentium3 -mtune=i386
939 971
940=back 972=back
941 973
942=head4 Variables you probably I<do not want> to override 974=head4 Variables you probably I<do not want> to override
943 975
1122 1154
1123=back 1155=back
1124 1156
1125=head1 RUNTIME FUNCTIONALITY 1157=head1 RUNTIME FUNCTIONALITY
1126 1158
1127Binaries created with C<mkbundle>/C<mkperl> contain extra functions, which 1159Binaries created with C<mkbundle>/C<mkperl> contain extra functionality,
1128are required to access the bundled perl sources, but might be useful for 1160mostly related to the extra files bundled in the binary (the virtual
1129other purposes. 1161filesystem). All of this data is statically compiled into the binary, and
1162accessing means copying it from a read-only section of your binary. Data
1163pages in this way is usually freed by the operating system, as it isn't
1164use more the onace.
1165
1166=head2 VIRTUAL FILESYSTEM
1167
1168Every bundle has a virtual filesystem. The only information stored in it
1169is the path and contents of each file that was bundled.
1170
1171=head3 LAYOUT
1172
1173Any path starting with an ampersand (F<&>) or exclamation mark (F<!>) are
1174reserved by F<staticperl>. They must only be used as described in this
1175section.
1176
1177=over 4
1178
1179=item !
1180
1181All files that typically cannot be loaded from memory (such as dynamic
1182objects or shared libraries), but have to reside in the filesystem, are
1183prefixed with F<!>. Typically these files get written out to some
1184(semi-)temporary directory shortly after program startup, or before being
1185used.
1186
1187=item !boot
1188
1189The bootstrap file, if specified during bundling.
1190
1191=item !auto/
1192
1193Shared objects or dlls corresponding to dynamically-linked perl extensions
1194are stored with an F<!auto/> prefix.
1195
1196=item !lib/
1197
1198External shared libraries are stored in this directory.
1199
1200=item any letter
1201
1202Any path starting with a letter is a perl library file. For example,
1203F<Coro/AIO.pm> corresponds to the file loaded by C<use Coro::AIO>, and
1204F<Coro/jit.pl> corresponds to C<require "Coro/jit.pl">.
1205
1206Obviously, module names shouldn't start with any other characters than
1207letters :)
1208
1209=back
1210
1211=head3 FUNCTIONS
1212
1213=over 4
1214
1215=item $file = static::find $path
1216
1217Returns the data associated with the given C<$path>
1218(e.g. C<Digest/MD5.pm>, C<auto/POSIX/autosplit.ix>).
1219
1220Returns C<undef> if the file isn't embedded.
1221
1222=item @paths = static::list
1223
1224Returns the list of all paths embedded in this binary.
1225
1226=back
1227
1228=head2 EXTRA FEATURES
1130 1229
1131In addition, for the embedded loading of perl files to work, F<staticperl> 1230In addition, for the embedded loading of perl files to work, F<staticperl>
1132overrides the C<@INC> array. 1231overrides the C<@INC> array.
1133
1134=over 4
1135
1136=item $file = staticperl::find $path
1137
1138Returns the data associated with the given C<$path>
1139(e.g. C<Digest/MD5.pm>, C<auto/POSIX/autosplit.ix>), which is basically
1140the UNIX path relative to the perl library directory.
1141
1142Returns C<undef> if the file isn't embedded.
1143
1144=item @paths = staticperl::list
1145
1146Returns the list of all paths embedded in this binary.
1147
1148=back
1149 1232
1150=head1 FULLY STATIC BINARIES - UCLIBC AND BUILDROOT 1233=head1 FULLY STATIC BINARIES - UCLIBC AND BUILDROOT
1151 1234
1152To make truly static (Linux-) libraries, you might want to have a look at 1235To make truly static (Linux-) libraries, you might want to have a look at
1153buildroot (L<http://buildroot.uclibc.org/>). 1236buildroot (L<http://buildroot.uclibc.org/>).

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines