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.41 by root, Thu May 19 18:58:19 2011 UTC vs.
Revision 1.51 by root, Mon Jul 18 07:34:48 2011 UTC

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
882=item C<STATICPERL> 901=item C<STATICPERL>
883 902
884The directory where staticperl stores all its files 903The directory where staticperl stores all its files
885(default: F<~/.staticperl>). 904(default: F<~/.staticperl>).
886 905
887=item C<PERL_MM_USE_DEFAULT>, C<EV_EXTRA_DEFS>, ... 906=item C<DLCACHE>
888 907
889Usually set to C<1> to make modules "less inquisitive" during their 908The path to a directory (will be created if it doesn't exist) where
890installation, you can set any environment variable you want - some modules 909downloaded perl sources are being cached, to avoid downloading them
891(such as L<Coro> or L<EV>) use environment variables for further tweaking. 910again. The default is empty, which means there is no cache.
892 911
893=item C<PERL_VERSION> 912=item C<PERL_VERSION>
894 913
895The perl version to install - default is currently C<5.12.3>, but C<5.8.9> 914The perl version to install - default is currently C<5.12.3>, but C<5.8.9>
896is also a good choice (5.8.9 is much smaller than 5.12.3, while 5.10.1 is 915is also a good choice (5.8.9 is much smaller than 5.12.3, while 5.10.1 is
897about as big as 5.12.3). 916about as big as 5.12.3).
917
918=item C<PERL_MM_USE_DEFAULT>, C<EV_EXTRA_DEFS>, ...
919
920Usually set to C<1> to make modules "less inquisitive" during their
921installation. You can set (and export!) any environment variable you want
922- some modules (such as L<Coro> or L<EV>) use environment variables for
923further tweaking.
898 924
899=item C<PERL_PREFIX> 925=item C<PERL_PREFIX>
900 926
901The prefix where perl gets installed (default: F<$STATICPERL/perl>), 927The prefix where perl gets installed (default: F<$STATICPERL/perl>),
902i.e. where the F<bin> and F<lib> subdirectories will end up. 928i.e. where the F<bin> and F<lib> subdirectories will end up.
923F<~/.staticperlrc> to override them. 949F<~/.staticperlrc> to override them.
924 950
925Most of the variables override (or modify) the corresponding F<Configure> 951Most of the variables override (or modify) the corresponding F<Configure>
926variable, except C<PERL_CCFLAGS>, which gets appended. 952variable, except C<PERL_CCFLAGS>, which gets appended.
927 953
928You 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
929staticperl 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
930suitable 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
931need 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
932 971
933=back 972=back
934 973
935=head4 Variables you probably I<do not want> to override 974=head4 Variables you probably I<do not want> to override
936 975
1115 1154
1116=back 1155=back
1117 1156
1118=head1 RUNTIME FUNCTIONALITY 1157=head1 RUNTIME FUNCTIONALITY
1119 1158
1120Binaries created with C<mkbundle>/C<mkperl> contain extra functions, which 1159Binaries created with C<mkbundle>/C<mkperl> contain extra functionality,
1121are required to access the bundled perl sources, but might be useful for 1160mostly related to the extra files bundled in the binary (the virtual
1122other 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
1123 1229
1124In 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>
1125overrides the C<@INC> array. 1231overrides the C<@INC> array.
1126
1127=over 4
1128
1129=item $file = staticperl::find $path
1130
1131Returns the data associated with the given C<$path>
1132(e.g. C<Digest/MD5.pm>, C<auto/POSIX/autosplit.ix>), which is basically
1133the UNIX path relative to the perl library directory.
1134
1135Returns C<undef> if the file isn't embedded.
1136
1137=item @paths = staticperl::list
1138
1139Returns the list of all paths embedded in this binary.
1140
1141=back
1142 1232
1143=head1 FULLY STATIC BINARIES - UCLIBC AND BUILDROOT 1233=head1 FULLY STATIC BINARIES - UCLIBC AND BUILDROOT
1144 1234
1145To 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
1146buildroot (L<http://buildroot.uclibc.org/>). 1236buildroot (L<http://buildroot.uclibc.org/>).
1167twice the address space needed for stacks). 1257twice the address space needed for stacks).
1168 1258
1169If you use C<linuxthreads.old>, then you should also be aware that 1259If you use C<linuxthreads.old>, then you should also be aware that
1170uClibc shares C<errno> between all threads when statically linking. See 1260uClibc shares C<errno> between all threads when statically linking. See
1171L<http://lists.uclibc.org/pipermail/uclibc/2010-June/044157.html> for a 1261L<http://lists.uclibc.org/pipermail/uclibc/2010-June/044157.html> for a
1172workaround (And L<https://bugs.uclibc.org/2089> for discussion). 1262workaround (and L<https://bugs.uclibc.org/2089> for discussion).
1173 1263
1174C<ccache> support is also recommended, especially if you want 1264C<ccache> support is also recommended, especially if you want
1175to play around with buildroot options. Enabling the C<miniperl> 1265to play around with buildroot options. Enabling the C<miniperl>
1176package will probably enable all options required for a successful 1266package will probably enable all options required for a successful
1177perl build. F<staticperl> itself additionally needs either C<wget> 1267perl build. F<staticperl> itself additionally needs either C<wget>
1185it from working properly in a chroot - either use dash (and link it to 1275it from working properly in a chroot - either use dash (and link it to
1186F</bin/sh> inside the chroot) or link busybox to F</bin/sh>, using it's 1276F</bin/sh> inside the chroot) or link busybox to F</bin/sh>, using it's
1187built-in ash shell. 1277built-in ash shell.
1188 1278
1189Finally, you need F</dev/null> inside the chroot for many scripts to work 1279Finally, you need F</dev/null> inside the chroot for many scripts to work
1190- F<cp /dev/null output/target/dev> or bind-mounting your F</dev> will 1280- either F<cp /dev/null output/target/dev> or bind-mounting your F</dev>
1191both provide this. 1281will provide this.
1192 1282
1193After you have compiled and set up your buildroot target, you can copy 1283After you have compiled and set up your buildroot target, you can copy
1194F<staticperl> from the C<App::Staticperl> distribution or from your 1284F<staticperl> from the C<App::Staticperl> distribution or from your
1195perl f<bin> directory (if you installed it) into the F<output/target> 1285perl F<bin> directory (if you installed it) into the F<output/target>
1196filesystem, chroot inside and run it. 1286filesystem, chroot inside and run it.
1197 1287
1198=head1 RECIPES / SPECIFIC MODULES 1288=head1 RECIPES / SPECIFIC MODULES
1199 1289
1200This section contains some common(?) recipes and information about 1290This section contains some common(?) recipes and information about

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines