… | |
… | |
495 | # then later, in perl, use |
495 | # then later, in perl, use |
496 | use myfiles::file1; |
496 | use myfiles::file1; |
497 | require myfiles::file2; |
497 | require myfiles::file2; |
498 | my $res = do "myfiles/file3.pl"; |
498 | my $res = do "myfiles/file3.pl"; |
499 | |
499 | |
500 | "--binadd" file | "--binadd" "file alias" |
500 | "--addbin" file | "--addbin" "file alias" |
501 | Just like "--add", except that it treats the file as binary and |
501 | Just like "--add", except that it treats the file as binary and |
502 | adds it without any postprocessing (perl files might get |
502 | adds it without any postprocessing (perl files might get |
503 | stripped to reduce their size). |
503 | stripped to reduce their size). |
504 | |
504 | |
505 | If you specify an alias you should probably add a "/" prefix to |
505 | If you specify an alias you should probably add a "/" prefix to |
… | |
… | |
832 | installation. You can set (and export!) any environment variable you |
832 | installation. You can set (and export!) any environment variable you |
833 | want - some modules (such as Coro or EV) use environment variables |
833 | want - some modules (such as Coro or EV) use environment variables |
834 | for further tweaking. |
834 | for further tweaking. |
835 | |
835 | |
836 | "PERL_PREFIX" |
836 | "PERL_PREFIX" |
837 | The prefix where perl gets installed (default: $STATICPERL/perl), |
837 | The directory where perl gets installed (default: $STATICPERL/perl), |
838 | i.e. where the bin and lib subdirectories will end up. |
838 | i.e. where the bin and lib subdirectories will end up. Previous |
|
|
839 | contents will be removed on installation. |
839 | |
840 | |
840 | "PERL_CONFIGURE" |
841 | "PERL_CONFIGURE" |
841 | Additional Configure options - these are simply passed to the perl |
842 | Additional Configure options - these are simply passed to the perl |
842 | Configure script. For example, if you wanted to enable dynamic |
843 | Configure script. For example, if you wanted to enable dynamic |
843 | loading, you could pass "-Dusedl". To enable ithreads (Why would you |
844 | loading, you could pass "-Dusedl". To enable ithreads (Why would you |
… | |
… | |
1082 | |
1083 | |
1083 | EXTRA FEATURES |
1084 | EXTRA FEATURES |
1084 | In addition, for the embedded loading of perl files to work, staticperl |
1085 | In addition, for the embedded loading of perl files to work, staticperl |
1085 | overrides the @INC array. |
1086 | overrides the @INC array. |
1086 | |
1087 | |
1087 | FULLY STATIC BINARIES - UCLIBC AND BUILDROOT |
1088 | FULLY STATIC BINARIES - ALPINE LINUX |
1088 | To make truly static (Linux-) libraries, you might want to have a look |
1089 | This section once contained a way to build fully static (including |
1089 | at buildroot (<http://buildroot.uclibc.org/>). |
1090 | uClibc) binaries with buildroot. Unfortunately, buildroot no longer |
|
|
1091 | supports a compiler, so I recommend using alpine linux instead |
|
|
1092 | (<http://alpinelinux.org/>). Get yourself a VM (e.g. with qemu), run an |
|
|
1093 | older alpine linux verison in it (e.g. 2.4), copy staticperl inside and |
|
|
1094 | use it. |
1090 | |
1095 | |
1091 | Buildroot is primarily meant to set up a cross-compile environment |
1096 | The reason you might want an older alpine linux is that uClibc can be |
1092 | (which is not so useful as perl doesn't quite like cross compiles), but |
1097 | quite dependent on kernel versions, so the newest version of alpine |
1093 | it can also compile a chroot environment where you can use staticperl. |
1098 | linux might need a newer kernel then you might want for, if you plan to |
1094 | |
1099 | run your binaries on on other kernels. |
1095 | To do so, download buildroot, and enable "Build options => development |
|
|
1096 | files in target filesystem" and optionally "Build options => gcc |
|
|
1097 | optimization level (optimize for size)". At the time of writing, I had |
|
|
1098 | good experiences with GCC 4.4.x but not GCC 4.5. |
|
|
1099 | |
|
|
1100 | To minimise code size, I used "-pipe -ffunction-sections -fdata-sections |
|
|
1101 | -finline-limit=8 -fno-builtin-strlen -mtune=i386". The "-mtune=i386" |
|
|
1102 | doesn't decrease codesize much, but it makes the file much more |
|
|
1103 | compressible (and the execution a lot slower...). |
|
|
1104 | |
|
|
1105 | If you don't need Coro or threads, you can go with "linuxthreads.old" |
|
|
1106 | (or no thread support). For Coro, it is highly recommended to switch to |
|
|
1107 | a uClibc newer than 0.9.31 (at the time of this writing, I used the |
|
|
1108 | 20101201 snapshot) and enable NPTL, otherwise Coro needs to be |
|
|
1109 | configured with the ultra-slow pthreads backend to work around |
|
|
1110 | linuxthreads bugs (it also uses twice the address space needed for |
|
|
1111 | stacks). |
|
|
1112 | |
|
|
1113 | If you use "linuxthreads.old", then you should also be aware that uClibc |
|
|
1114 | shares "errno" between all threads when statically linking. See |
|
|
1115 | <http://lists.uclibc.org/pipermail/uclibc/2010-June/044157.html> for a |
|
|
1116 | workaround (and <https://bugs.uclibc.org/2089> for discussion). |
|
|
1117 | |
|
|
1118 | "ccache" support is also recommended, especially if you want to play |
|
|
1119 | around with buildroot options. Enabling the "miniperl" package will |
|
|
1120 | probably enable all options required for a successful perl build. |
|
|
1121 | staticperl itself additionally needs either "wget" (recommended, for |
|
|
1122 | CPAN) or "curl". |
|
|
1123 | |
|
|
1124 | As for shells, busybox should provide all that is needed, but the |
|
|
1125 | default busybox configuration doesn't include comm which is needed by |
|
|
1126 | perl - either make a custom busybox config, or compile coreutils. |
|
|
1127 | |
|
|
1128 | For the latter route, you might find that bash has some bugs that keep |
|
|
1129 | it from working properly in a chroot - either use dash (and link it to |
|
|
1130 | /bin/sh inside the chroot) or link busybox to /bin/sh, using it's |
|
|
1131 | built-in ash shell. |
|
|
1132 | |
|
|
1133 | Finally, you need /dev/null inside the chroot for many scripts to work - |
|
|
1134 | either cp /dev/null output/target/dev or bind-mounting your /dev will |
|
|
1135 | provide this. |
|
|
1136 | |
|
|
1137 | After you have compiled and set up your buildroot target, you can copy |
|
|
1138 | staticperl from the "App::Staticperl" distribution or from your perl bin |
|
|
1139 | directory (if you installed it) into the output/target filesystem, |
|
|
1140 | chroot inside and run it. |
|
|
1141 | |
1100 | |
1142 | RECIPES / SPECIFIC MODULES |
1101 | RECIPES / SPECIFIC MODULES |
1143 | This section contains some common(?) recipes and information about |
1102 | This section contains some common(?) recipes and information about |
1144 | problems with some common modules or perl constructs that require extra |
1103 | problems with some common modules or perl constructs that require extra |
1145 | files to be included. |
1104 | files to be included. |
… | |
… | |
1197 | "MAN1PODS" and "MAN3PODS" to be empty via the "PERL_MM_OPT" |
1156 | "MAN1PODS" and "MAN3PODS" to be empty via the "PERL_MM_OPT" |
1198 | environment variable. |
1157 | environment variable. |
1199 | |
1158 | |
1200 | Gtk2 |
1159 | Gtk2 |
1201 | See Pango, same problems, same solution. |
1160 | See Pango, same problems, same solution. |
|
|
1161 | |
|
|
1162 | Net::SSLeay |
|
|
1163 | This module hasn't been significantly updated since OpenSSL is |
|
|
1164 | called OpenSSL, and fails to properly link against dependent |
|
|
1165 | libraries, most commonly, it forgets to specify -ldl when linking. |
|
|
1166 | |
|
|
1167 | On GNU/Linux systems this usually goes undetected, as perl usually |
|
|
1168 | links against -ldl itself and OpenSSL just happens to pick it up |
|
|
1169 | that way, by chance. |
|
|
1170 | |
|
|
1171 | For static builds, you either have to configure -ldl manually, or |
|
|
1172 | you cna use the following snippet in your "postinstall" hook which |
|
|
1173 | patches Net::SSLeay after installation, which happens to work most |
|
|
1174 | of the time: |
|
|
1175 | |
|
|
1176 | postinstall() { |
|
|
1177 | # first install it |
|
|
1178 | instcpan Net::SSLeay |
|
|
1179 | # then add -ldl for future linking |
|
|
1180 | chmod u+w "$PERL_PREFIX"/lib/auto/Net/SSLeay/extralibs.ld |
|
|
1181 | echo " -ldl" >>"$PERL_PREFIX"/lib/auto/Net/SSLeay/extralibs.ld |
|
|
1182 | } |
1202 | |
1183 | |
1203 | Pango |
1184 | Pango |
1204 | In addition to the "MAN3PODS" problem in Glib, Pango also routes |
1185 | In addition to the "MAN3PODS" problem in Glib, Pango also routes |
1205 | around ExtUtils::MakeMaker by compiling its files on its own. |
1186 | around ExtUtils::MakeMaker by compiling its files on its own. |
1206 | staticperl tries to patch ExtUtils::MM_Unix to route around Pango. |
1187 | staticperl tries to patch ExtUtils::MM_Unix to route around Pango. |
… | |
… | |
1264 | Also, this leaves "gethostbyname" in - not only is it actually used |
1245 | Also, this leaves "gethostbyname" in - not only is it actually used |
1265 | often, the Socket module also exposes it, so leaving it out usually |
1246 | often, the Socket module also exposes it, so leaving it out usually |
1266 | gains little. Why Socket exposes a C function that is in the core |
1247 | gains little. Why Socket exposes a C function that is in the core |
1267 | already is anybody's guess. |
1248 | already is anybody's guess. |
1268 | |
1249 | |
|
|
1250 | ADDITIONAL RESOURCES |
|
|
1251 | Some guy has made a repository on github |
|
|
1252 | (<https://github.com/gh0stwizard/staticperl-modules>) with some modules |
|
|
1253 | patched to build with staticperl. |
|
|
1254 | |
1269 | AUTHOR |
1255 | AUTHOR |
1270 | Marc Lehmann <schmorp@schmorp.de> |
1256 | Marc Lehmann <schmorp@schmorp.de> |
1271 | http://software.schmorp.de/pkg/staticperl.html |
1257 | http://software.schmorp.de/pkg/staticperl.html |
1272 | |
1258 | |