1 If you read this file _as_is_, just ignore the funny characters you
2 see. It is written in the POD format (see perlpod manpage) which is
3 specially designed to be readable as is.
7 perlos2 - Perl under OS/2, DOS, Win0.3*, Win0.95 and WinNT.
11 One can read this document in the following formats:
18 to list some (not all may be available simultaneously), or it may
19 be read I<as is>: either as F<README.os2>, or F<pod/perlos2.pod>.
21 To read the F<.INF> version of documentation (B<very> recommended)
22 outside of OS/2, one needs an IBM's reader (may be available on IBM
23 ftp sites (?) (URL anyone?)) or shipped with PC DOS 7.0 and IBM's
26 A copy of a Win* viewer is contained in the "Just add OS/2 Warp" package
28 ftp://ftp.software.ibm.com/ps/products/os2/tools/jaow/jaow.zip
30 in F<?:\JUST_ADD\view.exe>. This gives one an access to EMX's
31 F<.INF> docs as well (text form is available in F</emx/doc> in
34 Note that if you have F<lynx.exe> installed, you can follow WWW links
35 from this document in F<.INF> format. If you have EMX docs installed
36 correctly, you can follow library links (you need to have C<view emxbook>
37 working by setting C<EMXBOOK> environment variable as it is described
44 perlos2 - Perl under OS/2, DOS, Win0.3*, Win0.95 and WinNT.
52 - Starting Perl programs under OS/2 (and DOS and...)
53 - Starting OS/2 (and DOS) programs under Perl
54 Frequently asked questions
55 - I cannot run external programs
56 - I cannot embed perl into my program, or use perl.dll from my program.
57 - `` and pipe-open do not work under DOS.
58 - Cannot start find.exe "pattern" file
60 - Automatic binary installation
61 - Manual binary installation
63 Accessing documentation
74 - Application of the patches
78 - Installing the built perl
81 - Some / became \ in pdksh.
82 - 'errno' - unresolved external
84 - Some problem (forget which ;-)
85 - Library ... not found
87 Specific (mis)features of EMX port
88 - setpriority, getpriority
90 - extproc on the first line
101 - Why dynamic linking?
113 - Calls to external programs
123 The target is to make OS/2 the best supported platform for
124 using/building/developing Perl and I<Perl applications>, as well as
125 make Perl the best language to use under OS/2. The secondary target is
126 to try to make this work under DOS and Win* as well (but not B<too> hard).
128 The current state is quite close to this target. Known limitations:
134 Some *nix programs use fork() a lot; with the mostly useful flavors of perl
135 for OS/2 (there are several built simultaneously) this is supported;
136 some flavors do not. Using fork() after I<use>ing dynamically loading
137 extensions would not work with very old versions of EMX.
141 You need a separate perl executable F<perl__.exe> (see L<perl__.exe>)
142 if you want to use PM code in your application (as Perl/Tk or OpenGL
143 Perl modules do) without having a text-mode window present.
145 While using the standard F<perl.exe> from a text-mode window is possible
146 too, I have seen cases when this causes degradation of the system stability.
147 Using F<perl__.exe> avoids such a degradation.
151 There is no simple way to access WPS objects. The only way I know
152 is via C<OS2::REXX> extension (see L<OS2::REXX>), and we do not have access to
153 convenience methods of Object-REXX. (Is it possible at all? I know
154 of no Object-REXX API.) The C<SOM> extension (currently in alpha-text)
155 may eventually remove this shortcoming.
159 Please keep this list up-to-date by informing me about other items.
163 Since OS/2 port of perl uses a remarkable EMX environment, it can
164 run (and build extensions, and - possibly - be built itself) under any
165 environment which can run EMX. The current list is DOS,
166 DOS-inside-OS/2, Win0.3*, Win0.95 and WinNT. Out of many perl flavors,
167 only one works, see L<"perl_.exe">.
169 Note that not all features of Perl are available under these
170 environments. This depends on the features the I<extender> - most
171 probably RSX - decided to implement.
173 Cf. L<Prerequisites>.
181 EMX runtime is required (may be substituted by RSX). Note that
182 it is possible to make F<perl_.exe> to run under DOS without any
183 external support by binding F<emx.exe>/F<rsx.exe> to it, see L<emxbind>. Note
184 that under DOS for best results one should use RSX runtime, which
185 has much more functions working (like C<fork>, C<popen> and so on). In
186 fact RSX is required if there is no VCPI present. Note the
189 Only the latest runtime is supported, currently C<0.9d fix 03>. Perl may run
190 under earlier versions of EMX, but this is not tested.
192 One can get different parts of EMX from, say
194 http://www.leo.org/pub/comp/os/os2/leo/gnu/emx+gcc/
195 http://powerusersbbs.com/pub/os2/dev/ [EMX+GCC Development]
196 http://hobbes.nmsu.edu/pub/os2/dev/emx/v0.9d/
198 The runtime component should have the name F<emxrt.zip>.
200 B<NOTE>. It is enough to have F<emx.exe>/F<rsx.exe> on your path. One
201 does not need to specify them explicitly (though this
209 To run Perl on DPMI platforms one needs RSX runtime. This is
210 needed under DOS-inside-OS/2, Win0.3*, Win0.95 and WinNT (see
211 L<"Other OSes">). RSX would not work with VCPI
212 only, as EMX would, it requires DMPI.
214 Having RSX and the latest F<sh.exe> one gets a fully functional
215 B<*nix>-ish environment under DOS, say, C<fork>, C<``> and
216 pipe-C<open> work. In fact, MakeMaker works (for static build), so one
217 can have Perl development environment under DOS.
219 One can get RSX from, say
221 ftp://ftp.cdrom.com/pub/os2/emx09c/contrib
222 ftp://ftp.uni-bielefeld.de/pub/systems/msdos/misc
223 ftp://ftp.leo.org/pub/comp/os/os2/leo/devtools/emx+gcc/contrib
225 Contact the author on C<rainer@mathematik.uni-bielefeld.de>.
227 The latest F<sh.exe> with DOS hooks is available in
229 ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/
231 as F<sh_dos.zip> or under similar names starting with C<sh>, C<pdksh> etc.
235 Perl does not care about file systems, but to install the whole perl
236 library intact one needs a file system which supports long file names.
238 Note that if you do not plan to build the perl itself, it may be
239 possible to fool EMX to truncate file names. This is not supported,
240 read EMX docs to see how to do it.
244 To start external programs with complicated command lines (like with
245 pipes in between, and/or quoting of arguments), Perl uses an external
246 shell. With EMX port such shell should be named F<sh.exe>, and located
247 either in the wired-in-during-compile locations (usually F<F:/bin>),
248 or in configurable location (see L<"PERL_SH_DIR">).
250 For best results use EMX pdksh. The standard binary (5.2.14 or later) runs
251 under DOS (with L<RSX>) as well, see
253 ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/
257 =head2 Starting Perl programs under OS/2 (and DOS and...)
259 Start your Perl program F<foo.pl> with arguments C<arg1 arg2 arg3> the
260 same way as on any other platform, by
262 perl foo.pl arg1 arg2 arg3
264 If you want to specify perl options C<-my_opts> to the perl itself (as
265 opposed to your program), use
267 perl -my_opts foo.pl arg1 arg2 arg3
269 Alternately, if you use OS/2-ish shell, like CMD or 4os2, put
270 the following at the start of your perl script:
272 extproc perl -S -my_opts
274 rename your program to F<foo.cmd>, and start it by typing
278 Note that because of stupid OS/2 limitations the full path of the perl
279 script is not available when you use C<extproc>, thus you are forced to
280 use C<-S> perl switch, and your script should be on the C<PATH>. As a plus
281 side, if you know a full path to your script, you may still start it
284 perl ../../blah/foo.cmd arg1 arg2 arg3
286 (note that the argument C<-my_opts> is taken care of by the C<extproc> line
287 in your script, see L<C<extproc> on the first line>).
289 To understand what the above I<magic> does, read perl docs about C<-S>
290 switch - see L<perlrun>, and cmdref about C<extproc>:
297 or whatever method you prefer.
299 There are also endless possibilities to use I<executable extensions> of
300 4os2, I<associations> of WPS and so on... However, if you use
301 *nixish shell (like F<sh.exe> supplied in the binary distribution),
302 you need to follow the syntax specified in L<perlrun/"Switches">.
304 Note that B<-S> switch enables a search with additional extensions
305 F<.cmd>, F<.btm>, F<.bat>, F<.pl> as well.
307 =head2 Starting OS/2 (and DOS) programs under Perl
309 This is what system() (see L<perlfunc/system>), C<``> (see
310 L<perlop/"I/O Operators">), and I<open pipe> (see L<perlfunc/open>)
311 are for. (Avoid exec() (see L<perlfunc/exec>) unless you know what you
314 Note however that to use some of these operators you need to have a
315 sh-syntax shell installed (see L<"Pdksh">,
316 L<"Frequently asked questions">), and perl should be able to find it
317 (see L<"PERL_SH_DIR">).
319 The cases when the shell is used are:
325 One-argument system() (see L<perlfunc/system>), exec() (see L<perlfunc/exec>)
326 with redirection or shell meta-characters;
330 Pipe-open (see L<perlfunc/open>) with the command which contains redirection
331 or shell meta-characters;
335 Backticks C<``> (see L<perlop/"I/O Operators">) with the command which contains
336 redirection or shell meta-characters;
340 If the executable called by system()/exec()/pipe-open()/C<``> is a script
341 with the "magic" C<#!> line or C<extproc> line which specifies shell;
345 If the executable called by system()/exec()/pipe-open()/C<``> is a script
346 without "magic" line, and C<$ENV{EXECSHELL}> is set to shell;
350 If the executable called by system()/exec()/pipe-open()/C<``> is not
355 For globbing (see L<perlfunc/glob>, L<perlop/"I/O Operators">).
359 For the sake of speed for a common case, in the above algorithms
360 backslashes in the command name are not considered as shell metacharacters.
362 Perl starts scripts which begin with cookies
363 C<extproc> or C<#!> directly, without an intervention of shell. Perl uses the
364 same algorithm to find the executable as F<pdksh>: if the path
365 on C<#!> line does not work, and contains C</>, then the executable
366 is searched in F<.> and on C<PATH>. To find arguments for these scripts
367 Perl uses a different algorithm than F<pdksh>: up to 3 arguments are
368 recognized, and trailing whitespace is stripped.
371 does not contain such a cooky, then to avoid calling F<sh.exe>, Perl uses
372 the same algorithm as F<pdksh>: if C<$ENV{EXECSHELL}> is set, the
373 script is given as the first argument to this command, if not set, then
374 C<$ENV{COMSPEC} /c> is used (or a hardwired guess if C<$ENV{COMSPEC}> is
377 If starting scripts directly, Perl will use exactly the same algorithm as for
378 the search of script given by B<-S> command-line option: it will look in
379 the current directory, then on components of C<$ENV{PATH}> using the
380 following order of appended extensions: no extension, F<.cmd>, F<.btm>,
383 Note that Perl will start to look for scripts only if OS/2 cannot start the
384 specified application, thus C<system 'blah'> will not look for a script if
385 there is an executable file F<blah.exe> I<anywhere> on C<PATH>.
387 Note also that executable files on OS/2 can have an arbitrary extension,
388 but F<.exe> will be automatically appended if no dot is present in the name.
389 The workaround is as simple as that: since F<blah.> and F<blah> denote the
390 same file, to start an executable residing in file F<n:/bin/blah> (no
391 extension) give an argument C<n:/bin/blah.> (dot appended) to system().
393 Perl will correctly start PM programs from VIO (=text-mode) Perl process;
394 the opposite is not true: when you start a non-PM program from a PM
395 Perl process, it would not run it in a separate session. If a separate
396 session is desired, either ensure
397 that shell will be used, as in C<system 'cmd /c myprog'>, or start it using
398 optional arguments to system() documented in C<OS2::Process> module. This
399 is considered to be a feature.
401 =head1 Frequently asked questions
403 =head2 "It does not work"
405 Perl binary distributions come with a F<testperl.cmd> script which tries
406 to detect common problems with misconfigured installations. There is a
407 pretty large chance it will discover which step of the installation you
408 managed to goof. C<;-)>
410 =head2 I cannot run external programs
416 Did you run your programs with C<-w> switch? See
417 L<Starting OS/2 (and DOS) programs under Perl>.
421 Do you try to run I<internal> shell commands, like C<`copy a b`>
422 (internal for F<cmd.exe>), or C<`glob a*b`> (internal for ksh)? You
423 need to specify your shell explicitly, like C<`cmd /c copy a b`>,
424 since Perl cannot deduce which commands are internal to your shell.
428 =head2 I cannot embed perl into my program, or use F<perl.dll> from my
433 =item Is your program EMX-compiled with C<-Zmt -Zcrtdll>?
435 If not, you need to build a stand-alone DLL for perl. Contact me, I
436 did it once. Sockets would not work, as a lot of other stuff.
438 =item Did you use L<ExtUtils::Embed>?
440 I had reports it does not work. Somebody would need to fix it.
444 =head2 C<``> and pipe-C<open> do not work under DOS.
446 This may a variant of just L<"I cannot run external programs">, or a
447 deeper problem. Basically: you I<need> RSX (see L<"Prerequisites">)
448 for these commands to work, and you may need a port of F<sh.exe> which
449 understands command arguments. One of such ports is listed in
450 L<"Prerequisites"> under RSX. Do not forget to set variable
451 C<L<"PERL_SH_DIR">> as well.
453 DPMI is required for RSX.
455 =head2 Cannot start C<find.exe "pattern" file>
459 system 'cmd', '/c', 'find "pattern" file';
460 `cmd /c 'find "pattern" file'`
462 This would start F<find.exe> via F<cmd.exe> via C<sh.exe> via
463 C<perl.exe>, but this is a price to pay if you want to use
464 non-conforming program. In fact F<find.exe> cannot be started at all
465 using C library API only. Otherwise the following command-lines would be
473 =head2 Automatic binary installation
475 The most convenient way of installing a binary distribution of perl is via perl installer
476 F<install.exe>. Just follow the instructions, and 99% of the
477 installation blues would go away.
479 Note however, that you need to have F<unzip.exe> on your path, and
480 EMX environment I<running>. The latter means that if you just
481 installed EMX, and made all the needed changes to F<Config.sys>,
482 you may need to reboot in between. Check EMX runtime by running
486 A folder is created on your desktop which contains some useful
489 B<Things not taken care of by automatic binary installation:>
493 =item C<PERL_BADLANG>
495 may be needed if you change your codepage I<after> perl installation,
496 and the new value is not supported by EMX. See L<"PERL_BADLANG">.
498 =item C<PERL_BADFREE>
500 see L<"PERL_BADFREE">.
504 This file resides somewhere deep in the location you installed your
505 perl library, find it out by
507 perl -MConfig -le "print $INC{'Config.pm'}"
509 While most important values in this file I<are> updated by the binary
510 installer, some of them may need to be hand-edited. I know no such
511 data, please keep me informed if you find one.
515 B<NOTE>. Because of a typo the binary installer of 5.00305
516 would install a variable C<PERL_SHPATH> into F<Config.sys>. Please
517 remove this variable and put C<L<PERL_SH_DIR>> instead.
519 =head2 Manual binary installation
521 As of version 5.00305, OS/2 perl binary distribution comes split
522 into 11 components. Unfortunately, to enable configurable binary
523 installation, the file paths in the zip files are not absolute, but
524 relative to some directory.
526 Note that the extraction with the stored paths is still necessary
527 (default with unzip, specify C<-d> to pkunzip). However, you
528 need to know where to extract the files. You need also to manually
529 change entries in F<Config.sys> to reflect where did you put the
530 files. Note that if you have some primitive unzipper (like
531 pkunzip), you may get a lot of warnings/errors during
532 unzipping. Upgrade to C<(w)unzip>.
534 Below is the sample of what to do to reproduce the configuration on my
539 =item Perl VIO and PM executables (dynamically linked)
541 unzip perl_exc.zip *.exe *.ico -d f:/emx.add/bin
542 unzip perl_exc.zip *.dll -d f:/emx.add/dll
544 (have the directories with C<*.exe> on PATH, and C<*.dll> on
547 =item Perl_ VIO executable (statically linked)
549 unzip perl_aou.zip -d f:/emx.add/bin
551 (have the directory on PATH);
553 =item Executables for Perl utilities
555 unzip perl_utl.zip -d f:/emx.add/bin
557 (have the directory on PATH);
559 =item Main Perl library
561 unzip perl_mlb.zip -d f:/perllib/lib
563 If this directory is exactly the same as the prefix which was compiled
564 into F<perl.exe>, you do not need to change
565 anything. However, for perl to find the library if you use a different
567 C<set PERLLIB_PREFIX> in F<Config.sys>, see L<"PERLLIB_PREFIX">.
569 =item Additional Perl modules
571 unzip perl_ste.zip -d f:/perllib/lib/site_perl/5.8.3/
573 Same remark as above applies. Additionally, if this directory is not
574 one of directories on @INC (and @INC is influenced by C<PERLLIB_PREFIX>), you
576 directory and subdirectory F<./os2> in C<PERLLIB> or C<PERL5LIB>
577 variable. Do not use C<PERL5LIB> unless you have it set already. See
578 L<perl/"ENVIRONMENT">.
580 =item Tools to compile Perl modules
582 unzip perl_blb.zip -d f:/perllib/lib
584 Same remark as for F<perl_ste.zip>.
586 =item Manpages for Perl and utilities
588 unzip perl_man.zip -d f:/perllib/man
590 This directory should better be on C<MANPATH>. You need to have a
591 working man to access these files.
593 =item Manpages for Perl modules
595 unzip perl_mam.zip -d f:/perllib/man
597 This directory should better be on C<MANPATH>. You need to have a
598 working man to access these files.
600 =item Source for Perl documentation
602 unzip perl_pod.zip -d f:/perllib/lib
604 This is used by the C<perldoc> program (see L<perldoc>), and may be used to
605 generate HTML documentation usable by WWW browsers, and
606 documentation in zillions of other formats: C<info>, C<LaTeX>,
607 C<Acrobat>, C<FrameMaker> and so on.
609 =item Perl manual in F<.INF> format
611 unzip perl_inf.zip -d d:/os2/book
613 This directory should better be on C<BOOKSHELF>.
617 unzip perl_sh.zip -d f:/bin
619 This is used by perl to run external commands which explicitly
620 require shell, like the commands using I<redirection> and I<shell
621 metacharacters>. It is also used instead of explicit F</bin/sh>.
623 Set C<PERL_SH_DIR> (see L<"PERL_SH_DIR">) if you move F<sh.exe> from
626 B<Note.> It may be possible to use some other sh-compatible shell
627 (file globbing - if done via shell - may break).
631 After you installed the components you needed and updated the
632 F<Config.sys> correspondingly, you need to hand-edit
633 F<Config.pm>. This file resides somewhere deep in the location you
634 installed your perl library, find it out by
636 perl -MConfig -le "print $INC{'Config.pm'}"
638 You need to correct all the entries which look like file paths (they
639 currently start with C<f:/>).
643 The automatic and manual perl installation leave precompiled paths
644 inside perl executables. While these paths are overwriteable (see
645 L<"PERLLIB_PREFIX">, L<"PERL_SH_DIR">), one may get better results by
646 binary editing of paths inside the executables/DLLs.
648 =head1 Accessing documentation
650 Depending on how you built/installed perl you may have (otherwise
651 identical) Perl documentation in the following formats:
653 =head2 OS/2 F<.INF> file
655 Most probably the most convenient form. Under OS/2 view it as
660 view perl ExtUtils::MakeMaker
662 (currently the last two may hit a wrong location, but this may improve
663 soon). Under Win* see L<"SYNOPSIS">.
665 If you want to build the docs yourself, and have I<OS/2 toolkit>, run
669 in F</perllib/lib/pod> directory, then
673 (Expect a lot of errors during the both steps.) Now move it on your
678 If you have perl documentation in the source form, perl utilities
679 installed, and GNU groff installed, you may use
683 perldoc ExtUtils::MakeMaker
685 to access the perl documentation in the text form (note that you may get
686 better results using perl manpages).
688 Alternately, try running pod2text on F<.pod> files.
692 If you have man installed on your system, and you installed perl
693 manpages, use something like this:
697 man ExtUtils.MakeMaker
699 to access documentation for different components of Perl. Start with
703 Note that dot (F<.>) is used as a package separator for documentation
704 for packages, and as usual, sometimes you need to give the section - C<3>
705 above - to avoid shadowing by the I<less(1) manpage>.
707 Make sure that the directory B<above> the directory with manpages is
708 on our C<MANPATH>, like this
710 set MANPATH=c:/man;f:/perllib/man
712 for Perl manpages in C<f:/perllib/man/man1/> etc.
716 If you have some WWW browser available, installed the Perl
717 documentation in the source form, and Perl utilities, you can build
718 HTML docs. Cd to directory with F<.pod> files, and do like this
720 cd f:/perllib/lib/pod
723 After this you can direct your browser the file F<perl.html> in this
724 directory, and go ahead with reading docs, like this:
726 explore file:///f:/perllib/lib/pod/perl.html
728 Alternatively you may be able to get these docs prebuilt from CPAN.
730 =head2 GNU C<info> files
732 Users of Emacs would appreciate it very much, especially with
733 C<CPerl> mode loaded. You need to get latest C<pod2info> from C<CPAN>,
734 or, alternately, prebuilt info pages.
738 for C<Acrobat> are available on CPAN (for slightly old version of
743 can be constructed using C<pod2latex>.
747 Here we discuss how to build Perl under OS/2. There is an alternative
748 (but maybe older) view on http://www.shadow.net/~troc/os2perl.html
750 =head2 The short story
752 Assume that you are a seasoned porter, so are sure that all the necessary
753 tools are already present on your system, and you know how to get the Perl
754 source distribution. Untar it, change to the extract directory, and
756 gnupatch -p0 < os2\diff.configure
757 sh Configure -des -D prefix=f:/perllib
764 This puts the executables in f:/perllib/bin. Manually move them to the
765 C<PATH>, manually move the built F<perl*.dll> to C<LIBPATH> (here F<*> is
766 a not-very-meaningful hex checksum), and run
768 make installcmd INSTALLCMDDIR=d:/ir/on/path
770 What follows is a detailed guide through these steps.
774 You need to have the latest EMX development environment, the full
775 GNU tool suite (gawk renamed to awk, and GNU F<find.exe>
776 earlier on path than the OS/2 F<find.exe>, same with F<sort.exe>, to
782 ). You need the latest version of F<pdksh> installed as F<sh.exe>.
784 Check that you have B<BSD> libraries and headers installed, and -
785 optionally - Berkeley DB headers and libraries, and crypt.
787 Possible locations to get this from are
789 ftp://hobbes.nmsu.edu/os2/unix/
790 ftp://ftp.cdrom.com/pub/os2/unix/
791 ftp://ftp.cdrom.com/pub/os2/dev32/
792 ftp://ftp.cdrom.com/pub/os2/emx09c/
794 It is reported that the following archives contain enough utils to
795 build perl: F<gnufutil.zip>, F<gnusutil.zip>, F<gnututil.zip>, F<gnused.zip>,
796 F<gnupatch.zip>, F<gnuawk.zip>, F<gnumake.zip>, F<bsddev.zip> and
797 F<ksh527rt.zip> (or a later version). Note that all these utilities are
798 known to be available from LEO:
800 ftp://ftp.leo.org/pub/comp/os/os2/leo/gnu
802 If you have I<exactly the same version of Perl> installed already,
803 make sure that no copies or perl are currently running. Later steps
804 of the build may fail since an older version of F<perl.dll> loaded into
807 Also make sure that you have F</tmp> directory on the current drive,
808 and F<.> directory in your C<LIBPATH>. One may try to correct the
813 if you use something like F<CMD.EXE> or latest versions of F<4os2.exe>.
815 Make sure your gcc is good for C<-Zomf> linking: run C<omflibs>
816 script in F</emx/lib> directory.
818 Check that you have link386 installed. It comes standard with OS/2,
819 but may be not installed due to customization. If typing
823 shows you do not have it, do I<Selective install>, and choose C<Link
824 object modules> in I<Optional system utilities/More>. If you get into
825 link386 prompts, press C<Ctrl-C> to exit.
827 =head2 Getting perl source
829 You need to fetch the latest perl source (including developers
830 releases). With some probability it is located in
832 http://www.cpan.org/src/5.0
833 http://www.cpan.org/src/5.0/unsupported
835 If not, you may need to dig in the indices to find it in the directory
836 of the current maintainer.
838 Quick cycle of developers release may break the OS/2 build time to
841 http://www.cpan.org/ports/os2/ilyaz/
843 may indicate the latest release which was publicly released by the
844 maintainer. Note that the release may include some additional patches
845 to apply to the current source of perl.
849 tar vzxf perl5.00409.tar.gz
851 You may see a message about errors while extracting F<Configure>. This is
852 because there is a conflict with a similarly-named file F<configure>.
854 Change to the directory of extraction.
856 =head2 Application of the patches
858 You need to apply the patches in F<./os2/diff.*> like this:
860 gnupatch -p0 < os2\diff.configure
862 You may also need to apply the patches supplied with the binary
863 distribution of perl.
865 Note also that the F<db.lib> and F<db.a> from the EMX distribution
866 are not suitable for multi-threaded compile (even single-threaded
867 flavor of Perl uses multi-threaded C RTL, for
868 compatibility with XFree86-OS/2). Get a corrected one from
870 ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/db_mt.zip
874 You may look into the file F<./hints/os2.sh> and correct anything
875 wrong you find there. I do not expect it is needed anywhere.
879 sh Configure -des -D prefix=f:/perllib
881 C<prefix> means: where to install the resulting perl library. Giving
882 correct prefix you may avoid the need to specify C<PERLLIB_PREFIX>,
883 see L<"PERLLIB_PREFIX">.
885 I<Ignore the message about missing C<ln>, and about C<-c> option to
886 tr>. The latter is most probably already fixed, if you see it and can trace
887 where the latter spurious warning comes from, please inform me.
893 At some moment the built may die, reporting a I<version mismatch> or
894 I<unable to run F<perl>>. This means that you do not have F<.> in
895 your LIBPATH, so F<perl.exe> cannot find the needed F<perl67B2.dll> (treat
896 these hex digits as line noise). After this is fixed the build
897 should finish without a lot of fuss.
905 All tests should succeed (with some of them skipped).
907 Some tests may generate extra messages similar to
911 =item A lot of C<bad free>
913 in database tests related to Berkeley DB. I<This should be fixed already.>
914 If it persists, you may disable this warnings, see L<"PERL_BADFREE">.
916 =item Process terminated by SIGTERM/SIGINT
918 This is a standard message issued by OS/2 applications. *nix
919 applications die in silence. It is considered to be a feature. One can
920 easily disable this by appropriate sighandlers.
922 However the test engine bleeds these message to screen in unexpected
923 moments. Two messages of this kind I<should> be present during
928 To get finer test reports, call
932 The report with F<io/pipe.t> failing may look like this:
934 Failed Test Status Wstat Total Fail Failed List of failed
935 ------------------------------------------------------------
936 io/pipe.t 12 1 8.33% 9
937 7 tests skipped, plus 56 subtests skipped.
938 Failed 1/195 test scripts, 99.49% okay. 1/6542 subtests failed, 99.98% okay.
940 The reasons for most important skipped tests are:
950 Checks C<atime> and C<mtime> of C<stat()> - unfortunately, HPFS
951 provides only 2sec time granularity (for compatibility with FAT?).
955 Checks C<truncate()> on a filehandle just opened for write - I do not
956 know why this should or should not work.
962 Checks C<stat()>. Tests:
968 Checks C<atime> and C<mtime> of C<stat()> - unfortunately, HPFS
969 provides only 2sec time granularity (for compatibility with FAT?).
975 =head2 Installing the built perl
977 If you haven't yet moved perl.dll onto LIBPATH, do it now.
983 It would put the generated files into needed locations. Manually put
984 F<perl.exe>, F<perl__.exe> and F<perl___.exe> to a location on your
985 PATH, F<perl.dll> to a location on your LIBPATH.
989 make installcmd INSTALLCMDDIR=d:/ir/on/path
991 to convert perl utilities to F<.cmd> files and put them on
992 PATH. You need to put F<.EXE>-utilities on path manually. They are
993 installed in C<$prefix/bin>, here C<$prefix> is what you gave to
994 F<Configure>, see L<Making>.
996 =head2 C<a.out>-style build
998 Proceed as above, but make F<perl_.exe> (see L<"perl_.exe">) by
1007 Manually put F<perl_.exe> to a location on your PATH.
1009 B<Note.> The build process for C<perl_> I<does not know> about all the
1010 dependencies, so you should make sure that anything is up-to-date,
1019 =head2 Some C</> became C<\> in pdksh.
1021 You have a very old pdksh. See L<Prerequisites>.
1023 =head2 C<'errno'> - unresolved external
1025 You do not have MT-safe F<db.lib>. See L<Prerequisites>.
1027 =head2 Problems with tr or sed
1029 reported with very old version of tr and sed.
1031 =head2 Some problem (forget which ;-)
1033 You have an older version of F<perl.dll> on your LIBPATH, which
1034 broke the build of extensions.
1036 =head2 Library ... not found
1038 You did not run C<omflibs>. See L<Prerequisites>.
1040 =head2 Segfault in make
1042 You use an old version of GNU make. See L<Prerequisites>.
1044 =head2 op/sprintf test failure
1046 This can result from a bug in emx sprintf which was fixed in 0.9d fix 03.
1048 =head1 Specific (mis)features of OS/2 port
1050 =head2 C<setpriority>, C<getpriority>
1052 Note that these functions are compatible with *nix, not with the older
1053 ports of '94 - 95. The priorities are absolute, go from 32 to -95,
1054 lower is quicker. 0 is the default priority.
1056 B<WARNING>. Calling C<getpriority> on a non-existing process could lock
1057 the system before Warp3 fixpak22. Starting with Warp3, Perl will use
1058 a workaround: it aborts getpriority() if the process is not present.
1059 This is not possible on older versions C<2.*>, and has a race
1064 Multi-argument form of C<system()> allows an additional numeric
1065 argument. The meaning of this argument is described in
1068 When finding a program to run, Perl first asks the OS to look for executables
1069 on C<PATH> (OS/2 adds extension F<.exe> if no extension is present).
1070 If not found, it looks for a script with possible extensions
1071 added in this order: no extension, F<.cmd>, F<.btm>,
1072 F<.bat>, F<.pl>. If found, Perl checks the start of the file for magic
1073 strings C<"#!"> and C<"extproc ">. If found, Perl uses the rest of the
1074 first line as the beginning of the command line to run this script. The
1075 only mangling done to the first line is extraction of arguments (currently
1076 up to 3), and ignoring of the path-part of the "interpreter" name if it can't
1077 be found using the full path.
1079 E.g., C<system 'foo', 'bar', 'baz'> may lead Perl to finding
1080 F<C:/emx/bin/foo.cmd> with the first line being
1082 extproc /bin/bash -x -c
1084 If F</bin/bash.exe> is not found, then Perl looks for an executable F<bash.exe> on
1085 C<PATH>. If found in F<C:/emx.add/bin/bash.exe>, then the above system() is
1088 system qw(C:/emx.add/bin/bash.exe -x -c C:/emx/bin/foo.cmd bar baz)
1090 One additional translation is performed: instead of F</bin/sh> Perl uses
1091 the hardwired-or-customized shell (see C<L<"PERL_SH_DIR">>).
1093 The above search for "interpreter" is recursive: if F<bash> executable is not
1094 found, but F<bash.btm> is found, Perl will investigate its first line etc.
1095 The only hardwired limit on the recursion depth is implicit: there is a limit
1096 4 on the number of additional arguments inserted before the actual arguments
1097 given to system(). In particular, if no additional arguments are specified
1098 on the "magic" first lines, then the limit on the depth is 4.
1100 If Perl finds that the found executable is of different type than the
1101 current session, it will start the new process in a separate session of
1102 necessary type. Call via C<OS2::Process> to disable this magic.
1104 B<WARNING>. Due to the described logic, you need to explicitly
1105 specify F<.com> extension if needed. Moreover, if the executable
1106 F<perl5.6.1> is requested, Perl will not look for F<perl5.6.1.exe>.
1107 [This may change in the future.]
1109 =head2 C<extproc> on the first line
1111 If the first chars of a Perl script are C<"extproc ">, this line is treated
1112 as C<#!>-line, thus all the switches on this line are processed (twice
1113 if script was started via cmd.exe). See L<perlrun/DESCRIPTION>.
1115 =head2 Additional modules:
1117 L<OS2::Process>, L<OS2::DLL>, L<OS2::REXX>, L<OS2::PrfDB>, L<OS2::ExtAttr>. These
1118 modules provide access to additional numeric argument for C<system>
1119 and to the information about the running process,
1120 to DLLs having functions with REXX signature and to the REXX runtime, to
1121 OS/2 databases in the F<.INI> format, and to Extended Attributes.
1123 Two additional extensions by Andreas Kaiser, C<OS2::UPM>, and
1124 C<OS2::FTP>, are included into C<ILYAZ> directory, mirrored on CPAN.
1126 =head2 Prebuilt methods:
1130 =item C<File::Copy::syscopy>
1132 used by C<File::Copy::copy>, see L<File::Copy>.
1134 =item C<DynaLoader::mod2fname>
1136 used by C<DynaLoader> for DLL name mangling.
1138 =item C<Cwd::current_drive()>
1142 =item C<Cwd::sys_chdir(name)>
1144 leaves drive as it is.
1146 =item C<Cwd::change_drive(name)>
1148 chanes the "current" drive.
1150 =item C<Cwd::sys_is_absolute(name)>
1152 means has drive letter and is_rooted.
1154 =item C<Cwd::sys_is_rooted(name)>
1156 means has leading C<[/\\]> (maybe after a drive-letter:).
1158 =item C<Cwd::sys_is_relative(name)>
1160 means changes with current dir.
1162 =item C<Cwd::sys_cwd(name)>
1164 Interface to cwd from EMX. Used by C<Cwd::cwd>.
1166 =item C<Cwd::sys_abspath(name, dir)>
1168 Really really odious function to implement. Returns absolute name of
1169 file which would have C<name> if CWD were C<dir>. C<Dir> defaults to the
1172 =item C<Cwd::extLibpath([type])>
1174 Get current value of extended library search path. If C<type> is
1175 present and I<true>, works with END_LIBPATH, otherwise with
1178 =item C<Cwd::extLibpath_set( path [, type ] )>
1180 Set current value of extended library search path. If C<type> is
1181 present and I<true>, works with END_LIBPATH, otherwise with
1184 =item C<OS2::Error(do_harderror,do_exception)>
1186 Returns C<undef> if it was not called yet, otherwise bit 1 is
1187 set if on the previous call do_harderror was enabled, bit
1188 2 is set if on previous call do_exception was enabled.
1190 This function enables/disables error popups associated with
1191 hardware errors (Disk not ready etc.) and software exceptions.
1193 I know of no way to find out the state of popups I<before> the first call
1196 =item C<OS2::Errors2Drive(drive)>
1198 Returns C<undef> if it was not called yet, otherwise return false if errors
1199 were not requested to be written to a hard drive, or the drive letter if
1202 This function may redirect error popups associated with hardware errors
1203 (Disk not ready etc.) and software exceptions to the file POPUPLOG.OS2 at
1204 the root directory of the specified drive. Overrides OS2::Error() specified
1205 by individual programs. Given argument undef will disable redirection.
1207 Has global effect, persists after the application exits.
1209 I know of no way to find out the state of redirection of popups to the disk
1210 I<before> the first call to this function.
1212 =item OS2::SysInfo()
1214 Returns a hash with system information. The keys of the hash are
1216 MAX_PATH_LENGTH, MAX_TEXT_SESSIONS, MAX_PM_SESSIONS,
1217 MAX_VDM_SESSIONS, BOOT_DRIVE, DYN_PRI_VARIATION,
1218 MAX_WAIT, MIN_SLICE, MAX_SLICE, PAGE_SIZE,
1219 VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION,
1220 MS_COUNT, TIME_LOW, TIME_HIGH, TOTPHYSMEM, TOTRESMEM,
1221 TOTAVAILMEM, MAXPRMEM, MAXSHMEM, TIMER_INTERVAL,
1222 MAX_COMP_LENGTH, FOREGROUND_FS_SESSION,
1225 =item OS2::BootDrive()
1227 Returns a letter without colon.
1229 =item C<OS2::MorphPM(serve)>, C<OS2::UnMorphPM(serve)>
1231 Transforms the current application into a PM application and back.
1232 The argument true means that a real message loop is going to be served.
1233 OS2::MorphPM() returns the PM message queue handle as an integer.
1235 See L<"Centralized management of resources"> for additional details.
1237 =item C<OS2::Serve_Messages(force)>
1239 Fake on-demand retrieval of outstanding PM messages. If C<force> is false,
1240 will not dispatch messages if a real message loop is known to
1241 be present. Returns number of messages retrieved.
1243 Dies with "QUITing..." if WM_QUIT message is obtained.
1245 =item C<OS2::Process_Messages(force [, cnt])>
1247 Retrieval of PM messages until window creation/destruction.
1248 If C<force> is false, will not dispatch messages if a real message loop
1249 is known to be present.
1251 Returns change in number of windows. If C<cnt> is given,
1252 it is incremented by the number of messages retrieved.
1254 Dies with "QUITing..." if WM_QUIT message is obtained.
1256 =item C<OS2::_control87(new,mask)>
1258 the same as L<_control87(3)> of EMX. Takes integers as arguments, returns
1259 the previous coprocessor control word as an integer. Only bits in C<new> which
1260 are present in C<mask> are changed in the control word.
1262 =item OS2::get_control87()
1264 gets the coprocessor control word as an integer.
1266 =item C<OS2::set_control87_em(new=MCW_EM,mask=MCW_EM)>
1268 The variant of OS2::_control87() with default values good for
1269 handling exception mask: if no C<mask>, uses exception mask part of C<new>
1270 only. If no C<new>, disables all the floating point exceptions.
1272 See L<"Misfeatures"> for details.
1276 (Note that some of these may be moved to different libraries -
1280 =head2 Prebuilt variables:
1286 same as _emx_rev of EMX, a string similar to C<0.9c>.
1290 same as _emx_env of EMX, a number similar to 0x8001.
1294 a number C<OS_MAJOR + 0.001 * OS_MINOR>.
1304 Since L<flock(3)> is present in EMX, but is not functional, it is
1305 emulated by perl. To disable the emulations, set environment variable
1306 C<USE_PERL_FLOCK=0>.
1310 Here is the list of things which may be "broken" on
1311 EMX (from EMX docs):
1317 The functions L<recvmsg(3)>, L<sendmsg(3)>, and L<socketpair(3)> are not
1322 L<sock_init(3)> is not required and not implemented.
1326 L<flock(3)> is not yet implemented (dummy function). (Perl has a workaround.)
1330 L<kill(3)>: Special treatment of PID=0, PID=1 and PID=-1 is not implemented.
1338 waitpid() is not implemented for negative values of PID.
1342 Note that C<kill -9> does not work with the current version of EMX.
1346 Since F<sh.exe> is used for globing (see L<perlfunc/glob>), the bugs
1347 of F<sh.exe> plague perl as well.
1349 In particular, uppercase letters do not work in C<[...]>-patterns with
1354 Unix-domain sockets on OS/2 live in a pseudo-file-system C</sockets/...>.
1355 To avoid a failure to create a socket with a name of a different form,
1356 C<"/socket/"> is prepended to the socket name (unless it starts with this
1359 This may lead to problems later in case the socket is accessed via the
1360 "usual" file-system calls using the "initial" name.
1364 Apparently, IBM used a compiler (for some period of time around '95?) which
1365 changes FP mask right and left. This is not I<that> bad for IBM's
1366 programs, but the same compiler was used for DLLs which are used with
1367 general-purpose applications. When these DLLs are used, the state of
1368 floating-point flags in the application is not predictable.
1370 What is much worse, some DLLs change the floating point flags when in
1371 _DLLInitTerm() (e.g., F<TCP32IP>). This means that even if you do not I<call>
1372 any function in the DLL, just the act of loading this DLL will reset your
1373 flags. What is worse, the same compiler was used to compile some HOOK DLLs.
1374 Given that HOOK dlls are executed in the context of I<all> the applications
1375 in the system, this means a complete unpredictablity of floating point
1376 flags on systems using such HOOK DLLs. E.g., F<GAMESRVR.DLL> of B<DIVE>
1377 origin changes the floating point flags on each write to the TTY of a VIO
1378 (windowed text-mode) applications.
1380 Some other (not completely debugged) situations when FP flags change include
1381 some video drivers (?), and some operations related to creation of the windows.
1382 People who code B<OpenGL> may have more experience on this.
1384 Perl is generally used in the situation when all the floating-point
1385 exceptions are ignored, as is the default under EMX. If they are not ignored,
1386 some benign Perl programs would get a C<SIGFPE> and would die a horrible death.
1388 To circumvent this, Perl uses two hacks. They help against I<one> type of
1389 damage only: FP flags changed when loading a DLL.
1391 One of the hacks is to disable floating point exceptions on startup (as
1392 is the default with EMX). This helps only with compile-time-linked DLLs
1393 changing the flags before main() had a chance to be called.
1395 The other hack is to restore FP flags after a call to dlopen(). This helps
1396 against similar damage done by DLLs _DLLInitTerm() at runtime. Currently
1397 no way to switch these hacks off is provided.
1401 =head2 Modifications
1403 Perl modifies some standard C library calls in the following ways:
1409 C<my_popen> uses F<sh.exe> if shell is required, cf. L<"PERL_SH_DIR">.
1413 is created using C<TMP> or C<TEMP> environment variable, via
1418 If the current directory is not writable, file is created using modified
1419 C<tmpnam>, so there may be a race condition.
1423 a dummy implementation.
1427 C<os2_stat> special-cases F</dev/tty> and F</dev/con>.
1429 =item C<mkdir>, C<rmdir>
1431 these EMX functions do not work if the path contains a trailing C</>.
1432 Perl contains a workaround for this.
1436 Since L<flock(3)> is present in EMX, but is not functional, it is
1437 emulated by perl. To disable the emulations, set environment variable
1438 C<USE_PERL_FLOCK=0>.
1442 =head2 Identifying DLLs
1444 All the DLLs built with the current versions of Perl have ID strings
1445 identifying the name of the extension, its version, and the version
1446 of Perl required for this DLL. Run C<bldlevel DLL-name> to find this
1449 =head2 Centralized management of resources
1451 Since to call certain OS/2 API one needs to have a correctly initialized
1452 C<Win> subsystem, OS/2-specific extensions may require getting C<HAB>s and
1453 C<HMQ>s. If an extension would do it on its own, another extension could
1456 Perl provides a centralized management of these resources:
1462 To get the HAB, the extension should call C<hab = perl_hab_GET()> in C. After
1463 this call is performed, C<hab> may be accessed as C<Perl_hab>. There is
1464 no need to release the HAB after it is used.
1466 If by some reasons F<perl.h> cannot be included, use
1468 extern int Perl_hab_GET(void);
1474 There are two cases:
1480 the extension needs an C<HMQ> only because some API will not work otherwise.
1481 Use C<serve = 0> below.
1485 the extension needs an C<HMQ> since it wants to engage in a PM event loop.
1486 Use C<serve = 1> below.
1490 To get an C<HMQ>, the extension should call C<hmq = perl_hmq_GET(serve)> in C.
1491 After this call is performed, C<hmq> may be accessed as C<Perl_hmq>.
1493 To signal to Perl that HMQ is not needed any more, call
1494 C<perl_hmq_UNSET(serve)>. Perl process will automatically morph/unmorph itself
1495 into/from a PM process if HMQ is needed/not-needed. Perl will automatically
1496 enable/disable C<WM_QUIT> message during shutdown if the message queue is
1499 B<NOTE>. If during a shutdown there is a message queue which did not disable
1500 WM_QUIT, and which did not process the received WM_QUIT message, the
1501 shutdown will be automatically cancelled. Do not call C<perl_hmq_GET(1)>
1502 unless you are going to process messages on an orderly basis.
1508 Because of idiosyncrasies of OS/2 one cannot have all the eggs in the
1509 same basket (though EMX environment tries hard to overcome this
1510 limitations, so the situation may somehow improve). There are 4
1511 executables for Perl provided by the distribution:
1515 The main workhorse. This is a chimera executable: it is compiled as an
1516 C<a.out>-style executable, but is linked with C<omf>-style dynamic
1517 library F<perl.dll>, and with dynamic CRT DLL. This executable is a
1520 It can load perl dynamic extensions, and it can fork().
1522 B<Note.> Keep in mind that fork() is needed to open a pipe to yourself.
1526 This is a statically linked C<a.out>-style executable. It cannot
1527 load dynamic Perl extensions. The executable supplied in binary
1528 distributions has a lot of extensions prebuilt, thus the above restriction is
1529 important only if you use custom-built extensions. This executable is a VIO
1532 I<This is the only executable with does not require OS/2.> The
1533 friends locked into C<M$> world would appreciate the fact that this
1534 executable runs under DOS, Win0.3*, Win0.95 and WinNT with an
1535 appropriate extender. See L<"Other OSes">.
1537 =head2 F<perl__.exe>
1539 This is the same executable as F<perl___.exe>, but it is a PM
1542 B<Note.> Usually (unless explicitly redirected during the startup)
1543 STDIN, STDERR, and STDOUT of a PM
1544 application are redirected to F<nul>. However, it is possible to I<see>
1545 them if you start C<perl__.exe> from a PM program which emulates a
1546 console window, like I<Shell mode> of Emacs or EPM. Thus it I<is
1547 possible> to use Perl debugger (see L<perldebug>) to debug your PM
1548 application (but beware of the message loop lockups - this will not
1549 work if you have a message queue to serve, unless you hook the serving
1550 into the getc() function of the debugger).
1552 Another way to see the output of a PM program is to run it as
1554 pm_prog args 2>&1 | cat -
1556 with a shell I<different> from F<cmd.exe>, so that it does not create
1557 a link between a VIO session and the session of C<pm_porg>. (Such a link
1558 closes the VIO window.) E.g., this works with F<sh.exe> - or with Perl!
1560 open P, 'pm_prog args 2>&1 |' or die;
1563 The flavor F<perl__.exe> is required if you want to start your program without
1564 a VIO window present, but not C<detach>ed (run C<help detach> for more info).
1565 Very useful for extensions which use PM, like C<Perl/Tk> or C<OpenGL>.
1567 =head2 F<perl___.exe>
1569 This is an C<omf>-style executable which is dynamically linked to
1570 F<perl.dll> and CRT DLL. I know no advantages of this executable
1571 over C<perl.exe>, but it cannot fork() at all. Well, one advantage is
1572 that the build process is not so convoluted as with C<perl.exe>.
1574 It is a VIO application.
1576 =head2 Why strange names?
1578 Since Perl processes the C<#!>-line (cf.
1579 L<perlrun/DESCRIPTION>, L<perlrun/Switches>,
1580 L<perldiag/"Not a perl script">,
1581 L<perldiag/"No Perl script found in input">), it should know when a
1582 program I<is a Perl>. There is some naming convention which allows
1583 Perl to distinguish correct lines from wrong ones. The above names are
1584 almost the only names allowed by this convention which do not contain
1585 digits (which have absolutely different semantics).
1587 =head2 Why dynamic linking?
1589 Well, having several executables dynamically linked to the same huge
1590 library has its advantages, but this would not substantiate the
1591 additional work to make it compile. The reason is the complicated-to-developers
1592 but very quick and convenient-to-users "hard" dynamic linking used by OS/2.
1594 There are two distinctive features of the dyna-linking model of OS/2:
1595 all the references to external functions are resolved at the compile time;
1596 there is no runtime fixup of the DLLs after they are loaded into memory.
1597 The first feature is an enormous advantage over other models: it avoids
1598 conflicts when several DLLs used by an application export entries with
1599 the same name. In such cases "other" models of dyna-linking just choose
1600 between these two entry points using some random criterion - with predictable
1601 disasters as results. But it is the second feature which requires the build
1604 The address tables of DLLs are patched only once, when they are
1605 loaded. The addresses of the entry points into DLLs are guaranteed to be
1606 the same for all the programs which use the same DLL. This removes the
1607 runtime fixup - once DLL is loaded, its code is read-only.
1609 While this allows some (significant?) performance advantages, this makes life
1610 much harder for developers, since the above scheme makes it impossible
1611 for a DLL to be "linked" to a symbol in the F<.EXE> file. Indeed, this
1612 would need a DLL to have different relocations tables for the
1613 (different) executables which use this DLL.
1615 However, a dynamically loaded Perl extension is forced to use some symbols
1617 executable, e.g., to know how to find the arguments to the functions:
1618 the arguments live on the perl
1619 internal evaluation stack. The solution is to put the main code of
1620 the interpreter into a DLL, and make the F<.EXE> file which just loads
1621 this DLL into memory and supplies command-arguments. The extension DLL
1622 cannot link to symbols in F<.EXE>, but it has no problem linking
1623 to symbols in the F<.DLL>.
1625 This I<greatly> increases the load time for the application (as well as
1626 complexity of the compilation). Since interpreter is in a DLL,
1627 the C RTL is basically forced to reside in a DLL as well (otherwise
1628 extensions would not be able to use CRT). There are some advantages if
1629 you use different flavors of perl, such as running F<perl.exe> and
1630 F<perl__.exe> simultaneously: they share the memory of F<perl.dll>.
1632 B<NOTE>. There is one additional effect which makes DLLs more wasteful:
1633 DLLs are loaded in the shared memory region, which is a scarse resource
1634 given the 512M barrier of the "standard" OS/2 virtual memory. The code of
1635 F<.EXE> files is also shared by all the processes which use the particular
1636 F<.EXE>, but they are "shared in the private address space of the process";
1637 this is possible because the address at which different sections
1638 of the F<.EXE> file are loaded is decided at compile-time, thus all the
1639 processes have these sections loaded at same addresses, and no fixup
1640 of internal links inside the F<.EXE> is needed.
1642 Since DLLs may be loaded at run time, to have the same mechanism for DLLs
1643 one needs to have the address range of I<any of the loaded> DLLs in the
1644 system to be available I<in all the processes> which did not load a particular
1645 DLL yet. This is why the DLLs are mapped to the shared memory region.
1647 =head2 Why chimera build?
1649 Current EMX environment does not allow DLLs compiled using Unixish
1650 C<a.out> format to export symbols for data (or at least some types of
1651 data). This forces C<omf>-style compile of F<perl.dll>.
1653 Current EMX environment does not allow F<.EXE> files compiled in
1654 C<omf> format to fork(). fork() is needed for exactly three Perl
1661 explicit fork() in the script,
1669 C<open FH, "-|">, in other words, opening pipes to itself.
1673 While these operations are not questions of life and death, they are
1675 useful scripts. This forces C<a.out>-style compile of
1681 Here we list environment variables with are either OS/2- and DOS- and
1682 Win*-specific, or are more important under OS/2 than under other OSes.
1684 =head2 C<PERLLIB_PREFIX>
1686 Specific for EMX port. Should have the form
1694 If the beginning of some prebuilt path matches F<path1>, it is
1695 substituted with F<path2>.
1697 Should be used if the perl library is moved from the default
1698 location in preference to C<PERL(5)LIB>, since this would not leave wrong
1699 entries in @INC. For example, if the compiled version of perl looks for @INC
1700 in F<f:/perllib/lib>, and you want to install the library in
1703 set PERLLIB_PREFIX=f:/perllib/lib;h:/opt/gnu
1705 This will cause Perl with the prebuilt @INC of
1707 f:/perllib/lib/5.00553/os2
1708 f:/perllib/lib/5.00553
1709 f:/perllib/lib/site_perl/5.00553/os2
1710 f:/perllib/lib/site_perl/5.00553
1713 to use the following @INC:
1715 h:/opt/gnu/5.00553/os2
1717 h:/opt/gnu/site_perl/5.00553/os2
1718 h:/opt/gnu/site_perl/5.00553
1721 =head2 C<PERL_BADLANG>
1723 If 0, perl ignores setlocale() failing. May be useful with some
1726 =head2 C<PERL_BADFREE>
1728 If 0, perl would not warn of in case of unwarranted free(). With older
1730 useful in conjunction with the module DB_File, which was buggy when
1731 dynamically linked and OMF-built.
1733 Should not be set with newer Perls, since this may hide some I<real> problems.
1735 =head2 C<PERL_SH_DIR>
1737 Specific for EMX port. Gives the directory part of the location for
1740 =head2 C<USE_PERL_FLOCK>
1742 Specific for EMX port. Since L<flock(3)> is present in EMX, but is not
1743 functional, it is emulated by perl. To disable the emulations, set
1744 environment variable C<USE_PERL_FLOCK=0>.
1746 =head2 C<TMP> or C<TEMP>
1748 Specific for EMX port. Used as storage place for temporary files.
1752 Here we list major changes which could make you by surprise.
1756 C<setpriority> and C<getpriority> are not compatible with earlier
1757 ports by Andreas Kaiser. See C<"setpriority, getpriority">.
1759 =head2 DLL name mangling: pre 5.6.2
1761 With the release 5.003_01 the dynamically loadable libraries
1762 should be rebuilt when a different version of Perl is compiled. In particular,
1763 DLLs (including F<perl.dll>) are now created with the names
1764 which contain a checksum, thus allowing workaround for OS/2 scheme of
1767 It may be possible to code a simple workaround which would
1773 find the old DLLs looking through the old @INC;
1777 mangle the names according to the scheme of new perl and copy the DLLs to
1782 edit the internal C<LX> tables of DLL to reflect the change of the name
1783 (probably not needed for Perl extension DLLs, since the internally coded names
1784 are not used for "specific" DLLs, they used only for "global" DLLs).
1788 edit the internal C<IMPORT> tables and change the name of the "old"
1789 F<perl????.dll> to the "new" F<perl????.dll>.
1793 =head2 DLL name mangling: 5.6.2 and beyond
1795 In fact mangling of I<extension> DLLs was done due to misunderstanding
1796 of the OS/2 dynaloading model. OS/2 (effectively) maintains two
1797 different tables of loaded DLL:
1803 those loaded by the base name from C<LIBPATH>; including those
1804 associated at link time;
1808 loaded by the full name.
1812 When resolving a request for a global DLL, the table of already-loaded
1813 specific DLLs is (effectively) ignored; moreover, specific DLLs are
1814 I<always> loaded from the prescribed path.
1816 There is/was a minor twist which makes this scheme fragile: what to do
1817 with DLLs loaded from
1821 =item C<BEGINLIBPATH> and C<ENDLIBPATH>
1823 (which depend on the process)
1825 =item F<.> from C<LIBPATH>
1827 which I<effectively> depends on the process (although C<LIBPATH> is the
1828 same for all the processes).
1832 Unless C<LIBPATHSTRICT> is set to C<T> (and the kernel is after
1833 2000/09/01), such DLLs are considered to be global. When loading a
1834 global DLL it is first looked in the table of already-loaded global
1835 DLLs. Because of this the fact that one executable loaded a DLL from
1836 C<BEGINLIBPATH> and C<ENDLIBPATH>, or F<.> from C<LIBPATH> may affect
1837 I<which> DLL is loaded when I<another> executable requests a DLL with
1838 the same name. I<This> is the reason for version-specific mangling of
1839 the DLL name for perl DLL.
1841 Since the Perl extension DLLs are always loaded with the full path,
1842 there is no need to mangle their names in a version-specific ways:
1843 their directory already reflects the corresponding version of perl,
1844 and @INC takes into account binary compatibility with older version.
1845 Starting from C<5.6.2> the name mangling scheme is fixed to be the
1846 same as for Perl 5.005_53 (same as in a popular binary release). Thus
1847 new Perls will be able to I<resolve the names> of old extension DLLs
1848 if @INC allows finding their directories.
1850 However, this still does not guarantie that these DLL may be loaded.
1851 The reason is the mangling of the name of the I<Perl DLL>. And since
1852 the extension DLLs link with the Perl DLL, extension DLLs for older
1853 versions would load an older Perl DLL, and would most probably
1854 segfault (since the data in this DLL is not properly initialized).
1856 There is a partial workaround (which can be made complete with newer
1857 OS/2 kernels): create a forwarder DLL with the same name as the DLL of
1858 the older version of Perl, which forwards the entry points to the
1859 newer Perl's DLL. Make this DLL accessible on (say) the C<BEGINLIBPATH> of
1860 the new Perl executable. When the new executable accesses old Perl's
1861 extension DLLs, they would request the old Perl's DLL by name, get the
1862 forwarder instead, so effectively will link with the currently running
1865 This may break in two ways:
1871 Old perl executable is started when a new executable is running has
1872 loaded an extension compiled for the old executable (ouph!). In this
1873 case the old executable will get a forwarder DLL instead of the old
1874 perl DLL, so would link with the new perl DLL. While not directly
1875 fatal, it will behave the same as new excutable. This beats the whole
1876 purpose of explicitly starting an old executable.
1880 A new executable loads an extension compiled for the old executable
1881 when an old perl executable is running. In this case the extension
1882 will not pick up the forwarder - with fatal results.
1886 With support for C<LIBPATHSTRICT> this may be circumvented - unless
1887 one of DLLs is started from F<.> from C<LIBPATH> (I do not know
1888 whether C<LIBPATHSTRICT> affects this case).
1890 B<REMARK>. Unless newer kernels allow F<.> in C<BEGINLIBPATH> (older
1891 do not), this mess cannot be completely cleaned.
1894 B<REMARK>. C<LIBPATHSTRICT>, C<BEGINLIBPATH> and C<ENDLIBPATH> are
1895 not environment variables, although F<cmd.exe> emulates them on C<SET
1896 ...> lines. From Perl they may be accessed by L<Cwd::extLibpath> and
1897 L<Cwd::extLibpath_set>.
1899 =head2 DLL forwarder generation
1901 Assume that the old DLL is named F<perlE0AC.dll> (as is one for
1902 5.005_53), and the new version is 5.6.1. Create a file
1903 F<perl5shim.def-leader> with
1905 LIBRARY 'perlE0AC' INITINSTANCE TERMINSTANCE
1906 DESCRIPTION '@#perl5-porters@perl.org:5.006001#@ Perl module for 5.00553 -> Perl 5.6.1 forwarder'
1908 DATA LOADONCALL NONSHARED MULTIPLE
1911 modifying the versions/names as needed. Run
1913 perl -wnle "next if 0../EXPORTS/; print qq( \"$1\") if /\"(\w+)\"/" perl5.def >lst
1915 in the Perl build directory (to make the DLL smaller replace perl5.def
1916 with the definition file for the older version of Perl if present).
1918 cat perl5shim.def-leader lst >perl5shim.def
1919 gcc -Zomf -Zdll -o perlE0AC.dll perl5shim.def -s -llibperl
1921 (ignore multiple C<warning L4085>).
1925 As of release 5.003_01 perl is linked to multithreaded C RTL
1926 DLL. If perl itself is not compiled multithread-enabled, so will not be perl's
1927 malloc(). However, extensions may use multiple thread on their own
1930 This was needed to compile C<Perl/Tk> for XFree86-OS/2 out-of-the-box, and
1931 link with DLLs for other useful libraries, which typically are compiled
1932 with C<-Zmt -Zcrtdll>.
1934 =head2 Calls to external programs
1936 Due to a popular demand the perl external program calling has been
1937 changed wrt Andreas Kaiser's port. I<If> perl needs to call an
1938 external program I<via shell>, the F<f:/bin/sh.exe> will be called, or
1939 whatever is the override, see L<"PERL_SH_DIR">.
1941 Thus means that you need to get some copy of a F<sh.exe> as well (I
1942 use one from pdksh). The path F<F:/bin> above is set up automatically during
1943 the build to a correct value on the builder machine, but is
1944 overridable at runtime,
1946 B<Reasons:> a consensus on C<perl5-porters> was that perl should use
1947 one non-overridable shell per platform. The obvious choices for OS/2
1948 are F<cmd.exe> and F<sh.exe>. Having perl build itself would be impossible
1949 with F<cmd.exe> as a shell, thus I picked up C<sh.exe>. This assures almost
1950 100% compatibility with the scripts coming from *nix. As an added benefit
1951 this works as well under DOS if you use DOS-enabled port of pdksh
1952 (see L<"Prerequisites">).
1954 B<Disadvantages:> currently F<sh.exe> of pdksh calls external programs
1955 via fork()/exec(), and there is I<no> functioning exec() on
1956 OS/2. exec() is emulated by EMX by an asynchronous call while the caller
1957 waits for child completion (to pretend that the C<pid> did not change). This
1958 means that 1 I<extra> copy of F<sh.exe> is made active via fork()/exec(),
1959 which may lead to some resources taken from the system (even if we do
1960 not count extra work needed for fork()ing).
1962 Note that this a lesser issue now when we do not spawn F<sh.exe>
1963 unless needed (metachars found).
1965 One can always start F<cmd.exe> explicitly via
1967 system 'cmd', '/c', 'mycmd', 'arg1', 'arg2', ...
1969 If you need to use F<cmd.exe>, and do not want to hand-edit thousands of your
1970 scripts, the long-term solution proposed on p5-p is to have a directive
1974 which will override system(), exec(), C<``>, and
1975 C<open(,'...|')>. With current perl you may override only system(),
1976 readpipe() - the explicit version of C<``>, and maybe exec(). The code
1977 will substitute the one-argument call to system() by
1978 C<CORE::system('cmd.exe', '/c', shift)>.
1980 If you have some working code for C<OS2::Cmd>, please send it to me,
1981 I will include it into distribution. I have no need for such a module, so
1984 For the details of the current situation with calling external programs,
1985 see L<Starting OS/2 (and DOS) programs under Perl>. Set us mention a couple
1992 External scripts may be called by their basename. Perl will try the same
1993 extensions as when processing B<-S> command-line switch.
1997 External scripts starting with C<#!> or C<extproc > will be executed directly,
1998 without calling the shell, by calling the program specified on the rest of
2003 =head2 Memory allocation
2005 Perl uses its own malloc() under OS/2 - interpreters are usually malloc-bound
2006 for speed, but perl is not, since its malloc is lightning-fast.
2007 Perl-memory-usage-tuned benchmarks show that Perl's malloc is 5 times quicker
2008 than EMX one. I do not have convincing data about memory footprint, but
2009 a (pretty random) benchmark showed that Perl's one is 5% better.
2011 Combination of perl's malloc() and rigid DLL name resolution creates
2012 a special problem with library functions which expect their return value to
2013 be free()d by system's free(). To facilitate extensions which need to call
2014 such functions, system memory-allocation functions are still available with
2015 the prefix C<emx_> added. (Currently only DLL perl has this, it should
2016 propagate to F<perl_.exe> shortly.)
2020 One can build perl with thread support enabled by providing C<-D usethreads>
2021 option to F<Configure>. Currently OS/2 support of threads is very
2024 Most notable problems:
2030 may have a race condition. Needs a reimplementation (in terms of chaining
2031 waiting threads, with the linked list stored in per-thread structure?).
2035 has a couple of static variables used in OS/2-specific functions. (Need to be
2036 moved to per-thread structure, or serialized?)
2040 Note that these problems should not discourage experimenting, since they
2041 have a low probability of affecting small programs.
2045 This description was not updated since 5.6.1, see F<os2/Changes> for
2052 I include 3 extensions by Andreas Kaiser, OS2::REXX, OS2::UPM, and OS2::FTP,
2053 into my ftp directory, mirrored on CPAN. I made
2054 some minor changes needed to compile them by standard tools. I cannot
2055 test UPM and FTP, so I will appreciate your feedback. Other extensions
2056 there are OS2::ExtAttr, OS2::PrfDB for tied access to EAs and .INI
2057 files - and maybe some other extensions at the time you read it.
2059 Note that OS2 perl defines 2 pseudo-extension functions
2060 OS2::Copy::copy and DynaLoader::mod2fname (many more now, see
2061 L<Prebuilt methods>).
2063 The -R switch of older perl is deprecated. If you need to call a REXX code
2064 which needs access to variables, include the call into a REXX compartment
2066 REXX_call {...block...};
2068 Two new functions are supported by REXX code,
2070 REXX_eval_with 'string', REXX_function_name => \&perl_sub_reference;
2072 If you have some other extensions you want to share, send the code to
2073 me. At least two are available: tied access to EA's, and tied access
2074 to system databases.
2078 Ilya Zakharevich, ilya@math.ohio-state.edu