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

Last change on this file since f347da9 was f347da9, checked in by Joel Sherrill <joel.sherrill@…>, on 02/04/04 at 00:34:00

2004-02-03 Joel Sherrill <joel@…>

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