cnd has asked for the wisdom of the Perl Monks concerning the following question:

I've been playing with MicroPython (uPy) - it's very clever. My first version of perl ran (still runs today) on my HP 200LX pocket computer under DOS:-
1991/09/11 00:12.52 149,628 DOS\perl.exe
I'm toying with the "geeky" idea of building myself a MicroPerl (uPl) Is there any "TLDR;" doc or set of instructions from where I can start to build the absolute most minimal perl possible, with every feature stripped out (to initially run under linux, as a starting-point for porting it to esp32) ? esp32 has around 480KB RAM (expandable by 4 or 8mb SPIFLASH) and 4MB "disk" (flash storage) expandable by SD card, so, nearly the same as my 200LX with it's PCMCIA slot. uPy manages to squash their language, all the hardware support stuff letting them do-away with any O/S, and assorted starter modules into this space:-
2023/11/12 00:19.18 1,661,872 ./ESP32_GENERIC-20231005-v1.21.0.bin
The latest perl seems somewhat excessive in it's release form, even before any OS emulation layer is tacked on:
2023/11/11 23:57.09 3,745,840 ./perl-5.38.0/perl
my guess is that someplace in those "100 platforms" that perl has been ported onto, there's probably something minimalist already, which might make a better starting-point than my default linux "./Configure" is outputting ? I have considered using my old perl from 1991, which is clearly doable, but if I'm going to port to esp32, I may as well go all-in on the geekfactor and try to use the latest release first, right? Pointers, anyone?

Replies are listed 'Best First'.
Re: Building a MicroPerl distro for ESP32 and similar MCUs ?
by marto (Cardinal) on Nov 12, 2023 at 08:08 UTC
Re: Building a MicroPerl distro for ESP32 and similar MCUs ?
by cnd (Acolyte) on Nov 12, 2023 at 12:46 UTC
    Brilliant pointers! Thanks to metacpan and this amazing fellow ( https://cpan.metacpan.org/authors/id/J/JH/JHI/ ) who's kept antique source alive, I was able to build a working test version with no dramas (perl5.7.3 being the documented last time this worked)
    2023/11/12 12:17.12 1,065,256 microperl
    That's on my 64bit intel; a 32bit build for xtensa would presumably be even smaller... which leaves at least 600kb space to implement the OS-replacement stuff if I wanted to ship something even smaller than micropython :-)

    I apparently only need to implement these:

    - <stddef.h>, <stdlib.h>
    - rename()
    - opendir(), readdir(), closedir() (via dirent.h)
    - memchr(), memcmp(), memcpy(), memset() (via string.h)
    - (a safe) putenv() (via stdlib.h)
    - strtoul() (via stdlib.h)
    
    $ ./microperl -v This is perl, v5.7.3 built for unknown Copyright 1987-2002, Larry Wall
Re: Building a MicroPerl distro for ESP32 and similar MCUs ?
by LanX (Saint) on Nov 12, 2023 at 02:45 UTC