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.55 by root, Mon Mar 12 21:45:10 2012 UTC vs.
Revision 1.59 by root, Mon Jul 6 23:33:15 2015 UTC

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<--binadd> "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
922- some modules (such as L<Coro> or L<EV>) use environment variables for 922- some modules (such as L<Coro> or L<EV>) use environment variables for
923further tweaking. 923further tweaking.
924 924
925=item C<PERL_PREFIX> 925=item C<PERL_PREFIX>
926 926
927The prefix where perl gets installed (default: F<$STATICPERL/perl>), 927The directory where perl gets installed (default: F<$STATICPERL/perl>),
928i.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. Previous
929contents will be removed on installation.
929 930
930=item C<PERL_CONFIGURE> 931=item C<PERL_CONFIGURE>
931 932
932Additional Configure options - these are simply passed to the perl 933Additional Configure options - these are simply passed to the perl
933Configure script. For example, if you wanted to enable dynamic loading, 934Configure script. For example, if you wanted to enable dynamic loading,
1228=head2 EXTRA FEATURES 1229=head2 EXTRA FEATURES
1229 1230
1230In addition, for the embedded loading of perl files to work, F<staticperl> 1231In addition, for the embedded loading of perl files to work, F<staticperl>
1231overrides the C<@INC> array. 1232overrides the C<@INC> array.
1232 1233
1233=head1 FULLY STATIC BINARIES - UCLIBC AND BUILDROOT 1234=head1 FULLY STATIC BINARIES - ALPINE LINUX
1234 1235
1235To make truly static (Linux-) libraries, you might want to have a look at 1236This section once contained a way to build fully static (including
1236buildroot (L<http://buildroot.uclibc.org/>). 1237uClibc) binaries with buildroot. Unfortunately, buildroot no longer
1238supports a compiler, so I recommend using alpine linux instead
1239(L<http://alpinelinux.org/>). Get yourself a VM (e.g. with qemu), run an
1240older alpine linux verison in it (e.g. 2.4), copy staticperl inside and
1241use it.
1237 1242
1238Buildroot is primarily meant to set up a cross-compile environment (which 1243The reason you might want an older alpine linux is that uClibc can be
1239is not so useful as perl doesn't quite like cross compiles), but it can also compile 1244quite dependent on kernel versions, so the newest version of alpine linux
1240a chroot environment where you can use F<staticperl>. 1245might need a newer kernel then you might want for, if you plan to run your
1241 1246binaries on on other kernels.
1242To do so, download buildroot, and enable "Build options => development
1243files in target filesystem" and optionally "Build options => gcc
1244optimization level (optimize for size)". At the time of writing, I had
1245good experiences with GCC 4.4.x but not GCC 4.5.
1246
1247To minimise code size, I used C<-pipe -ffunction-sections -fdata-sections
1248-finline-limit=8 -fno-builtin-strlen -mtune=i386>. The C<-mtune=i386>
1249doesn't decrease codesize much, but it makes the file much more
1250compressible (and the execution a lot slower...).
1251
1252If you don't need Coro or threads, you can go with "linuxthreads.old" (or
1253no thread support). For Coro, it is highly recommended to switch to a
1254uClibc newer than 0.9.31 (at the time of this writing, I used the 20101201
1255snapshot) and enable NPTL, otherwise Coro needs to be configured with the
1256ultra-slow pthreads backend to work around linuxthreads bugs (it also uses
1257twice the address space needed for stacks).
1258
1259If you use C<linuxthreads.old>, then you should also be aware that
1260uClibc shares C<errno> between all threads when statically linking. See
1261L<http://lists.uclibc.org/pipermail/uclibc/2010-June/044157.html> for a
1262workaround (and L<https://bugs.uclibc.org/2089> for discussion).
1263
1264C<ccache> support is also recommended, especially if you want
1265to play around with buildroot options. Enabling the C<miniperl>
1266package will probably enable all options required for a successful
1267perl build. F<staticperl> itself additionally needs either C<wget>
1268(recommended, for CPAN) or C<curl>.
1269
1270As for shells, busybox should provide all that is needed, but the default
1271busybox configuration doesn't include F<comm> which is needed by perl -
1272either make a custom busybox config, or compile coreutils.
1273
1274For the latter route, you might find that bash has some bugs that keep
1275it from working properly in a chroot - either use dash (and link it to
1276F</bin/sh> inside the chroot) or link busybox to F</bin/sh>, using it's
1277built-in ash shell.
1278
1279Finally, you need F</dev/null> inside the chroot for many scripts to work
1280- either F<cp /dev/null output/target/dev> or bind-mounting your F</dev>
1281will provide this.
1282
1283After you have compiled and set up your buildroot target, you can copy
1284F<staticperl> from the C<App::Staticperl> distribution or from your
1285perl F<bin> directory (if you installed it) into the F<output/target>
1286filesystem, chroot inside and run it.
1287 1247
1288=head1 RECIPES / SPECIFIC MODULES 1248=head1 RECIPES / SPECIFIC MODULES
1289 1249
1290This section contains some common(?) recipes and information about 1250This section contains some common(?) recipes and information about
1291problems with some common modules or perl constructs that require extra 1251problems with some common modules or perl constructs that require extra
1353C<MAN3PODS> to be empty via the C<PERL_MM_OPT> environment variable. 1313C<MAN3PODS> to be empty via the C<PERL_MM_OPT> environment variable.
1354 1314
1355=item Gtk2 1315=item Gtk2
1356 1316
1357See Pango, same problems, same solution. 1317See Pango, same problems, same solution.
1318
1319=item Net::SSLeay
1320
1321This module hasn't been significantly updated since OpenSSL is called
1322OpenSSL, and fails to properly link against dependent libraries, most
1323commonly, it forgets to specify -ldl when linking.
1324
1325On GNU/Linux systems this usually goes undetected, as perl usually links
1326against -ldl itself and OpenSSL just happens to pick it up that way, by
1327chance.
1328
1329For static builds, you either have to configure -ldl manually, or you
1330cna use the following snippet in your C<postinstall> hook which patches
1331Net::SSLeay after installation, which happens to work most of the time:
1332
1333 postinstall() {
1334 # first install it
1335 instcpan Net::SSLeay
1336 # then add -ldl for future linking
1337 chmod u+w "$PERL_PREFIX"/lib/auto/Net/SSLeay/extralibs.ld
1338 echo " -ldl" >>"$PERL_PREFIX"/lib/auto/Net/SSLeay/extralibs.ld
1339 }
1358 1340
1359=item Pango 1341=item Pango
1360 1342
1361In addition to the C<MAN3PODS> problem in Glib, Pango also routes around 1343In addition to the C<MAN3PODS> problem in Glib, Pango also routes around
1362L<ExtUtils::MakeMaker> by compiling its files on its own. F<staticperl> 1344L<ExtUtils::MakeMaker> by compiling its files on its own. F<staticperl>
1430gains little. Why Socket exposes a C function that is in the core already 1412gains little. Why Socket exposes a C function that is in the core already
1431is anybody's guess. 1413is anybody's guess.
1432 1414
1433=back 1415=back
1434 1416
1417=head1 ADDITIONAL RESOURCES
1418
1419Some guy has made a repository on github
1420(L<https://github.com/gh0stwizard/staticperl-modules>) with some modules
1421patched to build with staticperl.
1422
1435=head1 AUTHOR 1423=head1 AUTHOR
1436 1424
1437 Marc Lehmann <schmorp@schmorp.de> 1425 Marc Lehmann <schmorp@schmorp.de>
1438 http://software.schmorp.de/pkg/staticperl.html 1426 http://software.schmorp.de/pkg/staticperl.html
1427

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines