Skip to content

Primer on a fully self-contained, statically linked build of Perl embedding in the binary system .pm files and any other files

Notifications You must be signed in to change notification settings

vadimkantorov/perlpack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Primer on a single-file, self-contained, fully statically-linked build of Perl, embedding a virtual, read-only file system (with all *.pm files and arbitrary files)

  • build Perl into a single, self-contained, fully statically-linked executable
  • builds all builtin modules statically and then links them statically
  • showcases using Alpine Linux and musl libc for static linking with libc
  • embeds *.pm modules into the executable
  • showcases embedding a user Perl script (for illustration is used perlpack.pl, see Makefile)
  • showcases embedding arbitrary files along (see Makefile and add files into the packfs directory)
  • showcases the --wrap linker flag enabling the overrides of the libc's filesystem-related functions

Limitations

  • not all I/O function calls are reimplemented
  • it's only a proof-of-concept, very little tested

Files of interest

  • perlpack.c - the main C program which embeds Perl, includes perlpack.h and override I/O callback to enable transparent access to the embedded files
  • perlpack.pl - generates in place a more non-empty perlpack.h, default perlpack.h provided only from illustrative purposes
  • Makefile - showcases building of main binaries perlpackstatic (and embedded myscript.o, perlpack.o)
  • .github/workflows/perlpack.yml - showcases testing command sequence
  • perlpackstatic - built in Makefile, the main binary with embedded Perl (using /mnt/packperl/ as the "mount-point" for the embedded, read-only virtual FS)

Overridden functions

  • open
  • access
  • stat
  • fstat
  • lseek
  • read
  • close
  • fopen
  • fileno

Prior complete, but also more complex approaches

References and alternatives

About

Primer on a fully self-contained, statically linked build of Perl embedding in the binary system .pm files and any other files

Topics

Resources

Stars

Watchers

Forks