… | |
… | |
1229 | =head2 EXTRA FEATURES |
1229 | =head2 EXTRA FEATURES |
1230 | |
1230 | |
1231 | In addition, for the embedded loading of perl files to work, F<staticperl> |
1231 | In addition, for the embedded loading of perl files to work, F<staticperl> |
1232 | overrides the C<@INC> array. |
1232 | overrides the C<@INC> array. |
1233 | |
1233 | |
1234 | =head1 FULLY STATIC BINARIES - UCLIBC AND BUILDROOT |
1234 | =head1 FULLY STATIC BINARIES - ALPINE LINUX |
1235 | |
1235 | |
1236 | To make truly static (Linux-) libraries, you might want to have a look at |
1236 | This section once contained a way to build fully static (including |
1237 | buildroot (L<http://buildroot.uclibc.org/>). |
1237 | uClibc) binaries with buildroot. Unfortunately, buildroot no longer |
|
|
1238 | supports a compiler, so I recommend using alpine linux instead |
|
|
1239 | (L<http://alpinelinux.org/>). Get yourself a VM (e.g. with qemu), run an |
|
|
1240 | older alpine linux verison in it (e.g. 2.4), copy staticperl inside and |
|
|
1241 | use it. |
1238 | |
1242 | |
1239 | Buildroot is primarily meant to set up a cross-compile environment (which |
1243 | The reason you might want an older alpine linux is that uClibc can be |
1240 | is not so useful as perl doesn't quite like cross compiles), but it can also compile |
1244 | quite dependent on kernel versions, so the newest version of alpine linux |
1241 | a chroot environment where you can use F<staticperl>. |
1245 | might need a newer kernel then you might want for, if you plan to run your |
1242 | |
1246 | binaries on on other kernels. |
1243 | To do so, download buildroot, and enable "Build options => development |
|
|
1244 | files in target filesystem" and optionally "Build options => gcc |
|
|
1245 | optimization level (optimize for size)". At the time of writing, I had |
|
|
1246 | good experiences with GCC 4.4.x but not GCC 4.5. |
|
|
1247 | |
|
|
1248 | To minimise code size, I used C<-pipe -ffunction-sections -fdata-sections |
|
|
1249 | -finline-limit=8 -fno-builtin-strlen -mtune=i386>. The C<-mtune=i386> |
|
|
1250 | doesn't decrease codesize much, but it makes the file much more |
|
|
1251 | compressible (and the execution a lot slower...). |
|
|
1252 | |
|
|
1253 | If you don't need Coro or threads, you can go with "linuxthreads.old" (or |
|
|
1254 | no thread support). For Coro, it is highly recommended to switch to a |
|
|
1255 | uClibc newer than 0.9.31 (at the time of this writing, I used the 20101201 |
|
|
1256 | snapshot) and enable NPTL, otherwise Coro needs to be configured with the |
|
|
1257 | ultra-slow pthreads backend to work around linuxthreads bugs (it also uses |
|
|
1258 | twice the address space needed for stacks). |
|
|
1259 | |
|
|
1260 | If you use C<linuxthreads.old>, then you should also be aware that |
|
|
1261 | uClibc shares C<errno> between all threads when statically linking. See |
|
|
1262 | L<http://lists.uclibc.org/pipermail/uclibc/2010-June/044157.html> for a |
|
|
1263 | workaround (and L<https://bugs.uclibc.org/2089> for discussion). |
|
|
1264 | |
|
|
1265 | C<ccache> support is also recommended, especially if you want |
|
|
1266 | to play around with buildroot options. Enabling the C<miniperl> |
|
|
1267 | package will probably enable all options required for a successful |
|
|
1268 | perl build. F<staticperl> itself additionally needs either C<wget> |
|
|
1269 | (recommended, for CPAN) or C<curl>. |
|
|
1270 | |
|
|
1271 | As for shells, busybox should provide all that is needed, but the default |
|
|
1272 | busybox configuration doesn't include F<comm> which is needed by perl - |
|
|
1273 | either make a custom busybox config, or compile coreutils. |
|
|
1274 | |
|
|
1275 | For the latter route, you might find that bash has some bugs that keep |
|
|
1276 | it from working properly in a chroot - either use dash (and link it to |
|
|
1277 | F</bin/sh> inside the chroot) or link busybox to F</bin/sh>, using it's |
|
|
1278 | built-in ash shell. |
|
|
1279 | |
|
|
1280 | Finally, you need F</dev/null> inside the chroot for many scripts to work |
|
|
1281 | - either F<cp /dev/null output/target/dev> or bind-mounting your F</dev> |
|
|
1282 | will provide this. |
|
|
1283 | |
|
|
1284 | After you have compiled and set up your buildroot target, you can copy |
|
|
1285 | F<staticperl> from the C<App::Staticperl> distribution or from your |
|
|
1286 | perl F<bin> directory (if you installed it) into the F<output/target> |
|
|
1287 | filesystem, chroot inside and run it. |
|
|
1288 | |
1247 | |
1289 | =head1 RECIPES / SPECIFIC MODULES |
1248 | =head1 RECIPES / SPECIFIC MODULES |
1290 | |
1249 | |
1291 | This section contains some common(?) recipes and information about |
1250 | This section contains some common(?) recipes and information about |
1292 | problems with some common modules or perl constructs that require extra |
1251 | problems with some common modules or perl constructs that require extra |
… | |
… | |
1453 | gains little. Why Socket exposes a C function that is in the core already |
1412 | gains little. Why Socket exposes a C function that is in the core already |
1454 | is anybody's guess. |
1413 | is anybody's guess. |
1455 | |
1414 | |
1456 | =back |
1415 | =back |
1457 | |
1416 | |
|
|
1417 | =head1 ADDITIONAL RESOURCES |
|
|
1418 | |
|
|
1419 | Some guy has made a repository on github |
|
|
1420 | (L<https://github.com/gh0stwizard/staticperl-modules>) with some modules |
|
|
1421 | patched to build with staticperl. |
|
|
1422 | |
1458 | =head1 AUTHOR |
1423 | =head1 AUTHOR |
1459 | |
1424 | |
1460 | Marc Lehmann <schmorp@schmorp.de> |
1425 | Marc Lehmann <schmorp@schmorp.de> |
1461 | http://software.schmorp.de/pkg/staticperl.html |
1426 | http://software.schmorp.de/pkg/staticperl.html |
|
|
1427 | |