Gentoo Archives: gentoo-commits

From: "Friedrich Oslage (bluebird)" <bluebird@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo commit in xml/htdocs/proj/en/base/sparc: index.xml multilib.xml
Date: Wed, 31 Dec 2008 15:17:36
Message-Id: E1LI2pB-0001Ko-Mn@stork.gentoo.org
1 bluebird 08/12/31 15:17:33
2
3 Modified: index.xml
4 Added: multilib.xml
5 Log:
6 Move multilib migration guide from dev space to normal docs space
7
8 Revision Changes Path
9 1.45 xml/htdocs/proj/en/base/sparc/index.xml
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/base/sparc/index.xml?rev=1.45&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/base/sparc/index.xml?rev=1.45&content-type=text/plain
13 diff : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/base/sparc/index.xml?r1=1.44&r2=1.45
14
15 Index: index.xml
16 ===================================================================
17 RCS file: /var/cvsroot/gentoo/xml/htdocs/proj/en/base/sparc/index.xml,v
18 retrieving revision 1.44
19 retrieving revision 1.45
20 diff -u -r1.44 -r1.45
21 --- index.xml 14 Nov 2008 20:58:15 -0000 1.44
22 +++ index.xml 31 Dec 2008 15:17:33 -0000 1.45
23 @@ -112,6 +112,9 @@
24 <uri link="qla2xxx.xml">How to get QLA2xxx adapters working with kernel
25 >=2.6.18</uri>
26 </li>
27 + <li>
28 + <uri link="multilib.xml">Gentoo Linux SPARC Multilib Migration Guide</uri>
29 + </li>
30 </ul>
31
32 <p>
33
34
35
36 1.1 xml/htdocs/proj/en/base/sparc/multilib.xml
37
38 file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/base/sparc/multilib.xml?rev=1.1&view=markup
39 plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/base/sparc/multilib.xml?rev=1.1&content-type=text/plain
40
41 Index: multilib.xml
42 ===================================================================
43 <?xml version="1.0" encoding="UTF-8"?>
44 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
45 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/proj/en/base/sparc/multilib.xml,v 1.1 2008/12/31 15:17:33 bluebird Exp $ -->
46
47 <guide link="/doc/en/guide.xml" lang="en">
48 <title>Gentoo Linux SPARC Multilib Migration Guide</title>
49
50 <author title="Author">
51 <mail link="bluebird"/>
52 </author>
53
54 <abstract>
55 This guide will help you to migrate your existing Gentoo Linux SPARC
56 installation from a non-multilib profile to a multilib profile.
57 </abstract>
58
59 <!-- The content of this document is licensed under the CC-BY-SA license -->
60 <!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
61 <license/>
62
63 <version>1.2</version>
64 <date>2008-12-30</date>
65
66 <chapter>
67 <title>Overview</title>
68 <section>
69 <body>
70
71 <p>
72 This guide will help you to migrate your existing Gentoo Linux SPARC
73 installation from a non-multilib profile to a multilib profile.
74 </p>
75
76 <impo>
77 Multilib is still experimental, do not use it if you have to rely on a fully
78 working machine.
79 </impo>
80
81 <p>
82 Multlib has advantages but it also has some disadvantages, these are the facts:
83 </p>
84
85 <dl>
86 <dt>Advantages</dt>
87 <dd>
88 <ul>
89 <li>You can compile and run 64 bit binaries</li>
90 <li>Gcc can handle -m32 and -m64 (biarch)</li>
91 <li>One compiler for both kernel and userland</li>
92 </ul>
93 </dd>
94 <dt>Drawbacks</dt>
95 <dd>
96 <ul>
97 <li>Compiling gcc takes twice as long as it did before</li>
98 <li>Compiling glibc takes twice as long as it did before</li>
99 </ul>
100 </dd>
101 </dl>
102
103
104 </body>
105 </section>
106 </chapter>
107
108 <chapter>
109 <title>Preparation</title>
110 <section>
111 <title>Unmask required packages</title>
112 <body>
113
114 <p>
115 The multilib profile requires recent versions of gcc and glibc, to be
116 exact:
117 </p>
118
119 <ul>
120 <li><c>&gt;=sys-devel/gcc-4.3.2-r1</c></li>
121 <li><c>&gt;=sys-libs/glibc-2.7</c></li>
122 </ul>
123
124 <p>
125 Depending on your configuration you may need to add them to
126 <path>/etc/portage/packages.keywords</path> to avoid holdups.
127 </p>
128
129 </body>
130 </section>
131
132 <section>
133 <title>Kernel configuration</title>
134 <body>
135
136 <p>
137 The Linux kernel can be configured to disable 64 bit ELF support and only
138 enable 32 bit ELF support. Make sure your kernel <e>is not</e> configured like
139 that and can acually run 64 bit ELF binaries.
140 </p>
141
142 <pre caption="Configuration options">
143 Executable file formats ---&gt;
144 &lt;*&gt; Kernel support for ELF binaries
145 </pre>
146
147 <p>
148 Which translated to the <path>.config</path> file would be:
149 </p>
150
151 <pre caption=".config options">
152 CONFIG_BINFMT_ELF=y
153 </pre>
154
155 </body>
156 </section>
157 </chapter>
158
159 <chapter>
160 <title>Migration</title>
161
162 <section>
163 <title>Update the make.profile symlink</title>
164 <body>
165
166 <p>
167 Because the profile is still in an experimental state you have to create/change
168 the <path>/etc/make.profile</path> symlink manually.
169 </p>
170 <p>
171 The multilib profile also provides these three sub-profiles for your
172 convenience, just like 2008.0 does:
173 </p>
174
175 <ul>
176 <li>desktop</li>
177 <li>developer</li>
178 <li>server</li>
179 </ul>
180
181 <pre caption="Update the make.profile symlink">
182 $ <i>rm /etc/make.profile</i>
183
184 $ <i>ln -s /usr/portage/profiles/default/linux/sparc/experimental/multilib /etc/make.profile</i>
185 or
186 $ <i>ln -s /usr/portage/profiles/default/linux/sparc/experimental/multilib/desktop /etc/make.profile</i>
187 or
188 $ <i>ln -s /usr/portage/profiles/default/linux/sparc/experimental/multilib/developer /etc/make.profile</i>
189 or
190 $ <i>ln -s /usr/portage/profiles/default/linux/sparc/experimental/multilib/server /etc/make.profile</i>
191 </pre>
192
193 </body>
194 </section>
195
196 <section>
197 <title>Rename lib to lib32</title>
198 <body>
199
200 <p>
201 Though it is not fully compliant with FHS, common practice in Gentoo is to store
202 32 bit libraries in <e>lib32</e>, 64 bit libraries in <e>lib64</e> and to have
203 <e>lib</e> as a symlink to the default library directory.
204 </p>
205 <p>
206 The 2008.0 profile stores libraries in <e>lib</e>. These commands will rename
207 all <e>lib</e> directories to <e>lib32</e> and create a symlink <e>lib</e> to
208 <e>lib32</e>. Additionally they will create empty <e>lib64</e> directories.
209 </p>
210
211 <warn>
212 Do not exit your shell while doing this! You would not be able to login again
213 and would have to boot a livecd to recover.
214 </warn>
215
216 <pre caption="Rename lib to lib32">
217 $ <i>mv /lib /lib32</i>
218 # sln is a statically linked version of ln
219 $ <i>sln lib32 /lib</i>
220 $ <i>mkdir -p /lib64</i>
221 $ <i>touch /lib64/.keep</i>
222 $ <i>for dir in /usr/qt/*/lib /usr/kde/*/lib /usr/local/lib /usr/lib</i>
223 <i>do</i>
224 <i>if [ -d ${dir} ]</i>
225 <i>then</i>
226 <i>mv ${dir} ${dir}32</i>
227 <i>ln -sf lib32 ${dir}</i>
228 <i>mkdir -p ${dir}64</i>
229 <i>touch ${dir}64/.keep</i>
230 <i>fi</i>
231 <i>done</i>
232 $ <i>ldconfig</i>
233 </pre>
234
235 </body>
236 </section>
237
238 <section>
239 <title>Remerge baselayout</title>
240 <body>
241
242 <p>
243 For multilib profiles, <c>sys-apps/baselayout</c> installs additional files,
244 like <path>/etc/env.d/04multilib</path>. To get these you need to remerge it.
245 </p>
246
247 <pre caption="Remerge baselayout">
248 $ <i>emerge --oneshot sys-apps/baselayout</i>
249 $ <i>env-update &amp;&amp; source /etc/profile</i>
250 </pre>
251
252 </body>
253 </section>
254
255 <section>
256 <title>Install a multilib glibc</title>
257 <body>
258
259 <p>
260 To compile a multilib glibc you need a biarch gcc but to compile a biarch gcc
261 you need a multilib glibc. You <e>could</e> compile glibc using a
262 cross-compiler such as <c>sys-devel/kgcc64</c> but that is not something you
263 would enjoy...
264 </p>
265 <p>
266 Therefore we will install a binary packages of glibc first and afterwards,
267 once the migration is complete, remerge it with your USE- and CFLAGS.
268 </p>
269
270 <pre caption="Install binary glibc package">
271 $ <i>PORTAGE_BINHOST="http://dev.gentoo.org/~bluebird/sparc-multilib/packages" emerge --getbinpkgonly --usepkgonly --oneshot sys-libs/glibc</i>
272 </pre>
273
274 <p>
275 If you get <e>All ebuilds that could satisfy "sys-libs/glibc" have been
276 masked.</e> try using a different version of glibc, these three are available
277 as binary packages:
278 </p>
279
280 <ul>
281 <li><c>=sys-libs/glibc-2.7-r2</c></li>
282 <li><c>=sys-libs/glibc-2.8_p20080602-r1</c></li>
283 <li><c>=sys-libs/glibc-2.9_p20081201-r1</c></li>
284 </ul>
285
286 </body>
287 </section>
288
289 <section>
290 <title>Install a biarch gcc</title>
291 <body>
292
293 <p>
294 With a multilib glibc installed you can simply compile a biarch gcc using
295 portage.
296 </p>
297
298 <pre caption="Install biarch gcc">
299 $ <i>emerge --oneshot sys-devel/gcc</i>
300 </pre>
301
302 <p>
303 Now you need to configure your system to use the newly installed gcc using
304 gcc-config. Replace <e>4.3.2</e> with the version you just installed.
305 </p>
306
307 <pre caption="Set native-compiler">
308 $ <i>gcc-config sparc-unknown-linux-gnu-4.3.2</i>
309 $ <i>source /etc/profile</i>
310 </pre>
311
312 </body>
313 </section>
314
315 <section>
316 <title>Remerge glibc with your preferred settings</title>
317 <body>
318
319 <p>
320 Remerge glibc with your system specific settings(USE-flags, CFLAGS and such).
321 </p>
322
323 <pre caption="Remerge glibc">
324 $ <i>emerge --oneshot sys-libs/glibc</i>
325 </pre>
326
327 <p>
328 If the glibc compilation finishes without any strange error messages it means
329 that your multilib setup is working. You can use <c>file</c> to verify this by
330 checking the contents of <path>/lib64</path>.
331 </p>
332 <pre caption="Verify multilib glibc installation">
333 $ <i>file /lib64/libc-*.so</i>
334 /lib64/libc-2.7.so: ELF 64-bit MSB shared object, SPARC V9, version 1 (SYSV), for GNU/Linux 2.6.9, stripped
335 </pre>
336
337 </body>
338 </section>
339
340 <section>
341 <title>Unmerge kgcc64</title>
342 <body>
343
344 <p>
345 <c>sys-devel/gcc</c> can compile the kernel now, therefore you don't need
346 <c>sys-devel/kgcc64</c> anymore to do it. If you have some scripts that need
347 it, just replace <e>sparc64-unknown-linux-gnu-gcc</e> with
348 <e>sparc-unknown-linux-gnu-gcc -m64</e>.
349 </p>
350
351 <pre caption="Unmerge kgcc64">
352 $ <i>emerge --unmerge sys-devel/kgcc64</i>
353 </pre>
354
355 </body>
356 </section>
357
358 <section>
359 <title>Remerge world</title>
360 <body>
361
362 <note>
363 This step is optional.
364 </note>
365
366 <p>
367 Your system was build with <e>lib</e> as library directory, now it's
368 <e>lib32</e>. Though you will not notice anything because there is a symlink in
369 place but if you have a lot of spare cpu time and like your system clean...
370 </p>
371 <p>
372 Or in other words: If you are one of those guys who uses portage's
373 multilib-strict feature just for the fun of it...this is for you!
374 </p>
375
376 <pre caption="Remerge world">
377 $ <i>emerge --emptytree world</i>
378 </pre>
379
380 </body>
381 </section>
382 </chapter>
383 <chapter>
384 <title>Closing-off</title>
385 <section>
386 <title>Usage example</title>
387 <body>
388
389 <p>
390 Here's a simple example how to compile a hello world programm in both 32 and
391 64 bit.
392 </p>
393
394 <pre caption="Sample hello world program, hello_world.c">
395 <ident>#include</ident> &lt;<var>stdio.h</var>&gt;
396 <ident>#include</ident> &lt;<var>stdlib.h</var>&gt;
397
398 <stmt>int main(int argc, char** argv)</stmt> {
399 <keyword>printf</keyword>("<const>hello, world\n</const>");
400 <keyword>return</keyword> <const>EXIT_SUCCESS</const>;
401 }
402 </pre>
403
404 <pre caption="Compile it as 32 bit binary">
405 $ <i>sparc-unknown-linux-gnu-gcc -m32 -o hello_world hello_world.c</i>
406 or
407 $ <i>sparc-unknown-linux-gnu-gcc -o hello_world hello_world.c</i>
408 </pre>
409
410 <note>
411 If you specify neigther -m32 nor -m64 the compiler will default to -m32.
412 </note>
413
414 <pre caption="Compile it as 64 bit binary">
415 $ <i>sparc-unknown-linux-gnu-gcc -m64 -o hello_world hello_world.c</i>
416 </pre>
417
418 </body>
419 </section>
420
421 <section>
422 <title>Things you shouldn't do</title>
423 <body>
424
425 <p>
426 So now you have a multlib installation and you are thinking about adding -m64
427 to CFLAGS in /etc/make.conf and recompiling your entire userland in 64 bit?
428 PLEASE DO NOT!
429 </p>
430
431 <warn>
432 <e>Doing this will render your system unusable!</e> Any bugs you report
433 will just be closed without any further action.
434 </warn>
435
436 <p>
437 While compiling everything in 64 bit may be a good idea on other 64 bit
438 architectures, like AMD64, on SPARC it is not. There are good reasons why we
439 have been using a pure 32 bit userland until now, some of these are:
440 </p>
441
442 <ul>
443 <li>32 bit is faster than 64 bit</li>
444 <li>32 bit is well tested, 64 bit isn't tested at all</li>
445 <li>2039 is still long way off</li>
446 </ul>
447
448 <p>
449 The only reasons why it <e>might</e> be appropriate to compile an application
450 in 64 bit are:
451 </p>
452
453 <ul>
454 <li>It needs to access more than 4GB of memory. In the real world this only
455 applies to huge databases.</li>
456 <li>It needs to talk to the kernel directly. Some applications, like
457 <c>net-firewall/iptables</c>, contain ugly hacks to support the 64 bit
458 kernel/32 bit userland thing.</li>
459 <li>It is a kernel.</li>
460 </ul>
461
462 <p>
463 If you would like to read more about the differences between 32 and 64 bit,
464 there are dozens of webpages about it on the internet, one of them is
465 <uri>http://www.superlogic.net/downloads/pub/docs/64bit.htm</uri>.
466 </p>
467
468 </body>
469 </section>
470 </chapter>
471
472 </guide>