… | |
… | |
39 | file that contains perl interpreter, libc, all the modules you need, all |
39 | file that contains perl interpreter, libc, all the modules you need, all |
40 | the libraries you need and of course your actual program. |
40 | the libraries you need and of course your actual program. |
41 | |
41 | |
42 | With F<uClibc> and F<upx> on x86, you can create a single 500kb binary |
42 | With F<uClibc> and F<upx> on x86, you can create a single 500kb binary |
43 | that contains perl and 100 modules such as POSIX, AnyEvent, EV, IO::AIO, |
43 | that contains perl and 100 modules such as POSIX, AnyEvent, EV, IO::AIO, |
44 | Coro and so on. Or any other choice of modules. |
44 | Coro and so on. Or any other choice of modules (and some other size :). |
45 | |
45 | |
46 | To see how this turns out, you can try out smallperl and bigperl, two |
46 | To see how this turns out, you can try out smallperl and bigperl, two |
47 | pre-built static and compressed perl binaries with many and even more |
47 | pre-built static and compressed perl binaries with many and even more |
48 | modules: just follow the links at L<http://staticperl.schmorp.de/>. |
48 | modules: just follow the links at L<http://staticperl.schmorp.de/>. |
49 | |
49 | |
… | |
… | |
882 | =item C<STATICPERL> |
882 | =item C<STATICPERL> |
883 | |
883 | |
884 | The directory where staticperl stores all its files |
884 | The directory where staticperl stores all its files |
885 | (default: F<~/.staticperl>). |
885 | (default: F<~/.staticperl>). |
886 | |
886 | |
|
|
887 | =item C<DLCACHE> |
|
|
888 | |
|
|
889 | The path to a directory (will be created if it doesn't exist) where |
|
|
890 | downloaded perl sources are being cached, to avoid downloading them |
|
|
891 | again. The default is empty, which means there is no cache. |
|
|
892 | |
|
|
893 | =item C<PERL_VERSION> |
|
|
894 | |
|
|
895 | The perl version to install - default is currently C<5.12.3>, but C<5.8.9> |
|
|
896 | is also a good choice (5.8.9 is much smaller than 5.12.3, while 5.10.1 is |
|
|
897 | about as big as 5.12.3). |
|
|
898 | |
887 | =item C<PERL_MM_USE_DEFAULT>, C<EV_EXTRA_DEFS>, ... |
899 | =item C<PERL_MM_USE_DEFAULT>, C<EV_EXTRA_DEFS>, ... |
888 | |
900 | |
889 | Usually set to C<1> to make modules "less inquisitive" during their |
901 | Usually set to C<1> to make modules "less inquisitive" during their |
890 | installation, you can set any environment variable you want - some modules |
902 | installation, you can set any environment variable you want - some modules |
891 | (such as L<Coro> or L<EV>) use environment variables for further tweaking. |
903 | (such as L<Coro> or L<EV>) use environment variables for further tweaking. |
892 | |
|
|
893 | =item C<PERL_VERSION> |
|
|
894 | |
|
|
895 | The perl version to install - default is currently C<5.12.3>, but C<5.8.9> |
|
|
896 | is also a good choice (5.8.9 is much smaller than 5.12.3, while 5.10.1 is |
|
|
897 | about as big as 5.12.3). |
|
|
898 | |
904 | |
899 | =item C<PERL_PREFIX> |
905 | =item C<PERL_PREFIX> |
900 | |
906 | |
901 | The prefix where perl gets installed (default: F<$STATICPERL/perl>), |
907 | The prefix where perl gets installed (default: F<$STATICPERL/perl>), |
902 | i.e. where the F<bin> and F<lib> subdirectories will end up. |
908 | i.e. where the F<bin> and F<lib> subdirectories will end up. |
… | |
… | |
922 | the top of the F<staticperl> script for more info on these, and use a |
928 | the top of the F<staticperl> script for more info on these, and use a |
923 | F<~/.staticperlrc> to override them. |
929 | F<~/.staticperlrc> to override them. |
924 | |
930 | |
925 | Most of the variables override (or modify) the corresponding F<Configure> |
931 | Most of the variables override (or modify) the corresponding F<Configure> |
926 | variable, except C<PERL_CCFLAGS>, which gets appended. |
932 | variable, except C<PERL_CCFLAGS>, which gets appended. |
|
|
933 | |
|
|
934 | You should have a look near the beginning of the F<staticperl> script - |
|
|
935 | staticperl tries to default C<PERL_OPTIMIZE> to some psace-saving options |
|
|
936 | suitable for newer gcc versions. For other compilers or older versions you |
|
|
937 | need to adjust these, for example, in your F<~/.staticperlrc>. |
927 | |
938 | |
928 | =back |
939 | =back |
929 | |
940 | |
930 | =head4 Variables you probably I<do not want> to override |
941 | =head4 Variables you probably I<do not want> to override |
931 | |
942 | |
… | |
… | |
1150 | good experiences with GCC 4.4.x but not GCC 4.5. |
1161 | good experiences with GCC 4.4.x but not GCC 4.5. |
1151 | |
1162 | |
1152 | To minimise code size, I used C<-pipe -ffunction-sections -fdata-sections |
1163 | To minimise code size, I used C<-pipe -ffunction-sections -fdata-sections |
1153 | -finline-limit=8 -fno-builtin-strlen -mtune=i386>. The C<-mtune=i386> |
1164 | -finline-limit=8 -fno-builtin-strlen -mtune=i386>. The C<-mtune=i386> |
1154 | doesn't decrease codesize much, but it makes the file much more |
1165 | doesn't decrease codesize much, but it makes the file much more |
1155 | compressible. |
1166 | compressible (and the execution a lot slower...). |
1156 | |
1167 | |
1157 | If you don't need Coro or threads, you can go with "linuxthreads.old" (or |
1168 | If you don't need Coro or threads, you can go with "linuxthreads.old" (or |
1158 | no thread support). For Coro, it is highly recommended to switch to a |
1169 | no thread support). For Coro, it is highly recommended to switch to a |
1159 | uClibc newer than 0.9.31 (at the time of this writing, I used the 20101201 |
1170 | uClibc newer than 0.9.31 (at the time of this writing, I used the 20101201 |
1160 | snapshot) and enable NPTL, otherwise Coro needs to be configured with the |
1171 | snapshot) and enable NPTL, otherwise Coro needs to be configured with the |
… | |
… | |
1162 | twice the address space needed for stacks). |
1173 | twice the address space needed for stacks). |
1163 | |
1174 | |
1164 | If you use C<linuxthreads.old>, then you should also be aware that |
1175 | If you use C<linuxthreads.old>, then you should also be aware that |
1165 | uClibc shares C<errno> between all threads when statically linking. See |
1176 | uClibc shares C<errno> between all threads when statically linking. See |
1166 | L<http://lists.uclibc.org/pipermail/uclibc/2010-June/044157.html> for a |
1177 | L<http://lists.uclibc.org/pipermail/uclibc/2010-June/044157.html> for a |
1167 | workaround (And L<https://bugs.uclibc.org/2089> for discussion). |
1178 | workaround (and L<https://bugs.uclibc.org/2089> for discussion). |
1168 | |
1179 | |
1169 | C<ccache> support is also recommended, especially if you want |
1180 | C<ccache> support is also recommended, especially if you want |
1170 | to play around with buildroot options. Enabling the C<miniperl> |
1181 | to play around with buildroot options. Enabling the C<miniperl> |
1171 | package will probably enable all options required for a successful |
1182 | package will probably enable all options required for a successful |
1172 | perl build. F<staticperl> itself additionally needs either C<wget> |
1183 | perl build. F<staticperl> itself additionally needs either C<wget> |
… | |
… | |
1180 | it from working properly in a chroot - either use dash (and link it to |
1191 | it from working properly in a chroot - either use dash (and link it to |
1181 | F</bin/sh> inside the chroot) or link busybox to F</bin/sh>, using it's |
1192 | F</bin/sh> inside the chroot) or link busybox to F</bin/sh>, using it's |
1182 | built-in ash shell. |
1193 | built-in ash shell. |
1183 | |
1194 | |
1184 | Finally, you need F</dev/null> inside the chroot for many scripts to work |
1195 | Finally, you need F</dev/null> inside the chroot for many scripts to work |
1185 | - F<cp /dev/null output/target/dev> or bind-mounting your F</dev> will |
1196 | - either F<cp /dev/null output/target/dev> or bind-mounting your F</dev> |
1186 | both provide this. |
1197 | will provide this. |
1187 | |
1198 | |
1188 | After you have compiled and set up your buildroot target, you can copy |
1199 | After you have compiled and set up your buildroot target, you can copy |
1189 | F<staticperl> from the C<App::Staticperl> distribution or from your |
1200 | F<staticperl> from the C<App::Staticperl> distribution or from your |
1190 | perl f<bin> directory (if you installed it) into the F<output/target> |
1201 | perl F<bin> directory (if you installed it) into the F<output/target> |
1191 | filesystem, chroot inside and run it. |
1202 | filesystem, chroot inside and run it. |
1192 | |
1203 | |
1193 | =head1 RECIPES / SPECIFIC MODULES |
1204 | =head1 RECIPES / SPECIFIC MODULES |
1194 | |
1205 | |
1195 | This section contains some common(?) recipes and information about |
1206 | This section contains some common(?) recipes and information about |