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