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.49 by root, Wed Jul 13 15:23:13 2011 UTC vs.
Revision 1.64 by root, Thu Mar 21 16:41:36 2019 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
348 add eg/httpd httpd.pm 348 add eg/httpd httpd.pm
349 349
350All options that specify modules or files to be added are processed in the 350All options that specify modules or files to be added are processed in the
351order given on the command line. 351order given on the command line.
352 352
353=head3 BUNDLE CREATION WORKFLOW / STATICPELR MKBUNDLE OPTIONS 353=head3 BUNDLE CREATION WORKFLOW / STATICPERL MKBUNDLE OPTIONS
354 354
355F<staticperl mkbundle> works by first assembling a list of candidate 355F<staticperl mkbundle> works by first assembling a list of candidate
356files and modules to include, then filtering them by include/exclude 356files and modules to include, then filtering them by include/exclude
357patterns. The remaining modules (together with their direct dependencies, 357patterns. The remaining modules (together with their direct dependencies,
358such as link libraries and L<AutoLoader> files) are then converted into 358such as link libraries and L<AutoLoader> files) are then converted into
543 # then later, in perl, use 543 # then later, in perl, use
544 use myfiles::file1; 544 use myfiles::file1;
545 require myfiles::file2; 545 require myfiles::file2;
546 my $res = do "myfiles/file3.pl"; 546 my $res = do "myfiles/file3.pl";
547 547
548=item C<--binadd> F<file> | C<--add> "F<file> alias" 548=item C<--addbin> F<file> | C<--addbin> "F<file> alias"
549 549
550Just 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
551without any postprocessing (perl files might get stripped to reduce their 551without any postprocessing (perl files might get stripped to reduce their
552size). 552size).
553 553
752standalone applications, and this option removes those known to cause 752standalone applications, and this option removes those known to cause
753trouble. 753trouble.
754 754
755Specifically, these are removed: 755Specifically, these are removed:
756 756
757C<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
758output, C<PERL5OPT>, C<PERL_DESTRUCT_LEVEL>, C<PERL_HASH_SEED> and 758output, C<PERL5OPT>, C<PERL_DESTRUCT_LEVEL>, C<PERL_HASH_SEED> and
759C<PERL_SIGNALS> can alter execution significantly, and C<PERL_UNICODE>, 759C<PERL_SIGNALS> can alter execution significantly, and C<PERL_UNICODE>,
760C<PERLIO_DEBUG> and C<PERLIO> can affect input and output. 760C<PERLIO_DEBUG> and C<PERLIO> can affect input and output.
761 761
762The 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
800 staticperl mkperl -MIO::AIO --staticlib crypt 800 staticperl mkperl -MIO::AIO --staticlib crypt
801 801
802 # ldopts might now contain: 802 # ldopts might now contain:
803 # -lm -Wl,-Bstatic -lcrypt -Wl,-Bdynamic -lpthread 803 # -lm -Wl,-Bstatic -lcrypt -Wl,-Bdynamic -lpthread
804 804
805=item C<--extra-cflags> string
806
807Specifies extra compiler flags, used when compiling the bundle file. The
808flags are appended to all the existing flags, so can be sued to override
809settings.
810
811=item C<--extra-ldflags> string
812
813Specifies extra linker flags, used when linking the bundle.
814
815=item C<--extra-libs> string
816
817Extra linker flags, appended at the end when linking. The difference to
818C<--extra-ldflags> is that the ldflags are appended to the flags, before
819the objects and libraries, and the extra libs are added at the end.
820
805=back 821=back
806 822
807=back 823=back
808 824
809=head3 EXTENDED GLOB PATTERNS 825=head3 EXTENDED GLOB PATTERNS
909downloaded perl sources are being cached, to avoid downloading them 925downloaded perl sources are being cached, to avoid downloading them
910again. The default is empty, which means there is no cache. 926again. The default is empty, which means there is no cache.
911 927
912=item C<PERL_VERSION> 928=item C<PERL_VERSION>
913 929
914The perl version to install - default is currently C<5.12.3>, but C<5.8.9> 930The perl version to install - C<5.12.5> is a good choice for small builds,
915is also a good choice (5.8.9 is much smaller than 5.12.3, while 5.10.1 is 931but C<5.8.9> is also a good choice (5.8.9 is much smaller than 5.12.5), if
916about as big as 5.12.3). 932it builds on your system.
933
934You can also set this variable to the absolute URL of a tarball (F<.tar>,
935F<.tar.gz>, F<.tar.bz2>, F<.tar.lzma> or F<.tar.xz>), or to the absolute
936path of an unpacked perl source tree, which will be copied.
937
938The default is currently
939F<http://stableperl.schmorp.de/dist/latest.tar.gz>, i.e. the latest
940stableperl release.
917 941
918=item C<PERL_MM_USE_DEFAULT>, C<EV_EXTRA_DEFS>, ... 942=item C<PERL_MM_USE_DEFAULT>, C<EV_EXTRA_DEFS>, ...
919 943
920Usually set to C<1> to make modules "less inquisitive" during their 944Usually set to C<1> to make modules "less inquisitive" during their
921installation. You can set (and export!) any environment variable you want 945installation. You can set (and export!) any environment variable you want
922- some modules (such as L<Coro> or L<EV>) use environment variables for 946- some modules (such as L<Coro> or L<EV>) use environment variables for
923further tweaking. 947further tweaking.
924 948
925=item C<PERL_PREFIX> 949=item C<PERL_PREFIX>
926 950
927The prefix where perl gets installed (default: F<$STATICPERL/perl>), 951The directory where perl gets installed (default: F<$STATICPERL/perl>),
928i.e. where the F<bin> and F<lib> subdirectories will end up. 952i.e. where the F<bin> and F<lib> subdirectories will end up. Previous
953contents will be removed on installation.
929 954
930=item C<PERL_CONFIGURE> 955=item C<PERL_CONFIGURE>
931 956
932Additional Configure options - these are simply passed to the perl 957Additional Configure options - these are simply passed to the perl
933Configure script. For example, if you wanted to enable dynamic loading, 958Configure script. For example, if you wanted to enable dynamic loading,
949F<~/.staticperlrc> to override them. 974F<~/.staticperlrc> to override them.
950 975
951Most of the variables override (or modify) the corresponding F<Configure> 976Most of the variables override (or modify) the corresponding F<Configure>
952variable, except C<PERL_CCFLAGS>, which gets appended. 977variable, except C<PERL_CCFLAGS>, which gets appended.
953 978
954You should have a look near the beginning of the F<staticperl> script - 979The default for C<PERL_OPTIMIZE> is C<-Os> (assuming gcc), and for
955staticperl tries to default C<PERL_OPTIMIZE> to some psace-saving options 980C<PERL_LIBS> is C<-lm -lcrypt>, which should be good for most (but not
956suitable for newer gcc versions. For other compilers or older versions you 981all) systems.
982
983For other compilers or more customised optimisation settings, you need to
957need to adjust these, for example, in your F<~/.staticperlrc>. 984adjust these, e.g. in your F<~/.staticperlrc>.
985
986With gcc on x86 and amd64, you can get more space-savings by using:
987
988 -Os -ffunction-sections -fdata-sections -finline-limit=8 -mpush-args
989 -mno-inline-stringops-dynamically -mno-align-stringops
990
991And on x86 and pentium3 and newer (basically everything you might ever
992want to run on), adding these is even better for space-savings (use
993-mtune=core2 or something newer for much faster code, too):
994
995 -fomit-frame-pointer -march=pentium3 -mtune=i386
958 996
959=back 997=back
960 998
961=head4 Variables you probably I<do not want> to override 999=head4 Variables you probably I<do not want> to override
962 1000
1145 1183
1146Binaries created with C<mkbundle>/C<mkperl> contain extra functionality, 1184Binaries created with C<mkbundle>/C<mkperl> contain extra functionality,
1147mostly related to the extra files bundled in the binary (the virtual 1185mostly related to the extra files bundled in the binary (the virtual
1148filesystem). All of this data is statically compiled into the binary, and 1186filesystem). All of this data is statically compiled into the binary, and
1149accessing means copying it from a read-only section of your binary. Data 1187accessing means copying it from a read-only section of your binary. Data
1150pages in this way is usually freed by the operating system, as it isn't 1188pages in this way are usually freed by the operating system, as they aren't
1151use more the onace. 1189used more then once.
1152 1190
1153=head2 VIRTUAL FILESYSTEM 1191=head2 VIRTUAL FILESYSTEM
1154 1192
1155Every bundle has a virtual filesystem. The only information stored in it 1193Every bundle has a virtual filesystem. The only information stored in it
1156is the path and contents of each file that was bundled. 1194is the path and contents of each file that was bundled.
1157 1195
1158=head3 LAYOUT 1196=head3 LAYOUT
1159 1197
1160Any path starting with an ampersand (F<&>) or exclamation mark (F<!>) are 1198Any paths starting with an ampersand (F<&>) or exclamation mark (F<!>) are
1161reserved by F<staticperl>. They must only be used as described in this 1199reserved by F<staticperl>. They must only be used as described in this
1162section. 1200section.
1163 1201
1164=over 4 1202=over 4
1165 1203
1215=head2 EXTRA FEATURES 1253=head2 EXTRA FEATURES
1216 1254
1217In addition, for the embedded loading of perl files to work, F<staticperl> 1255In addition, for the embedded loading of perl files to work, F<staticperl>
1218overrides the C<@INC> array. 1256overrides the C<@INC> array.
1219 1257
1220=head1 FULLY STATIC BINARIES - UCLIBC AND BUILDROOT 1258=head1 FULLY STATIC BINARIES - ALPINE LINUX
1221 1259
1222To make truly static (Linux-) libraries, you might want to have a look at 1260This section once contained a way to build fully static (including
1223buildroot (L<http://buildroot.uclibc.org/>). 1261uClibc) binaries with buildroot. Unfortunately, buildroot no longer
1262supports a compiler, so I recommend using alpine linux instead
1263(L<http://alpinelinux.org/>). Get yourself a VM (e.g. with qemu), run an
1264older alpine linux verison in it (e.g. 2.4), copy staticperl inside and
1265use it.
1224 1266
1225Buildroot is primarily meant to set up a cross-compile environment (which 1267The reason you might want an older alpine linux is that uClibc can be
1226is not so useful as perl doesn't quite like cross compiles), but it can also compile 1268quite dependent on kernel versions, so the newest version of alpine linux
1227a chroot environment where you can use F<staticperl>. 1269might need a newer kernel then you might want for, if you plan to run your
1228 1270binaries on on other kernels.
1229To do so, download buildroot, and enable "Build options => development
1230files in target filesystem" and optionally "Build options => gcc
1231optimization level (optimize for size)". At the time of writing, I had
1232good experiences with GCC 4.4.x but not GCC 4.5.
1233
1234To minimise code size, I used C<-pipe -ffunction-sections -fdata-sections
1235-finline-limit=8 -fno-builtin-strlen -mtune=i386>. The C<-mtune=i386>
1236doesn't decrease codesize much, but it makes the file much more
1237compressible (and the execution a lot slower...).
1238
1239If you don't need Coro or threads, you can go with "linuxthreads.old" (or
1240no thread support). For Coro, it is highly recommended to switch to a
1241uClibc newer than 0.9.31 (at the time of this writing, I used the 20101201
1242snapshot) and enable NPTL, otherwise Coro needs to be configured with the
1243ultra-slow pthreads backend to work around linuxthreads bugs (it also uses
1244twice the address space needed for stacks).
1245
1246If you use C<linuxthreads.old>, then you should also be aware that
1247uClibc shares C<errno> between all threads when statically linking. See
1248L<http://lists.uclibc.org/pipermail/uclibc/2010-June/044157.html> for a
1249workaround (and L<https://bugs.uclibc.org/2089> for discussion).
1250
1251C<ccache> support is also recommended, especially if you want
1252to play around with buildroot options. Enabling the C<miniperl>
1253package will probably enable all options required for a successful
1254perl build. F<staticperl> itself additionally needs either C<wget>
1255(recommended, for CPAN) or C<curl>.
1256
1257As for shells, busybox should provide all that is needed, but the default
1258busybox configuration doesn't include F<comm> which is needed by perl -
1259either make a custom busybox config, or compile coreutils.
1260
1261For the latter route, you might find that bash has some bugs that keep
1262it from working properly in a chroot - either use dash (and link it to
1263F</bin/sh> inside the chroot) or link busybox to F</bin/sh>, using it's
1264built-in ash shell.
1265
1266Finally, you need F</dev/null> inside the chroot for many scripts to work
1267- either F<cp /dev/null output/target/dev> or bind-mounting your F</dev>
1268will provide this.
1269
1270After you have compiled and set up your buildroot target, you can copy
1271F<staticperl> from the C<App::Staticperl> distribution or from your
1272perl F<bin> directory (if you installed it) into the F<output/target>
1273filesystem, chroot inside and run it.
1274 1271
1275=head1 RECIPES / SPECIFIC MODULES 1272=head1 RECIPES / SPECIFIC MODULES
1276 1273
1277This section contains some common(?) recipes and information about 1274This section contains some common(?) recipes and information about
1278problems with some common modules or perl constructs that require extra 1275problems with some common modules or perl constructs that require extra
1292 1289
1293Many Unicode properties in turn are defined in separate modules, 1290Many Unicode properties in turn are defined in separate modules,
1294such as C<"unicore/Heavy.pl"> and more specific data tables such as 1291such as C<"unicore/Heavy.pl"> and more specific data tables such as
1295C<"unicore/To/Digit.pl"> or C<"unicore/lib/Perl/Word.pl">. These tables 1292C<"unicore/To/Digit.pl"> or C<"unicore/lib/Perl/Word.pl">. These tables
1296are big (7MB uncompressed, although F<staticperl> contains special 1293are big (7MB uncompressed, although F<staticperl> contains special
1297handling for those files), so including them on demand by your application 1294handling for those files), so including them only on demand in your
1298only might pay off. 1295application might pay off.
1299 1296
1300To simply include the whole unicode database, use: 1297To simply include the whole unicode database, use:
1301 1298
1302 --incglob '/unicore/**.pl' 1299 --incglob '/unicore/**.pl'
1303 1300
1340C<MAN3PODS> to be empty via the C<PERL_MM_OPT> environment variable. 1337C<MAN3PODS> to be empty via the C<PERL_MM_OPT> environment variable.
1341 1338
1342=item Gtk2 1339=item Gtk2
1343 1340
1344See Pango, same problems, same solution. 1341See Pango, same problems, same solution.
1342
1343=item Net::SSLeay
1344
1345This module hasn't been significantly updated since OpenSSL is called
1346OpenSSL, and fails to properly link against dependent libraries, most
1347commonly, it forgets to specify -ldl when linking.
1348
1349On GNU/Linux systems this usually goes undetected, as perl usually links
1350against -ldl itself and OpenSSL just happens to pick it up that way, by
1351chance.
1352
1353For static builds, you either have to configure -ldl manually, or you
1354cna use the following snippet in your C<postinstall> hook which patches
1355Net::SSLeay after installation, which happens to work most of the time:
1356
1357 postinstall() {
1358 # first install it
1359 instcpan Net::SSLeay
1360 # then add -ldl for future linking
1361 chmod u+w "$PERL_PREFIX"/lib/auto/Net/SSLeay/extralibs.ld
1362 echo " -ldl" >>"$PERL_PREFIX"/lib/auto/Net/SSLeay/extralibs.ld
1363 }
1345 1364
1346=item Pango 1365=item Pango
1347 1366
1348In addition to the C<MAN3PODS> problem in Glib, Pango also routes around 1367In addition to the C<MAN3PODS> problem in Glib, Pango also routes around
1349L<ExtUtils::MakeMaker> by compiling its files on its own. F<staticperl> 1368L<ExtUtils::MakeMaker> by compiling its files on its own. F<staticperl>
1417gains little. Why Socket exposes a C function that is in the core already 1436gains little. Why Socket exposes a C function that is in the core already
1418is anybody's guess. 1437is anybody's guess.
1419 1438
1420=back 1439=back
1421 1440
1441=head1 ADDITIONAL RESOURCES
1442
1443Some guy has made a repository on github
1444(L<https://github.com/gh0stwizard/staticperl-modules>) with some modules
1445patched to build with staticperl.
1446
1422=head1 AUTHOR 1447=head1 AUTHOR
1423 1448
1424 Marc Lehmann <schmorp@schmorp.de> 1449 Marc Lehmann <schmorp@schmorp.de>
1425 http://software.schmorp.de/pkg/staticperl.html 1450 http://software.schmorp.de/pkg/staticperl.html
1451

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines