source: rtems/doc/started/buildc.t @ e630235

4.115
Last change on this file since e630235 was a91dfbf9, checked in by Joel Sherrill <joel.sherrill@…>, on 09/25/08 at 19:34:41

2008-09-25 Joel Sherrill <joel.sherrill@…>

  • setup.def, started/buildc.t: Update.
  • Property mode set to 100644
File size: 31.2 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-2002.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6@c  $Id$
7@c
8
9@chapter Building the GNU Cross Compiler Toolset
10
11NOTE:  This chapter does @b{NOT} apply if you installed
12prebuilt toolset executables for BINUTILS, GCC, NEWLIB,
13and GDB.  If you installed prebuilt executables for all
14of those, proceed to @ref{Building RTEMS}.  If you require
15a GDB with a special configuration to connect to your
16target board, then proceed to @ref{Building the GNU Debugger GDB}
17for some advice.
18
19This chapter describes the steps required to acquire the
20source code for a GNU cross compiler toolset, apply
21any required RTEMS specific patches, compile that
22toolset and install it.
23
24It is recommended that when toolset binaries are available for
25your particular host, that they be used.  Prebuilt binaries
26are much easier to install.
27
28@c
29@c  Building BINUTILS GCC and NEWLIB
30@c
31@section Building BINUTILS GCC and NEWLIB
32
33NOTE: This step is NOT required if prebuilt executables for
34BINUTILS, GCC, and NEWLIB were installed.
35
36This section describes the process of building BINUTILS, GCC, and
37NEWLIB using a variety of methods.  Included is information on
38obtaining the source code and patches, applying patches, and
39building and installing the tools using multiple methods.
40
41@c
42@c  Obtain Source and Patches for BINUTILS GCC and NEWLIB
43@c
44
45@subsection Obtain Source and Patches for BINUTILS GCC and NEWLIB
46
47NOTE: This step is required for all methods of building BINUTILS,
48GCC, and NEWLIB.
49
50This section lists the components required to build BINUTILS, GCC,
51and NEWLIB from source to target RTEMS.  These files should be
52placed in your @code{archive} directory.  Included are the locations
53of each component as well as any required RTEMS specific patches.
54
55@need 1000
56@subheading @value{GCCUNTAR}
57@example
58    FTP Site:    @value{GCCFTPSITE}
59    Directory:   @value{GCCFTPDIR}
60    File:        @value{GCCTAR}
61@c @ifset use-html
62    URL:         @uref{ftp://@value{GCCFTPSITE}@value{GCCFTPDIR}/@value{GCCTAR},,ftp://@value{GCCFTPSITE}@value{GCCFTPDIR}/@value{GCCTAR}}
63@c    URL:         ftp://@value{GCCFTPSITE}@value{GCCFTPDIR}
64@c @end ifset
65@end example
66
67@need 1000
68@subheading @value{BINUTILSUNTAR}
69@example
70    FTP Site:    @value{BINUTILSFTPSITE}
71    Directory:   @value{BINUTILSFTPDIR}
72    File:        @value{BINUTILSTAR}
73@c @ifset use-html
74    URL:         @uref{ftp://@value{BINUTILSFTPSITE}@value{BINUTILSFTPDIR}/@value{BINUTILSTAR},,ftp://@value{BINUTILSFTPSITE}@value{BINUTILSFTPDIR}/@value{BINUTILSTAR}}
75@c    URL:         ftp://@value{BINUTILSFTPSITE}@value{BINUTILSFTPDIR}/@value{BINUTILSTAR}
76@c @end ifset
77@end example
78
79@need 1000
80@subheading @value{NEWLIBUNTAR}
81@example
82    FTP Site:    @value{NEWLIBFTPSITE}
83    Directory:   @value{NEWLIBFTPDIR}
84    File:        @value{NEWLIBTAR}
85@c @ifset use-html
86    URL:         @uref{ftp://@value{NEWLIBFTPSITE}@value{NEWLIBFTPDIR}/@value{NEWLIBTAR},,ftp://@value{NEWLIBFTPSITE}@value{NEWLIBFTPDIR}/@value{NEWLIBTAR}}
87@c    URL:         ftp://@value{NEWLIBFTPSITE}@value{NEWLIBFTPDIR}/@value{NEWLIBTAR}
88@c @end ifset
89@end example
90
91@need 1000
92@subheading RTEMS Specific Tool Patches and Scripts
93@example
94    FTP Site:    @value{RTEMSFTPSITE}
95    Directory:   @value{RTEMSFTPDIR}/SOURCES/@value{RTEMSAPI}
96@ifset BINUTILSPATCHVERSION
97    File:        @value{BINUTILSRTEMSPATCH}
98@end ifset
99@ifset NEWLIBPATCHVERSION
100    File:        @value{NEWLIBRTEMSPATCH}
101@end ifset
102@ifset GCCPATCHVERSION
103    File:        @value{GCCRTEMSPATCH}
104@end ifset
105@ifset use-html
106    URL:         @uref{ftp://@value{RTEMSFTPSITE}@value{RTEMSFTPDIR}/SOURCES/@value{RTEMSAPI},,ftp://@value{RTEMSFTPSITE}@value{RTEMSFTPDIR}/SOURCES/@value{RTEMSAPI}}
107@c    URL:         ftp://@value{RTEMSFTPSITE}@value{RTEMSFTPDIR}/SOURCES/@value{RTEMSAPI}
108@end ifset
109@end example
110
111The individual components in the RTEMS Development Toolset are
112updated independently of one another by their respective
113maintainers.  In addition, the patches which the RTEMS Project
114has determined are necessary are subject to change as users
115report issues on individual host and target platforms.  As
116a result, it is possible that the versions listed in this
117document are @b{NOT} the latest ones available.  The latest
118patches for each tool are always available from RTEMS CVS
119on the respective branch and should always be mirrored on the
120RTEMS ftp site.  It is recommended that before building a
121toolset from source, you verify you are using the
122latest patches.
123
124@c
125@c  Unarchiving the Tools
126@c
127@subsection Unarchiving the Tools
128
129NOTE: This step is required if building BINUTILS, GCC, and NEWLIB
130using the procedure described in @ref{Using configure and make}.
131It is @b{NOT} required if using the procedure
132described in @ref{Using RPM to Build BINUTILS GCC and NEWLIB}.
133
134GNU source distributions are archived using @code{tar} and
135compressed using either @code{gzip} or @code{bzip}. 
136If compressed with @code{gzip}, the extension @code{.gz} is used.
137If compressed with @code{bzip}, the extension @code{.bz2} is used.
138
139While in the @code{tools} directory, unpack the compressed
140tar files for BINUTILS, GCC, and NEWLIB using the appropriate
141command based upon the compression program used.
142
143@example
144cd tools
145tar xzf ../archive/TOOLNAME.tar.gz  # for gzip'ed tools
146tar xjf ../archive/TOOLNAME.tar.bz2 # for bzip'ed tools
147@end example
148
149After the compressed tar files have been unpacked using
150the appropriate commands, the following
151directories will have been created under tools.
152
153@itemize @bullet
154@item @value{BINUTILSUNTAR}
155@item @value{GCCUNTAR}
156@item @value{NEWLIBUNTAR}
157@end itemize
158
159The tree should look something like the following figure:
160
161@example
162@group
163/whatever/prefix/you/choose/
164        archive/
165            @value{GCCTAR}
166            @value{BINUTILSTAR}
167            @value{NEWLIBTAR}
168@ifset GCCPATCHVERSION
169            @value{GCCRTEMSPATCH}
170@end ifset
171@ifset BINUTILSPATCHVERSION
172            @value{BINUTILSRTEMSPATCH}
173@end ifset
174@ifset NEWLIBPATCHVERSION
175            @value{NEWLIBRTEMSPATCH}
176@end ifset
177        tools/
178            @value{BINUTILSUNTAR}/
179            @value{GCCUNTAR}/
180            @value{NEWLIBUNTAR}/
181@end group
182@end example
183
184@c
185@c  Applying RTEMS Patches
186@c
187
188@subsection Applying RTEMS Patches
189
190NOTE: This step is required if building BINUTILS, GCC, and NEWLIB
191using the procedures described in @ref{Using configure and make}.
192It is @b{NOT} required if using the procedure
193described in @ref{Using RPM to Build BINUTILS GCC and NEWLIB}.
194
195This section describes the process of applying the RTEMS patches
196to GCC, NEWLIB, and BINUTILS.
197
198@c
199@c  GCC patches
200@c
201
202@subheading Apply RTEMS Patch to GCC
203
204@ifclear GCCPATCHVERSION
205No RTEMS specific patches are required for @value{GCCUNTAR} to
206support @value{RTEMSVERSION}.
207@end ifclear
208
209@ifset GCCPATCHVERSION
210
211Apply the patch using the following command sequence:
212
213@example
214cd tools/@value{GCCUNTAR}
215cat ../../archive/@value{GCCRTEMSPATCH} | \
216    patch -p1
217@end example
218
219If the patch was compressed with the @code{gzip} program, it will
220have a suffix of @code{.gz} and you should use @code{zcat} instead
221of @code{cat} as shown above.  If the patch was compressed with
222the @code{gzip} program, it will have a suffix of @code{.bz2} and
223you should use @code{bzcat} instead of @code{cat} as shown above.
224
225Check to see if any of these patches have been rejected using the following
226sequence:
227
228@example
229cd tools/@value{GCCUNTAR}
230find . -name "*.rej" -print
231@end example
232
233If any files are found with the .rej extension, a patch has been rejected.
234This should not happen with a good patch file which is properly applied.
235
236@end ifset
237
238@c
239@c  BINUTILS patches
240@c
241
242@subheading Apply RTEMS Patch to binutils
243
244@ifclear BINUTILSPATCHVERSION
245No RTEMS specific patches are required for @value{BINUTILSUNTAR} to
246support @value{RTEMSVERSION}.
247@end ifclear
248
249@ifset BINUTILSPATCHVERSION
250Apply the patch using the following command sequence:
251
252@example
253cd tools/@value{BINUTILSUNTAR}
254cat ../../archive/@value{BINUTILSRTEMSPATCH} | \
255    patch -p1
256@end example
257
258If the patch was compressed with the @code{gzip} program, it will
259have a suffix of @code{.gz} and you should use @code{zcat} instead
260of @code{cat} as shown above.  If the patch was compressed with
261the @code{gzip} program, it will have a suffix of @code{.bz2} and
262you should use @code{bzcat} instead of @code{cat} as shown above.
263
264Check to see if any of these patches have been rejected using the following
265sequence:
266
267@example
268cd tools/@value{BINUTILSUNTAR}
269find . -name "*.rej" -print
270@end example
271
272If any files are found with the .rej extension, a patch has been rejected.
273This should not happen with a good patch file which is properly applied.
274
275@end ifset
276
277@c
278@c  Newlib patches
279@c
280
281@subheading Apply RTEMS Patch to newlib
282
283@ifclear NEWLIBPATCHVERSION
284No RTEMS specific patches are required for @value{NEWLIBUNTAR} to
285support @value{RTEMSVERSION}.
286@end ifclear
287
288@ifset NEWLIBPATCHVERSION
289
290Apply the patch using the following command sequence:
291
292@example
293cd tools/@value{NEWLIBUNTAR}
294cat ../../archive/@value{NEWLIBRTEMSPATCH} | \
295    patch -p1
296@end example
297
298If the patch was compressed with the @code{gzip} program, it will
299have a suffix of @code{.gz} and you should use @code{zcat} instead
300of @code{cat} as shown above.  If the patch was compressed with
301the @code{gzip} program, it will have a suffix of @code{.bz2} and
302you should use @code{bzcat} instead of @code{cat} as shown above.
303
304Check to see if any of these patches have been rejected using the following
305sequence:
306
307@example
308cd tools/@value{NEWLIBUNTAR}
309find . -name "*.rej" -print
310@end example
311
312If any files are found with the .rej extension, a patch has been rejected.
313This should not happen with a good patch file which is properly applied.
314
315@end ifset
316
317
318@c
319@c  Compiling and Installing BINUTILS GCC and NEWLIB
320@c
321
322@subsection Compiling and Installing BINUTILS GCC and NEWLIB
323
324There are two supported methods to compile and install BINUTILS, GCC,
325and NEWLIB:
326
327@itemize @bullet
328@item RPM
329@item direct invocation of @code{configure} and @code{make}
330@end itemize
331
332Direct invocation of @code{configure} and @code{make} provides more control
333and easier recovery from problems when building.
334
335@c
336@c  Using RPM to Build BINUTILS GCC and NEWLIB
337@c
338
339@subsubsection Using RPM to Build BINUTILS GCC and NEWLIB
340
341NOTE:  The procedures described in the following sections must
342be completed before this step:
343
344@itemize @bullet
345@item @ref{Obtain Source and Patches for BINUTILS GCC and NEWLIB}
346@end itemize
347
348RPM automatically unarchives the source and applies any needed
349patches so you do @b{NOT} have to manually perform the procedures
350described @ref{Unarchiving the Tools} and
351@ref{Applying RTEMS Patches}.
352
353This section describes the process of building binutils, gcc, and
354newlib using RPM.  RPM is a packaging format which can be used to
355distribute binary files as well as to capture the procedure and
356source code used to produce those binary files.  Before
357attempting to build any RPM from source, it is necessary to
358ensure that all required source and patches are in the @code{SOURCES}
359directory under the RPM root (probably @code{/usr/src/redhat} or
360@code{/usr/local/src/redhat}) on your machine.  This procedure
361starts by installing the source RPMs as shown in the following
362example:
363
364@example
365rpm -U @value{RTEMSRPMPREFIX}i386-rtems@value{RTEMSAPI}-binutils-@value{BINUTILSVERSION}-@value{BINUTILSRPMRELEASE}.src.rpm
366rpm -U @value{RTEMSRPMPREFIX}i386-rtems@value{RTEMSAPI}-gcc-@value{GCCVERSION}-@value{GCCRPMRELEASE}.src.rpm
367@end example
368
369The RTEMS tool source RPMS are called "nosrc" to indicate that one or
370more source files required to produce the RPMs are not present. 
371The RTEMS source RPMs typically include all required patches, but do not
372include the large @code{.tar.gz} or @code{.tgz} files for
373each component such as BINUTILS, GCC, or NEWLIB.  These are shared
374by all RTEMS RPMs regardless of target CPU and there was no reason
375to duplicate them.  You will have to get the required source
376archive files by hand and place them in the @code{SOURCES} directory
377before attempting to build.  If you forget to do this, RPM is
378smart -- it will tell you what is missing.  To determine what is
379included or referenced by a particular RPM, use a command like the
380following:
381
382@example
383@c Don't use @value{GCC*} below. This is an example
384$ rpm -q -l -p @value{RTEMSRPMPREFIX}i386-rtems@value{RTEMSAPI}-gcc-3.2.3-1.src.rpm
385gcc-3.2.3-rtems@value{RTEMSAPI}-20030507a.diff
386@value{RTEMSRPMPREFIX}i386-rtems4.7-gcc.spec
387newlib-1.11.0-rtems@value{RTEMSAPI}-20030507.diff
388@end example
389
390Notice that there are patch files (the @code{.diff} files) and a file
391describing the build procedure and files produced (the @code{.spec} file),
392but no source archives (the @code{*tar.*} files).
393When installing this source RPM
394(@code{rpm -U @value{RTEMSRPMPREFIX}i386-rtems@value{RTEMSAPI}-gcc-newlib-gcc3.2.3newlib1.11.0-1.src.rpm}),
395the @code{.spec} file is placed in the @code{SPECS} directory under the RPM root
396directory, while the @code{*.diff} files are placed into the @code{SOURCES}
397directory.
398
399@c
400@c  Configuring and Building BINUTILS using RPM
401@c
402
403@subheading Configuring and Building BINUTILS using RPM
404
405The following example illustrates the invocation of RPM to build a new,
406locally compiled, binutils binary RPM that matches the installed source
407RPM.  This example assumes that all of the required source is installed.
408
409@example
410cd <RPM_ROOT_DIRECTORY>/SPECS
411rpm -bb i386-rtems@value{RTEMSAPI}-binutils-@value{BINUTILSVERSION}.spec
412@end example
413
414If the build completes successfully, RPMS like the following will
415be generated in a build-host architecture specific subdirectory
416of the RPMS directory under the RPM root directory.
417
418@example
419@value{RTEMSRPMPREFIX}binutils-common-@value{BINUTILSVERSION}-@value{BINUTILSRPMRELEASE}.i386.rpm
420@value{RTEMSRPMPREFIX}i386-rtems@value{RTEMSAPI}-binutils-@value{BINUTILSVERSION}-@value{BINUTILSRPMRELEASE}.i386.rpm
421@end example
422
423NOTE: It may be necessary to remove the build tree in the
424@code{BUILD} directory under the RPM root directory.
425
426@c
427@c  Configuring and Building GCC and NEWLIB using RPM
428@c
429
430@subheading Configuring and Building GCC and NEWLIB using RPM
431
432The following example illustrates the invocation of RPM to build a new,
433locally compiled, set of GCC and NEWLIB binary RPMs that match the
434installed source RPM.  It is also necessary to install the BINUTILS
435RPMs and place them in your PATH.  This example assumes that all of
436the required source is installed.
437
438@example
439cd <RPM_ROOT_DIRECTORY>/RPMS/i386
440rpm -U @value{RTEMSRPMPREFIX}binutils-common-@value{BINUTILSVERSION}-@value{BINUTILSRPMRELEASE}.i386.rpm
441rpm -U @value{RTEMSRPMPREFIX}i386-rtems@value{RTEMSAPI}-binutils-@value{BINUTILSVERSION}-@value{BINUTILSRPMRELEASE}.i386.rpm
442export PATH=@value{RTEMSPREFIX}/bin:$PATH
443cd <RPM_ROOT_DIRECTORY>/SPECS
444rpm -bb i386-rtems@value{RTEMSAPI}-gcc-@value{GCCVERSION}-newlib-@value{NEWLIBVERSION}.spec
445@end example
446
447If the build completes successfully, a set of RPMS like the following will
448be generated in a build-host architecture specific subdirectory
449of the RPMS directory under the RPM root directory.
450
451@example
452@value{RTEMSRPMPREFIX}gcc-common-@value{GCCVERSION}-@value{GCCRPMRELEASE}.i386.rpm
453@value{RTEMSRPMPREFIX}i386-rtems@value{RTEMSAPI}-newlib-@value{NEWLIBVERSION}-@value{GCCRPMRELEASE}.i386.rpm
454@value{RTEMSRPMPREFIX}i386-rtems@value{RTEMSAPI}-gcc-@value{GCCVERSION}-@value{GCCRPMRELEASE}.i386.rpm
455@value{RTEMSRPMPREFIX}i386-rtems@value{RTEMSAPI}-gcc-c++-@value{GCCVERSION}-@value{GCCRPMRELEASE}.i386.rpm
456@end example
457
458NOTE: Some targets do not support building all languages.
459
460NOTE: It may be necessary to remove the build tree in the
461@code{BUILD} directory under the RPM root directory.
462
463@c
464@c  Using configure and make
465@c
466
467@subsubsection Using configure and make
468
469NOTE:  The procedures described in the following sections must
470be completed before this step:
471
472@itemize @bullet
473@item @ref{Obtain Source and Patches for BINUTILS GCC and NEWLIB}
474@item @ref{Unarchiving the Tools}
475@item @ref{Applying RTEMS Patches}
476@end itemize
477
478This section describes the process of building binutils, gcc, and
479newlib manually using @code{configure} and @code{make} directly.
480
481@c
482@c  Configuring and Building BINUTILS
483@c
484
485@subheading Configuring and Building BINUTILS
486
487The following example illustrates the invocation of
488@code{configure} and @code{make}
489to build and install @value{BINUTILSUNTAR} for the
490sparc-rtems@value{RTEMSAPI} target:
491
492@example
493mkdir b-binutils
494cd b-binutils
495../@value{BINUTILSUNTAR}/configure --target=sparc-rtems@value{RTEMSAPI} \
496  --prefix=@value{RTEMSPREFIX}
497make all
498make info
499make install
500@end example
501
502After @value{BINUTILSUNTAR} is built and installed the
503build directory @code{b-binutils} may be removed.
504
505For more information on the invocation of @code{configure}, please
506refer to the documentation for @value{BINUTILSUNTAR} or
507invoke the @value{BINUTILSUNTAR} @code{configure} command with the
508@code{--help} option.
509
510NOTE: The shell PATH variable needs to be updated to include the path
511the binutils user executables have  been installed in.  The directory
512containing the executables is the prefix used above with
513@file{bin} post-fixed.
514
515@example
516export PATH=@value{RTEMSPREFIX}/bin:$@{PATH@}
517@end example
518
519Failure to have the binutils in the path will cause the GCC and NEWLIB
520build to fail with an error message similar to:
521
522@example
523sparc-rtems@value{RTEMSAPI}-ar: command not found
524@end example
525
526@c
527@c  Configuring and Building GCC and NEWLIB
528@c
529
530@subheading Configuring and Building GCC and NEWLIB
531
532Before building @value{GCCUNTAR} and @value{NEWLIBUNTAR},
533@value{BINUTILSUNTAR} must be installed and the directory
534containing those executables must be in your PATH.
535
536The C Library is built as a subordinate component of
537@value{GCCUNTAR}.  Because of this, the @value{NEWLIBUNTAR}
538directory source must be available inside the @value{GCCUNTAR}
539source tree.  This is normally accomplished using a symbolic
540link as shown in this example:
541
542@example
543cd @value{GCCUNTAR}
544ln -s ../@value{NEWLIBUNTAR}/newlib .
545@end example
546
547The following example illustrates the invocation of
548@code{configure} and @code{make}
549to build and install @value{GCCUNTAR} with only
550C and C++ support for the sparc-rtems@value{RTEMSAPI} target:
551
552@example
553mkdir b-gcc
554cd b-gcc
555../@value{GCCUNTAR}/configure --target=sparc-rtems@value{RTEMSAPI} \
556   --with-gnu-as --with-gnu-ld --with-newlib --verbose \
557   --enable-threads --enable-languages="c,c++" \
558   --prefix=@value{RTEMSPREFIX}
559make all
560make info
561make install
562@end example
563
564After @value{GCCUNTAR} is built and installed the
565build directory @code{b-gcc} may be removed.
566
567For more information on the invocation of @code{configure}, please
568refer to the documentation for @value{GCCUNTAR} or
569invoke the @value{GCCUNTAR} @code{configure} command with the
570@code{--help} option.
571
572@c
573@c Building GCC with Ada Support
574@c
575@subheading Building GCC with Ada Support
576
577If you want a GCC toolset that includes support for Ada
578(e.g. GNAT), there are some additional requirements on
579the host environment and additional build steps to perform.
580It is critical that you use the same version of GCC/GNAT as
581the native compiler.  GNAT must be compiled with an Ada compiler
582and when building a GNAT cross-compiler, it should be
583the same version of GNAT itself.
584
585The build procedure is the same until the configure step.
586A GCC toolset with GNAT enabled requires that @code{ada}
587be included in the set of enabled languages.
588The following example illustrates the invocation of
589@code{configure} and @code{make}
590to build and install @value{GCCUNTAR} with only
591C, C++, and Ada support for the sparc-rtems@value{RTEMSAPI} target:
592
593@example
594mkdir b-gcc
595cd @value{GCCUNTAR}/gcc/ada
596touch treeprs.ads [es]info.h nmake.ad[bs]
597cd ../../../b-gcc
598../@value{GCCUNTAR}/configure --target=sparc-rtems@value{RTEMSAPI} \
599   --with-gnu-as --with-gnu-ld --with-newlib --verbose \
600   --enable-threads --enable-languages="c,c++,ada" \
601   --prefix=@value{RTEMSPREFIX}
602make all
603make info
604make -C gcc cross-gnattools
605make -C gcc ada.all.cross
606make -C gcc GNATLIBCFLAGS="USER_SELECTED_CPU_CFLAGS" gnatlib
607make install
608@end example
609
610After @value{GCCUNTAR} is built and installed the
611build directory @code{b-gcc} may be removed.
612
613@c
614@c Building the GNU Debugger GDB
615@c
616
617@section Building the GNU Debugger GDB
618
619NOTE: This step is NOT required if prebuilt executables for
620the GNU Debugger GDB were installed.
621
622The GNU Debugger GDB supports many configurations but requires some
623means of communicating between the host computer and target board.
624This communication can be via a serial port, Ethernet, BDM, or ROM emulator.
625The communication protocol can be the GDB remote protocol or GDB
626can talk directly to a ROM monitor.  This setup is target board
627specific.  The following configurations have been
628successfully used with RTEMS applications:
629
630@itemize @bullet
631@item BDM with ColdFire, 683xx, MPC860 CPUs
632@item Motorola Mxxxbug found on M68xxx VME boards
633@item Motorola PPCbug found on PowerPC VME, CompactPCI, and MTX boards
634@item ARM based Cogent EDP7312
635@item PC's using various Intel and AMD CPUs including i386,
636i486, Pentium and above, and Athlon
637@item PowerPC Instruction Simulator in GDB (PSIM)
638@item MIPS Instruction Simulator in GDB (JMR3904)
639@item Sparc Instruction Simulator in GDB (SIS)
640@item Sparc Instruction Simulator (TSIM)
641@item DINK32 on various PowerPC boards
642@end itemize
643
644GDB is currently RTEMS thread/task aware only if you are using the
645remote debugging support via Ethernet.  These are configured
646using gdb targets of the form CPU-RTEMS.  Note the capital RTEMS.
647
648It is recommended that when toolset binaries are available for
649your particular host, that they be used.  Prebuilt binaries
650are much easier to install but in the case of gdb may or may
651not include support for your particular target board.
652
653@c
654@c  Obtain Source and Patches for GDB
655@c
656
657@subsection Obtain Source and Patches for GDB
658
659NOTE: This step is required for all methods of building GDB.
660
661This section lists the components required to build GDB
662from source to target RTEMS.  These files should be
663placed in your @code{archive} directory.  Included are the locations
664of each component as well as any required RTEMS specific patches.
665
666@need 1000
667@subheading @value{GDBUNTAR}
668@example
669    FTP Site:    @value{GDBFTPSITE}
670    Directory:   @value{GDBFTPDIR}
671    File:        @value{GDBTAR}
672    URL:         @uref{@value{GDBFTPURL},,@value{GDBFTPURL}}
673@end example
674
675@need 1000
676@subheading RTEMS Specific Tool Patches and Scripts
677@example
678    FTP Site:    @value{RTEMSFTPSITE}
679    Directory:   @value{RTEMSFTPDIR}/SOURCES/@value{RTEMSAPI}
680@ifset GDBPATCHVERSION
681    File:        @value{GDBRTEMSPATCH}
682    URL:         @uref{ftp://@value{RTEMSFTPSITE}@value{RTEMSFTPDIR}/SOURCES/@value{GDBRTEMSPATCH},,ftp://@value{RTEMSFTPSITE}@value{RTEMSFTPDIR}/SOURCES/@value{GDBRTEMSPATCH}}
683@end ifset
684@end example
685
686@c
687@c  Unarchiving the GDB Distribution
688@c
689@subsection Unarchiving the GDB Distribution
690
691Use the following commands to unarchive the GDB distribution:
692
693@example
694cd tools
695tar xzf ../archive/@value{GDBTAR}
696@end example
697
698The directory @value{GDBUNTAR} is created under the tools directory.
699
700@c
701@c  Applying RTEMS Patch to GDB
702@c
703
704@subsection Applying RTEMS Patch to GDB
705
706@ifclear GDBPATCHVERSION
707No RTEMS specific patches are required for @value{GDBVERSION} to
708support @value{RTEMSVERSION}.
709@end ifclear
710
711@ifset GDBPATCHVERSION
712
713Apply the patch using the following command sequence:
714
715@example
716cd tools/@value{GDBUNTAR}
717cat archive/@value{GDBRTEMSPATCH} | \
718    patch -p1
719@end example
720
721If the patch was compressed with the @code{gzip} program, it will
722have a suffix of @code{.gz} and you should use @code{zcat} instead
723of @code{cat} as shown above.  If the patch was compressed with
724the @code{gzip} program, it will have a suffix of @code{.bz2} and
725you should use @code{bzcat} instead of @code{cat} as shown above.
726
727Check to see if any of these patches have been rejected using the following
728sequence:
729
730@example
731cd tools/@value{GDBUNTAR}
732find . -name "*.rej" -print
733@end example
734
735If any files are found with the .rej extension, a patch has been rejected.
736This should not happen with a good patch file.
737
738@end ifset
739
740@c
741@c  Compiling and Installing the GNU Debugger GDB
742@c
743
744@subsection Compiling and Installing the GNU Debugger GDB
745
746There are three methods of building the GNU Debugger:
747
748@itemize @bullet
749@item RPM
750@item direct invocation of @code{configure} and @code{make}
751@end itemize
752
753Direct invocation of @code{configure} and @code{make} provides more control
754and easier recovery from problems when building.
755
756@c
757@c  Using RPM to Build GDB
758@c
759
760@subsubsection Using RPM to Build GDB
761
762This section describes the process of building binutils, gcc, and
763newlib using RPM.  RPM is a packaging format which can be used to
764distribute binary files as well as to capture the procedure and
765source code used to produce those binary files.  Before
766attempting to build any RPM from source, it is necessary to
767ensure that all required source and patches are in the @code{SOURCES}
768directory under the RPM root (probably @code{/usr/src/redhat} or
769@code{/usr/local/src/redhat}) on your machine.  This procedure
770starts by installing the source RPMs as shown in the following
771example:
772
773@example
774rpm -U @value{RTEMSRPMPREFIX}i386-rtems@value{RTEMSAPI}-gdb-@value{GDBVERSION}-@value{GDBRPMRELEASE}.src.rpm
775@end example
776
777Because RTEMS tool RPMS are called "nosrc" to indicate that one or
778more source files required to produce the RPMs are not present.
779The RTEMS source GDB RPM does not include the large @code{.tar.gz} or
780@code{.tgz} files for GDB.  This is shared by all RTEMS RPMs
781regardless of target CPU and there was no reason
782to duplicate them.  You will have to get the required source
783archive files by hand and place them in the @code{SOURCES} directory
784before attempting to build.  If you forget to do this, RPM is
785smart -- it will tell you what is missing.  To determine what is
786included or referenced by a particular RPM, use a command like the
787following:
788
789@example
790$ rpm -q -l -p @value{RTEMSRPMPREFIX}i386-rtems@value{RTEMSAPI}-gdb-@value{GDBVERSION}-@value{GDBRPMRELEASE}.src.rpm
791gdb-@value{GDBVERSION}-rtems@value{RTEMSAPI}-@value{GDBPATCHVERSION}.diff
792gdb-@value{GDBVERSION}.tar.gz
793i386-rtems@value{RTEMSAPI}-gdb-@value{GDBVERSION}.spec
794@end example
795
796Notice that there is a patch file (the @code{.diff} file), a source archive
797file (the @code{.tar.gz}), and a file describing the build procedure and
798files produced (the @code{.spec} file).  The @code{.spec} file is placed
799in the @code{SPECS} directory under the RPM root directory.
800
801@c
802@c  Configuring and Building GDB using RPM
803@c
804
805@subheading Configuring and Building GDB using RPM
806
807The following example illustrates the invocation of RPM to build a new,
808locally compiled, binutils binary RPM that matches the installed source
809RPM.  This example assumes that all of the required source is installed.
810
811@example
812cd <RPM_ROOT_DIRECTORY>/SPECS
813rpm -bb i386-rtems@value{RTEMSAPI}-gdb-@value{GDBVERSION}.spec
814@end example
815
816If the build completes successfully, RPMS like the following will
817be generated in a build-host architecture specific subdirectory
818of the RPMS directory under the RPM root directory.
819
820@example
821@value{RTEMSRPMPREFIX}gdb-common-@value{GDBVERSION}-@value{GDBRPMRELEASE}.i386.rpm
822@value{RTEMSRPMPREFIX}i386-rtems@value{RTEMSAPI}-gdb-@value{GDBVERSION}-@value{GDBRPMRELEASE}.i386.rpm
823@end example
824
825NOTE: It may be necessary to remove the build tree in the
826@code{BUILD} directory under the RPM root directory.
827
828@c
829@c Using the GDB configure Script Directly
830@c
831
832@subsubsection Using the GDB configure Script Directly
833
834This section describes how to configure the GNU debugger for
835RTEMS targets using @code{configure} and @code{make} directly.
836The following example illustrates the invocation of @code{configure}
837and @code{make} to build and install @value{GDBUNTAR} for the
838m68k-rtems@value{RTEMSAPI} target:
839
840@example
841mkdir b-gdb
842cd b-gdb
843../@value{GDBUNTAR}/configure --target=m68k-rtems@value{RTEMSAPI} \
844  --prefix=@value{RTEMSPREFIX}
845make all
846make info
847make install
848@end example
849
850For some configurations, it is necessary to specify extra options
851to @code{configure} to enable and configure option components
852such as a processor simulator.  The following is a list of
853configurations for which there are extra options:
854
855@table @b
856@item powerpc-rtems@value{RTEMSAPI}
857@code{--enable-sim --enable-sim-powerpc --enable-sim-timebase --enable-sim-hardware}
858
859@item sparc-rtems@value{RTEMSAPI}
860@code{--enable-sim}
861
862@end table
863
864After @value{GDBUNTAR} is built and installed the
865build directory @code{b-gdb} may be removed.
866
867For more information on the invocation of @code{configure}, please
868refer to the documentation for @value{GDBUNTAR} or
869invoke the @value{GDBUNTAR} @code{configure} command with the
870@code{--help} option.
871
872@c
873@c Common Problems
874@c
875
876@section Common Problems
877
878@subsection Error Message Indicates Invalid Option to Assembler
879
880If a message like this is printed then the new cross compiler
881is most likely using the native assembler instead of the cross
882assembler or vice-versa (native compiler using new cross assembler).
883This can occur for one of the following reasons:
884
885@itemize @bullet
886
887@item Binutils Patch Improperly Applied
888@item Binutils Not Built
889@item Current Directory is in Your PATH
890
891@end itemize
892
893If you are using binutils 2.9.1 or newer with certain older versions of
894gcc, they do not agree on what the name of the newly
895generated cross assembler is.  Older binutils called it @code{as.new}
896which became @code{as.new.exe} under Windows.  This is not a valid
897file name, so @code{as.new} is now called @code{as-new}.  By using the latest
898released tool versions and RTEMS patches, this problem will be avoided.
899
900If binutils did not successfully build the cross assembler, then
901the new cross gcc (@code{xgcc}) used to build the libraries can not
902find it.  Make sure the build of the binutils succeeded.
903
904If you include the current directory in your PATH, then there
905is a chance that the native compiler will accidentally use
906the new cross assembler instead of the native one.  This usually
907indicates that "." is before the standard system directories
908in your PATH.  As a general rule, including "." in your PATH
909is a security risk and should be avoided.  Remove "." from
910your PATH.
911
912NOTE:  In some environments, it may be difficult to remove "."
913completely from your PATH.  In this case, make sure that "."
914is after the system directories containing "as" and "ld".
915
916@subsection Error Messages Indicating Configuration Problems
917
918If you see error messages like the following,
919
920@itemize @bullet
921
922@item cannot configure libiberty
923@item coff-emulation not found
924@item etc.
925
926@end itemize
927
928Then it is likely that one or more of your gnu tools is
929already configured locally in its source tree.  You can check
930for this by searching for the @code{config.status} file
931in the various tool source trees.  The following command
932does this for the binutils source:
933
934@example
935find @value{BINUTILSUNTAR} -name config.status -print
936@end example
937
938The solution for this is to execute the command
939@code{make distclean} in each of the GNU tools
940root source directory.  This should remove all
941generated files including Makefiles.
942
943This situation usually occurs when you have previously
944built the tool source for some non-RTEMS target.  The
945generated configuration specific files are still in
946the source tree and the include path specified during
947the RTEMS build accidentally picks up the previous
948configuration.  The include path used is something like
949this:
950
951@example
952-I../../@value{BINUTILSUNTAR}/gcc -I/@value{BINUTILSUNTAR}/gcc/include -I.
953@end example
954
955Note that the tool source directory is searched before the
956build directory.
957
958This situation can be avoided entirely by never using
959the source tree as the build directory -- even for
960
Note: See TracBrowser for help on using the repository browser.