Build a Separate Perl Tree on Synology DSM with Policy.sh
You will build Perl from source on a Synology NAS, run its test harness, and install it below /opt/perl instead of replacing the DSM-managed Perl. The workflow follows the installed perlsynology(1) manual, whose revision covers DSM 5.1, DSM 6.1 and DSM 7.1. It is not a general recipe for every DSM release or CPU.
The route
Jump straight to the step you need, or tick off Done means at the end.
- 1. Confirm the target before changing it
- 2. Install a supported build environment
- 3. Prepare library names only when Configure needs them
- 4. Create a private install policy
- 5. Configure and compile
- 6. Run tests before installing
- 7. Install and verify the separate tree
- 8. Add libraries with an explicit runtime path
Allow at least an hour for package setup, compilation and tests. You need SSH access, enough storage for source and build artefacts, and a DSM version and architecture supported by your chosen Entware bootstrap. The local reference package is perl-doc 5.38.2-3.2ubuntu0.6; that is the version of the documentation installed on this Linux workstation, not the Perl version supplied by your NAS. The manual describes Synology package versions from 5.8.6 on DSM 4.3 to 5.28.1 on DSM 7.1, plus Entware builds of 5.26.1 or 5.24.1.
1. Confirm the target before changing it
Read the NAS release and CPU details first. Synology systems use several architectures, including ARM, Intel and PowerPC, and an Entware binary or compiler setup for one architecture is not interchangeable with another. The manual links to Synology's CPU guidance and Entware's installation instructions.
On the NAS, collect facts without changing configuration:
$ uname -a
$ uname -m
$ command -v perl || true
$ perl -V:version -V:archname 2>/dev/null || true
The last command may fail if Perl is not installed. That is useful information, not a reason to guess a package source. Record the output as a checkpoint before proceeding.
2. Install a supported build environment
For DSM 7, the manual identifies Entware as the practical development environment and uses opkg for packages. Follow the current Entware installation instructions for the NAS architecture, then install the compiler and build tools:
# opkg install make gcc
This is an elevated command because it changes the Entware installation. If you also need the manual's optional shell and text-processing tools, install them separately:
# opkg install bash gawk
Do not replace /usr/bin/bash with a symlink merely because the example in the manual does so. That changes a system command and can affect DSM maintenance scripts. First confirm that your build works with an explicit shell path. If your deployment really requires the replacement, take a configuration backup and schedule a recovery window.
Checkpoint: verify the tools resolve to the Entware installation:
$ command -v opkg
$ command -v gcc
$ command -v make
$ command -v gawk
If any command is missing, stop here. Installing Perl source files will not repair an incomplete compiler environment.
3. Prepare library names only when Configure needs them
Some Synology layouts provide versioned libraries without the unversioned names that a source build searches for. The manual gives examples under /opt/lib, including libm.so, libcrypt.so and libpthread.so. Inspect the actual files first:
$ ls -l /opt/lib
$ find /opt/lib -maxdepth 1 -type f -o -type l
Do not create links by copying the example blindly. A wrong link can make Configure select the wrong ABI, and system-library links may disappear after a DSM upgrade. If you must add an Entware-side compatibility link, record the original listing and use the exact library version present on that NAS. Avoid adding the manual's dangerous /lib/glibc.so link: it explicitly warns that linking /lib/glibc.so.6 to that name can break system components.
4. Create a private install policy
Unpack the Perl source in a working directory with enough space. In the source directory, create Policy.sh with paths that keep the result separate from DSM and Entware:
# Administrivia
perladmin="[email protected]"
# Keep the compiled Perl in its own tree
prefix=/opt/perl
# DSM may not provide a cc alias
cc=gcc
awk=/opt/bin/gawk
# Optional build flag
ccflags="-DDEBUGGING"
# Entware and system search paths
locincpth="/opt/include"
loclibpth="/opt/lib /usr/local/lib /usr/lib"
libpth="/opt/lib /usr/local/lib /usr/lib"
Replace the administrator address and adjust awk only if command -v gawk shows a different path. The prefix setting is the safety boundary: do not set it to /usr, /bin or a DSM-managed Perl directory. Create /opt/perl with suitable ownership before installation if you want to avoid running the final install as root.
5. Configure and compile
Run the source tree's Configure script with the options documented by the manual:
$ bash ./Configure -Dusedevel -Duseshrplib -Duse64bitall -des
$ make -j2
-Dusedevel selects the development configuration described by the source workflow, -Duseshrplib requests shared Perl libraries, and -Duse64bitall requests the 64-bit settings. These choices depend on the NAS architecture. Read the Configure output rather than assuming a successful shell command selected every feature.
Checkpoint: Configure should produce its generated files and make should finish without an error. If config.sh reports a syntax error, the manual points to unusual compiler output under -v as a known cause. Capture the first error and fix the toolchain or library path before retrying.
6. Run tests before installing
Use the documented test harness with two workers:
$ env TEST_JOBS=2 make test_harness
Tests can take time on a NAS. Do not treat an interrupted run as a clean result. One documented Synology-specific issue is a DynaLoader test failure because /lib/glibc.so is absent. The manual warns not to create that link to make the test green, because it can break system components. Keep the failure in your build notes and investigate the platform-specific cause instead.
If the test harness passes, confirm that the built interpreter reports the expected configuration before installation:
$ ./perl -V:version -V:archname -V:prefix
$ ./perl -e 'print "Perl build OK\n"'
7. Install and verify the separate tree
Installation changes files below the configured prefix, so use the required privilege only if the destination is not writable by your build user:
$ make install
$ /opt/perl/bin/perl -V:version -V:prefix
$ /opt/perl/bin/perl -e 'print "Installed Perl works\n"'
If make install reports a permission error, stop and fix ownership of /opt/perl or rerun only that install step with the NAS administrator's approved privilege. Do not solve it by changing the prefix to a system directory. Undoing this installation means removing the dedicated /opt/perl tree after checking that no service or script uses it. Do not remove it while processes are running from that path.
8. Add libraries with an explicit runtime path
The basic build may omit database libraries. If you add them through Entware, the manual says LD_LIBRARY_PATH must cover the relevant directories both while Perl is built and when programs run:
export LD_LIBRARY_PATH=/lib:/opt/lib
/opt/perl/bin/perl -V:libs
Keep this setting scoped to the application or service that needs it. Do not add a broad library path to every DSM shell or startup script without testing: library search order affects unrelated programs.
Done means
- The NAS architecture and Entware support were confirmed before package changes.
make,gccand the selectedawkwere verified on the NAS.Policy.shpoints at a dedicated/opt/perltree.- Configure completed,
make -j2completed, andTEST_JOBS=2 make test_harnesswas recorded as passed. /opt/perl/bin/perlreports the expected version and prefix.- No unsafe
/lib/glibc.solink or unplanned DSM system-file change was made.