Home / Alt manpages / perlsynology(1)

  • perlsynology(1)
  • User command
  • linux

Build a Separate Perl Tree on Synology DSM

DSM ships a Perl of its own, and replacing it is a fast way to break the maintenance scripts Synology relies on. This guide builds Perl from source on a Synology NAS, runs its test harness, and installs it below /opt/perl instead. It 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.

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, which is the version of the documentation installed on this Linux workstation, not the Perl version your NAS actually ships. 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 will not run on 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 treats Entware as the practical development environment and uses opkg for packages. Follow the current Entware installation instructions for your NAS architecture, then install the compiler and build tools:

# opkg install make gcc

That command is elevated because it changes the Entware installation. Install the manual's optional shell and text-processing tools separately if you need them:

# opkg install bash gawk

Do not replace /usr/bin/bash with a symlink just because the manual's example does. That changes a system command and can affect DSM maintenance scripts. Confirm your build works with an explicit shell path first; if your deployment genuinely needs 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 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 copy the manual's example links blindly. A wrong link can make Configure select the wrong ABI.
  • Record the original listing before adding any Entware-side compatibility link, and use the exact library version present on that NAS.
  • Never add the manual's /lib/glibc.so link. It explicitly warns that linking /lib/glibc.so.6 to that name can break system components, and system-library links can also vanish after a DSM upgrade.

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 here: 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 the manual documents:

$ 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, so 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 a while 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 just to make the test green, because it can break system components. Note the failure in your build notes and investigate the platform-specific cause instead.

If the test harness passes, confirm the built interpreter reports the expected configuration before you install it:

$ ./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 pointing the prefix at a system directory. Undoing this installation means removing the dedicated /opt/perl tree after checking that no service or script uses it, and never while a process is still 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 too.

Done means

  • NAS architecture and Entware support were confirmed before any package changes.
  • make, gcc and the selected awk were verified on the NAS.
  • Policy.sh points at a dedicated /opt/perl tree.
  • Configure, make -j2, and TEST_JOBS=2 make test_harness all completed and were recorded.
  • /opt/perl/bin/perl reports the expected version and prefix.
  • No unsafe /lib/glibc.so link or unplanned DSM system-file change was made.