3 If you read this file _as_is_, just ignore the funny characters you see.
4 It is written in the POD format (see pod/perlpod.pod) which is specially
5 designed to be readable as is. But if you have been into Perl you
6 probably already know this.
10 perlsynology - Perl 5 on Synology DSM systems
14 Synology manufactures a vast number of Network Attached Storage (NAS)
15 devices that are very popular in large organisations as well as small
18 The NAS systems are equipped with Synology Disk Storage Manager (DSM),
19 which is a trimmed-down Linux system enhanced with several tools for
20 managing the NAS. There are several flavours of hardware: Marvell
21 Armada (ARMv5tel, ARMv7l), Intel Atom (i686, x86_64), Freescale QorIQ
22 (PPC), and more. For a full list see the
23 L<Synology FAQ|https://kb.synology.com/en-global/DSM/tutorial/What_kind_of_CPU_does_my_NAS_have>.
25 Since it is based on Linux, the NAS can run many popular Linux
26 software packages, including Perl. In fact, Synology provides a
27 ready-to-install package for Perl, depending on the version of DSM
28 the installed perl ranges from 5.8.6 on DSM-4.3 to 5.28.1 on DSM-7.1.
30 There is an active user community that provides many software packages
31 for the Synology DSM systems; at the time of writing this document
32 they provide Perl version 5.28.1.
34 This document describes various features of Synology DSM operating
35 system that will affect how Perl 5 (hereafter just Perl) is
36 configured, compiled and/or runs. It has been compiled and verified by
37 Johan Vromans for the Synology DS413 (QorIQ), with feedback from
38 H.Merijn Brand (DS213: ARMv5tel, RS815: Intel Atom x64, and DS218+:
41 =head2 Setting up the build environment
45 For a comfortable development environment, Entware is currently the only
46 viable solution. Just follow the detailed instructions on
47 L<Install Entware on Synology NAS|https://github.com/Entware/Entware/wiki/Install-on-Synology-NAS>.
48 supported architectures are armv5, armv7, mipsel, wl500g, x86_32, and x86_64.
49 Check L<here|https://pkg.entware.net/binaries/> for supported platforms.
51 That github link also shows what environments should be supported.
53 It was tested on DSM-7.1 by H.Merijn Brand on a DS218+ and a DS220+ (both
56 Entware comes with a precompiled 5.26.1 (Jan 2018) that allowes
57 building shared XS code. Note that this installation does B<not> use
58 a site_perl folder. The available C<cpan> works. If all required
59 development packages are installed too, also for XS.
61 Installing perl from the Community package center:
67 Using your favourite browser open the DSM management page and start
72 In Settings, add the following Package Sources:
75 Location: https://synopackage.com/repository/spk/All
79 Still in Settings, in Channel Update, select Beta Channel.
83 To complete the development environment, install make and gcc
85 ds220# opkg install make gcc
87 Then, optionally, make sure you use the more recent bash and gawk.
89 ds220# opkg install bash gawk
91 ds220# mv bash bash.syno
92 ds220# ln -s /opt/bin/bash .
94 In order to have Configure find the required libraries
97 ds220# ln -s libcrypt.so.? libcrypt.so
98 ds220# ln -s libdl.so.? libdl.so
99 ds220# ln -s libgdbm.so.? libgdbm.so
100 ds220# ln -s libgdbm_compat.so.? libgdbm_compat.so
101 ds220# ln -s libm.so.? libm.so
102 ds220# ln -s libpthread.so.? libpthread.so
103 ds220# ln -s libutil.so.? libutil.so
107 Using iPkg has been deprecated on DSM 6, but an alternative is available
108 for DSM 6: entware/opkg. For instructions on how to use that, please read
109 L<Install Entware-ng on Synology NAS|https://github.com/Entware-ng/Entware-ng/wiki/Install-on-Synology-NAS>
111 That sadly does not (yet) work on QorIQ. At the moment of writing, the
112 supported architectures are armv5, armv7, mipsel, wl500g, x86_32, and x86_64.
113 Check L<here|https://pkg.entware.net/binaries/> for supported platforms.
115 Entware-ng comes with a precompiled 5.24.1 (June 2017) that allowes
116 building shared XS code. Note that this installation does B<not> use
117 a site_perl folder. The available C<cpan> works. If all required
118 development packages are installed too, also for XS.
122 As DSM is a trimmed-down Linux system, it lacks many of the tools and
123 libraries commonly found on Linux. The basic tools like sh, cp, rm,
124 etc. are implemented using
125 L<BusyBox|https://en.wikipedia.org/wiki/BusyBox>.
131 Using your favourite browser open the DSM management page and start
136 If you want to smoke test Perl, install C<Perl>.
140 In Settings, add the following Package Sources:
142 https://www.cphub.net
143 http://packages.quadrat4.de
145 As these two are both discontinued, it is unlikely you will be able
146 to set up a build environment on DSM 5.
150 Still in Settings, in Channel Update, select Beta Channel.
154 Press Refresh. In the left panel the item "Community" will appear.
155 Click it. Select "Bootstrap Installer Beta" and install it.
159 Likewise, install "iPKGui Beta".
161 The application window should now show an icon for iPKGui.
165 Start iPKGui. Install the packages C<make>, C<gcc> and C<coreutils>.
167 If you want to smoke test Perl, install C<patch>.
171 The next step is to add some symlinks to system libraries. For
172 example, the development software expect a library C<libm.so> that
173 normally is a symlink to C<libm.so.6>. Synology only provides the
174 latter and not the symlink.
176 Here the actual architecture of the Synology system matters. You have
177 to find out where the gcc libraries have been installed. Look in /opt
178 for a directory similar to arm-none-linux-gnueab or
179 powerpc-linux-gnuspe. In the instructions below I'll use
180 powerpc-linux-gnuspe as an example.
186 On the DSM management page start the Control Panel.
190 Click Terminal, and enable SSH service.
194 Close Terminal and the Control Panel.
198 Open a shell on the Synology using ssh and become root.
202 Execute the following commands:
205 ln -s libm.so.6 libm.so
206 ln -s libcrypt.so.1 libcrypt.so
207 ln -s libdl.so.2 libdl.so
208 cd /opt/powerpc-linux-gnuspe/lib (or
209 /opt/arm-none-linux-gnueabi/lib)
210 ln -s /lib/libdl.so.2 libdl.so
214 B<WARNING:> When you perform a system software upgrade, these links
215 will disappear and need to be re-established.
217 =head2 Compiling Perl 5
219 When the build environment has been set up, building and testing Perl
220 is straightforward. The only thing you need to do is download the
221 sources as usual, and add a file Policy.sh as follows:
226 # Install Perl in a tree in /opt/perl instead of /opt/bin.
229 # Select the compiler. Note that there is no 'cc' alias or link
230 # on older DSM versions
234 # Build flags. Optional
235 ccflags="-DDEBUGGING"
237 # Library and include paths.
238 locincpth="/opt/include"
239 loclibpth="/opt/lib /usr/local/lib /usr/lib"
240 libpth="/opt/lib /usr/local/lib /usr/lib"
242 You may want to create the destination directory and give it the right
243 permissions before installing, thus eliminating the need to build Perl
246 In the directory where you unpacked the sources, issue the familiar
249 $ bash ./Configure -Dusedevel -Duseshrplib -Duse64bitall -des
251 $ env TEST_JOBS=2 make test_harness
254 =head2 Known problems
258 The GNU C-compiler might spit out unexpected stuff under -v, which
259 causes the analysis of cppsymbols to fail because of unmatched quotes.
261 You'll note if config.sh fails with a syntax error.
267 =item Error message "No error definitions found".
269 This error is generated when it is not possible to find the local
270 definitions for error codes, due to the uncommon structure of the
271 Synology file system.
273 This error was fixed in the Perl development git for version 5.19,
274 commit 7a8f1212e5482613c8a5b0402528e3105b26ff24.
282 =item F<ext/DynaLoader/t/DynaLoader.t>
284 One subtest fails due to the uncommon structure of the Synology file
285 system. The file F</lib/glibc.so> is missing.
287 B<WARNING:> Do not symlink F</lib/glibc.so.6> to F</lib/glibc.so> or
288 some system components will start to fail.
292 =head2 Smoke testing Perl
294 If building completes successfully, you can set up smoke testing as
295 described in the Test::Smoke documentation.
297 For smoke testing you need a running Perl. You can either install the
298 Synology supplied package for Perl 5.8.6, or build and install your
299 own, much more recent version.
301 Note that I could not run successful smokes when initiated by the
302 Synology Task Scheduler. I resorted to initiating the smokes via a
303 cron job run on another system, using ssh:
305 ssh nas1 wrk/Test-Smoke/smoke/smokecurrent.sh
309 When local patches are applied with smoke testing, the test driver
310 will automatically request regeneration of certain tables after the
311 patches are applied. The Synology supplied Perl 5.8.6 (at least on the
312 DS413) B<is NOT capable> of generating these tables. It will generate
313 opcodes with bogus values, causing the build to fail.
315 You can prevent regeneration by adding the setting
319 to the smoke config, or by adding another patch that inserts
321 exit 0 if $] == 5.008006;
323 in the beginning of the C<regen.pl> program.
325 =head2 Adding libraries
327 The above procedure describes a basic environment and hence results in
328 a basic Perl. If you want to add additional libraries to Perl, you may
329 need some extra settings.
331 For example, the basic Perl does not have any of the DB libraries (db,
332 dbm, ndbm, gdsm). You can add these using iPKGui, however, you need to
333 set environment variable LD_LIBRARY_PATH to the appropriate value:
335 LD_LIBRARY_PATH=/lib:/opt/lib
336 export LD_LIBRARY_PATH
338 This setting needs to be in effect while Perl is built, but also when
339 the programs are run.
343 July 2022, for DSM 5.1.5022 and DSM 6.1-15101-4, and DSM-7.1-42661-3.