Notice: WebPerl is very much in beta. Some things may not work yet, and parts of the API may still change. Your feedback is always appreciated!
This page documents the Perl 5 support, for the experimental Perl 6 support, see here.
bash(tested on a minimum of Ubuntu 16.04)
sudo apt-get install git-core)
perl; for example on Ubuntu:
sudo apt-get install build-essentialand
sudo apt-get build-dep perl
perl -Mlazy build.pl --help. Otherwise, the modules used by
build.plcan be seen in its source grouped near the top of the file.
The source code is in two repositories:
https://github.com/haukex/webperl - the main WebPerl repository
https://github.com/haukex/emperl5 - a fork of the Perl 5 source repository where the WebPerl-specific patches are applied
You only need to check out the first of the two, the
is checked out by the build script.
Some of the central source files of WebPerl are:
Fetch the source code.
$ git clone https://github.com/haukex/webperl.git $ cd webperl
Install the prerequisites.
Edit the configuration file,
./build/emperl_config.sh, to fit
your system. For a first build, just make sure the path to
emsdk_env.sh is correct.
Source the configuration file to set the environment variables.
Remember to do this anytime you change variables. You may also
add the sourcing of the configuration file to your
$ . ./build/emperl_config.sh
Run the build script:
If the build succeeds, the output files
emperl.* will be
copied to the
web directory of the repository. You can
then use the files in the
web directory as described in
The build script
build.pl tries to take care of as much of the build process as
possible. Most of the work happens in a subdirectory
work of the repository.
make, it tries to not run build steps that don’t need to be rerun.
A brief note on naming:
emperlis generally used for the build products of Emscripten
emperl5is the Perl 5 source tree modified for WebPerl
- WebPerl is the finished product, including
emperland the WebPerl APIs (
The steps in the build process are roughly as follows.
Since WebPerl is still in beta, they are subject to change.
the source of the
for the current details.
Patch Emscripten (currently just a minor patch, but important for Perl)
emperl5 Perl source tree
If necessary, build “host Perl” - in Perl’s cross-compilation system,
this is the Perl that is built for the host system architecture,
i.e. in the case of Linux, a normal build of Perl for Linux. The
miniperl from the host Perl will be used for some of the build
steps for the target architecture.
(Note: This step can take quite a while, but it usually only needs
to be run once.)
Download and extract any CPAN modules, such as the required
into the Perl source tree so that they will be built as part of the normal
build process and any XS extensions linked statically into the
(See “Adding CPAN Modules”)
Configure script using the custom “hints” file for the Emscripten
make to compile
perl. This produces a file
perl.bc with LLVM IR
Because some steps in the build process require a working
Run the equivalent of
make install, which copies all the Perl modules
etc. into the target directory that will become part of the Emscripten
virtual file system. Then, we clean this directory up by deleting anything
that we don’t need for WebPerl: additional binaries (it’s a single-process
*.pod files, as well as stripping the POD out of
files, etc. to reduce the download size.
The Emscripten compiler is used to take the previously compiled
and build the final output,
emperl.js along with the corresponding
.data file. This step also includes the packaging of the
build.pl provides various command-line options that allow you to control
parts of the build process. See
build.pl --help for details.
In the configuration file
emperl_config.sh, the variable
is a whitespace-separated list of module names.
build.pl will fetch these
from CPAN and extract them into the
ext directory of the Perl source tree
so that they are compiled along with Perl. Any XS modules that need to be
perl need to be added to the variable
the format expected by Perl’s
static_ext configuration variable,
so for example
Cpanel/JSON/XS instead of
Note that the build script does not automatically fetch modules’
dependencies, for now you will need to resolve them and add them to
EMPERL_EXTENSIONS yourself. (This may be improved upon in the future.)
You can try out the script
which uses the MetaCPAN API to resolve dependencies.
Additional notes on building WebPerl may be found in the GitHub Wiki.
Copyright (c) 2018 Hauke Daempfling (email@example.com) at the Leibniz Institute of Freshwater Ecology and Inland Fisheries (IGB), Berlin, Germany, http://www.igb-berlin.de
Please see the “Legal” page for details.
You can find the source for this page at https://github.com/haukex/webperl/blob/gh-pages/building.md