1PERLSYNOLOGY(1) Perl Programmers Reference Guide PERLSYNOLOGY(1)
2
3
4
6 perlsynology - Perl 5 on Synology DSM systems
7
9 Synology manufactures a vast number of Network Attached Storage (NAS)
10 devices that are very popular in large organisations as well as small
11 businesses and homes.
12
13 The NAS systems are equipped with Synology Disk Storage Manager (DSM),
14 which is a trimmed-down Linux system enhanced with several tools for
15 managing the NAS. There are several flavours of hardware: Marvell
16 Armada (ARMv5tel, ARMv7l), Intel Atom (i686, x86_64), Freescale QorIQ
17 (PPC), and more. For a full list see the Synology FAQ
18 <https://kb.synology.com/en-
19 global/DSM/tutorial/What_kind_of_CPU_does_my_NAS_have>.
20
21 Since it is based on Linux, the NAS can run many popular Linux software
22 packages, including Perl. In fact, Synology provides a ready-to-install
23 package for Perl, depending on the version of DSM the installed perl
24 ranges from 5.8.6 on DSM-4.3 to 5.28.1 on DSM-7.1.
25
26 There is an active user community that provides many software packages
27 for the Synology DSM systems; at the time of writing this document they
28 provide Perl version 5.28.1.
29
30 This document describes various features of Synology DSM operating
31 system that will affect how Perl 5 (hereafter just Perl) is configured,
32 compiled and/or runs. It has been compiled and verified by Johan
33 Vromans for the Synology DS413 (QorIQ), with feedback from H.Merijn
34 Brand (DS213: ARMv5tel, RS815: Intel Atom x64, and DS218+: Celeron
35 J3355).
36
37 Setting up the build environment
38 DSM 7
39
40 For a comfortable development environment, Entware is currently the
41 only viable solution. Just follow the detailed instructions on Install
42 Entware on Synology NAS
43 <https://github.com/Entware/Entware/wiki/Install-on-Synology-NAS>.
44 supported architectures are armv5, armv7, mipsel, wl500g, x86_32, and
45 x86_64. Check here <https://pkg.entware.net/binaries/> for supported
46 platforms.
47
48 That github link also shows what environments should be supported.
49
50 It was tested on DSM-7.1 by H.Merijn Brand on a DS218+ and a DS220+
51 (both Intel x64).
52
53 Entware comes with a precompiled 5.26.1 (Jan 2018) that allowes
54 building shared XS code. Note that this installation does not use a
55 site_perl folder. The available "cpan" works. If all required
56 development packages are installed too, also for XS.
57
58 Installing perl from the Community package center:
59
60 • Using your favourite browser open the DSM management page and start
61 the Package Center.
62
63 • In Settings, add the following Package Sources:
64
65 Name: Community
66 Location: https://synopackage.com/repository/spk/All
67
68 • Still in Settings, in Channel Update, select Beta Channel.
69
70 To complete the development environment, install make and gcc
71
72 ds220# opkg install make gcc
73
74 Then, optionally, make sure you use the more recent bash and gawk.
75
76 ds220# opkg install bash gawk
77 ds220# cd /usr/bin
78 ds220# mv bash bash.syno
79 ds220# ln -s /opt/bin/bash .
80
81 In order to have Configure find the required libraries
82
83 ds220# cd /opt/lib
84 ds220# ln -s libcrypt.so.? libcrypt.so
85 ds220# ln -s libdl.so.? libdl.so
86 ds220# ln -s libgdbm.so.? libgdbm.so
87 ds220# ln -s libgdbm_compat.so.? libgdbm_compat.so
88 ds220# ln -s libm.so.? libm.so
89 ds220# ln -s libpthread.so.? libpthread.so
90 ds220# ln -s libutil.so.? libutil.so
91
92 DSM 6
93
94 Using iPkg has been deprecated on DSM 6, but an alternative is
95 available for DSM 6: entware/opkg. For instructions on how to use that,
96 please read Install Entware-ng on Synology NAS
97 <https://github.com/Entware-ng/Entware-ng/wiki/Install-on-Synology-NAS>
98
99 That sadly does not (yet) work on QorIQ. At the moment of writing, the
100 supported architectures are armv5, armv7, mipsel, wl500g, x86_32, and
101 x86_64. Check here <https://pkg.entware.net/binaries/> for supported
102 platforms.
103
104 Entware-ng comes with a precompiled 5.24.1 (June 2017) that allowes
105 building shared XS code. Note that this installation does not use a
106 site_perl folder. The available "cpan" works. If all required
107 development packages are installed too, also for XS.
108
109 DSM 5
110
111 As DSM is a trimmed-down Linux system, it lacks many of the tools and
112 libraries commonly found on Linux. The basic tools like sh, cp, rm,
113 etc. are implemented using BusyBox
114 <https://en.wikipedia.org/wiki/BusyBox>.
115
116 • Using your favourite browser open the DSM management page and start
117 the Package Center.
118
119 • If you want to smoke test Perl, install "Perl".
120
121 • In Settings, add the following Package Sources:
122
123 https://www.cphub.net
124 http://packages.quadrat4.de
125
126 As these two are both discontinued, it is unlikely you will be able
127 to set up a build environment on DSM 5.
128
129 • Still in Settings, in Channel Update, select Beta Channel.
130
131 • Press Refresh. In the left panel the item "Community" will appear.
132 Click it. Select "Bootstrap Installer Beta" and install it.
133
134 • Likewise, install "iPKGui Beta".
135
136 The application window should now show an icon for iPKGui.
137
138 • Start iPKGui. Install the packages "make", "gcc" and "coreutils".
139
140 If you want to smoke test Perl, install "patch".
141
142 The next step is to add some symlinks to system libraries. For example,
143 the development software expect a library "libm.so" that normally is a
144 symlink to "libm.so.6". Synology only provides the latter and not the
145 symlink.
146
147 Here the actual architecture of the Synology system matters. You have
148 to find out where the gcc libraries have been installed. Look in /opt
149 for a directory similar to arm-none-linux-gnueab or powerpc-linux-
150 gnuspe. In the instructions below I'll use powerpc-linux-gnuspe as an
151 example.
152
153 • On the DSM management page start the Control Panel.
154
155 • Click Terminal, and enable SSH service.
156
157 • Close Terminal and the Control Panel.
158
159 • Open a shell on the Synology using ssh and become root.
160
161 • Execute the following commands:
162
163 cd /lib
164 ln -s libm.so.6 libm.so
165 ln -s libcrypt.so.1 libcrypt.so
166 ln -s libdl.so.2 libdl.so
167 cd /opt/powerpc-linux-gnuspe/lib (or
168 /opt/arm-none-linux-gnueabi/lib)
169 ln -s /lib/libdl.so.2 libdl.so
170
171 WARNING: When you perform a system software upgrade, these links will
172 disappear and need to be re-established.
173
174 Compiling Perl 5
175 When the build environment has been set up, building and testing Perl
176 is straightforward. The only thing you need to do is download the
177 sources as usual, and add a file Policy.sh as follows:
178
179 # Administrivia.
180 perladmin="your.email@goes.here"
181
182 # Install Perl in a tree in /opt/perl instead of /opt/bin.
183 prefix=/opt/perl
184
185 # Select the compiler. Note that there is no 'cc' alias or link
186 # on older DSM versions
187 cc=gcc
188 awk=/opt/bin/gawk
189
190 # Build flags. Optional
191 ccflags="-DDEBUGGING"
192
193 # Library and include paths.
194 locincpth="/opt/include"
195 loclibpth="/opt/lib /usr/local/lib /usr/lib"
196 libpth="/opt/lib /usr/local/lib /usr/lib"
197
198 You may want to create the destination directory and give it the right
199 permissions before installing, thus eliminating the need to build Perl
200 as a super user.
201
202 In the directory where you unpacked the sources, issue the familiar
203 commands:
204
205 $ bash ./Configure -Dusedevel -Duseshrplib -Duse64bitall -des
206 $ make -j2
207 $ env TEST_JOBS=2 make test_harness
208 $ make install
209
210 Known problems
211 Configure
212
213 The GNU C-compiler might spit out unexpected stuff under -v, which
214 causes the analysis of cppsymbols to fail because of unmatched quotes.
215
216 You'll note if config.sh fails with a syntax error.
217
218 Build
219
220 Error message "No error definitions found".
221 This error is generated when it is not possible to find the local
222 definitions for error codes, due to the uncommon structure of the
223 Synology file system.
224
225 This error was fixed in the Perl development git for version 5.19,
226 commit 7a8f1212e5482613c8a5b0402528e3105b26ff24.
227
228 Failing tests
229
230 ext/DynaLoader/t/DynaLoader.t
231 One subtest fails due to the uncommon structure of the Synology
232 file system. The file /lib/glibc.so is missing.
233
234 WARNING: Do not symlink /lib/glibc.so.6 to /lib/glibc.so or some
235 system components will start to fail.
236
237 Smoke testing Perl
238 If building completes successfully, you can set up smoke testing as
239 described in the Test::Smoke documentation.
240
241 For smoke testing you need a running Perl. You can either install the
242 Synology supplied package for Perl 5.8.6, or build and install your
243 own, much more recent version.
244
245 Note that I could not run successful smokes when initiated by the
246 Synology Task Scheduler. I resorted to initiating the smokes via a cron
247 job run on another system, using ssh:
248
249 ssh nas1 wrk/Test-Smoke/smoke/smokecurrent.sh
250
251 Local patches
252
253 When local patches are applied with smoke testing, the test driver will
254 automatically request regeneration of certain tables after the patches
255 are applied. The Synology supplied Perl 5.8.6 (at least on the DS413)
256 is NOT capable of generating these tables. It will generate opcodes
257 with bogus values, causing the build to fail.
258
259 You can prevent regeneration by adding the setting
260
261 'flags' => 0,
262
263 to the smoke config, or by adding another patch that inserts
264
265 exit 0 if $] == 5.008006;
266
267 in the beginning of the "regen.pl" program.
268
269 Adding libraries
270 The above procedure describes a basic environment and hence results in
271 a basic Perl. If you want to add additional libraries to Perl, you may
272 need some extra settings.
273
274 For example, the basic Perl does not have any of the DB libraries (db,
275 dbm, ndbm, gdsm). You can add these using iPKGui, however, you need to
276 set environment variable LD_LIBRARY_PATH to the appropriate value:
277
278 LD_LIBRARY_PATH=/lib:/opt/lib
279 export LD_LIBRARY_PATH
280
281 This setting needs to be in effect while Perl is built, but also when
282 the programs are run.
283
285 July 2022, for DSM 5.1.5022 and DSM 6.1-15101-4, and DSM-7.1-42661-3.
286
288 Johan Vromans <jvromans@squirrel.nl> H. Merijn Brand
289 <cpan@tux.freedom.nl>
290
291
292
293perl v5.38.2 2023-11-30 PERLSYNOLOGY(1)