Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

perl 2.01 on Cygwin

by rje (Deacon)
on Mar 26, 2019 at 23:02 UTC ( [id://1231721] : CUFP . print w/replies, xml ) Need Help??

Even though I haven't programmed in C for a long time, I could get Perl2 compiled and running (a 387k binary!) in just a couple hours this afternoon on Cygwin.

.Can I throw out the in-house malloc and other hand-rolled memory management code? What else can I do away with? How about all of the variant hardware #defines Larry had to make? Can't I simplify the code by aiming for one modern OS (Linux?) and Dockerizing it? And how about all that K&R C? Boy does that take me back... Can I shrink the binary by modernizing the code?

$ perl2 -v This is perl 2, subversion 1 (v2.0.1) Copyright 1987-2019, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU GPL ( Documentation for Perl should be found on this system via "man perl". Point your browser at, the Perl Home Page. Patch level: 0

I needed GCC, make, and byacc (softlinked to 'yacc'). Then, I had to make a few edits:

1. stab.c: commented out extern errno and replaced it with: int errno;

2. perl.h: commented out the #ifdef that declared sprintf().

3. perl.h: commented out the declaration of times().

4. perly.c: I changed the -v message to look more Perl-like.

I might have made two earlier edits, but they were along the same lines of removing conflicting or redundant declarations.

And now, as a reward, I've got perl 2 running on Cygwin on my laptop! I have to say, it was worth the effort!

Onward to hack!

-rwxrwxr-x+ 1 rje None 387058 Mar 26 17:52 perl2.exe

Replies are listed 'Best First'.
Re: perl 2.01 on Cygwin
by afoken (Chancellor) on Mar 28, 2019 at 23:32 UTC

    Then, I had to make a few edits:

    1. stab.c: commented out extern errno and replaced it with: int errno;

    Very likely, that won't work as expected, because now perl and the libc have two different ideas of where the last error code is stored. errno is an extern int, or some voodoo that makes your code behave as if it was an extern int. The clean way is to remove the errno declaration and add #include <errno.h> instead.


    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      Thanks for that! I'll be learning things like that as I go make mistakes. Onward then.
Re: perl 2.01 on Cygwin
by Lotus1 (Vicar) on Mar 31, 2019 at 19:17 UTC

    I'm curious why you picked Perl 2. Were you just wanting to try to compile something without a specific goal? Why not Perl 3, 4 or 5?

      It seemed a good place to start: small but feature-rich. I'm looking at Perl 3 now and deciding if I "need" binary ops and sockets. At the moment, I think I can survive without both, but we will see.
        It seemed a good place to start:[...]

        What I'm really wondering is what you are trying to accomplish. Usually, posts in 'Cool uses for Perl' tell you what the use is. Compiling old versions of Perl is interesting but why? Are you planning to create your own new language? Are you targeting a microcontroller or embedded system of some sort? Are you planning to embed it in Lua and then embed that Lua into Perl? A game engine?

        It would be interesting if there were a repository for all the old versions of Perl.

      Earliest available version?

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Re: perl 2.01 on Cygwin
by ikegami (Patriarch) on Mar 29, 2019 at 06:52 UTC

    I changed the -v message to look more Perl-like.

    Except you seem to have forgotten to specify the version??? It's the subversion of what version?