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

4.104.114.84.95
Last change on this file since adee5979 was adee5979, checked in by Joel Sherrill <joel.sherrill@…>, on 05/04/00 at 19:45:17

Numerous changes based on comments from Stephan Wilms <Stephan.Wilms@…>
including a new section in the Getting Started called "Where to
Go From Here", lots of index entries added, and more configuration
table information.

  • Property mode set to 100644
File size: 18.3 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-1999.
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 C/C++ Cross Compiler Toolset
10
11This chapter describes the steps required to acquire the
12source code for a GNU cross compiler toolset, apply
13any required RTEMS specific patches, compile that
14toolset and install it.
15
16It is recommended that when toolset binaries are available for
17your particular host, that they be used.  Prebuilt binaries
18are much easier to install.
19
20@section Create the Archive and Build Directories
21
22Start by making the @code{archive} directory to contain the downloaded
23source code and the @code{tools} directory to be used as a build
24directory.  The command sequence to do this is shown
25below:
26
27@example
28mkdir archive
29mkdir tools
30@end example
31
32This will result in an initial directory structure similar to the
33one shown in the following figure:
34
35@example
36@group
37/whatever/prefix/you/choose/
38        archive/
39        tools/
40
41@end group
42@end example
43
44@c @ifset use-html
45@c @html
46@c <IMG SRC="sfile12c.jpg" WIDTH=417 HEIGHT=178
47@c      ALT="Starting Directory Organization">
48@c @end html
49@c @end ifset
50
51@section Get All the Pieces
52
53This section lists the components of an RTEMS cross development system. 
54Included are the locations of each component as well as any required RTEMS
55specific patches.
56
57@subheading @value{GCC-VERSION}
58@example
59    FTP Site:    @value{GCC-FTPSITE}
60    Directory:   @value{GCC-FTPDIR}
61    File:        @value{GCC-TAR}
62@ifset use-html
63    URL:         @uref{Download @value{GCC-VERSION}, ftp://@value{GCC-FTPSITE}@value{GCC-HTTPDIR}}
64@end ifset
65@end example
66
67@subheading @value{BINUTILS-VERSION}
68@example
69    FTP Site:    @value{BINUTILS-FTPSITE}
70    Directory:   @value{BINUTILS-FTPDIR}
71    File:        @value{BINUTILS-TAR}
72@ifset use-html
73    URL:         @uref{ftp://@value{BINUTILS-FTPSITE}@value{BINUTILS-FTPDIR}/@value{BINUTILS-TAR},Download @value{BINUTILS-VERSION}}
74@end ifset
75@end example
76
77@subheading @value{NEWLIB-VERSION}
78@example
79    FTP Site:    @value{NEWLIB-FTPSITE}
80    Directory:   @value{NEWLIB-FTPDIR}
81    File:        @value{NEWLIB-TAR}
82@ifset use-html
83    URL:         @uref{ftp://@value{NEWLIB-FTPSITE}@value{NEWLIB-FTPDIR}/@value{NEWLIB-TAR}, Download @value{NEWLIB-VERSION}}
84@end ifset
85@end example
86
87@subheading @value{RTEMS-VERSION}
88@example
89    FTP Site:    @value{RTEMS-FTPSITE}
90    Directory:   @value{RTEMS-FTPDIR}
91    File:        @value{RTEMS-TAR}
92@ifset use-html
93    URL:         @uref{ftp://@value{RTEMS-FTPSITE}@value{RTEMS-FTPDIR}, Download RTEMS components}
94@end ifset
95@end example
96
97@subheading RTEMS Hello World
98@example
99    FTP Site:    @value{RTEMS-FTPSITE}
100    Directory:   @value{RTEMS-FTPDIR}
101    File:        hello_world_c.tgz
102@ifset use-html
103    URL:         @uref{ftp://@value{RTEMS-FTPSITE}@value{RTEMS-FTPDIR}/hello_world_c.tgz, Download RTEMS Hello World}
104@end ifset
105@end example
106
107@subheading RTEMS Specific Tool Patches and Scripts
108@example
109    FTP Site:    @value{RTEMS-FTPSITE}
110    Directory:   @value{RTEMS-FTPDIR}/c_tools
111    File:        @value{BUILDTOOLS-TAR}
112@ifset BINUTILS-RTEMSPATCH
113    File:        @value{BINUTILS-RTEMSPATCH}
114@end ifset
115@ifset NEWLIB-RTEMSPATCH
116    File:        @value{NEWLIB-RTEMSPATCH}
117@end ifset
118@ifset GCC-RTEMSPATCH
119    File:        @value{GCC-RTEMSPATCH}
120@end ifset
121@ifset use-html
122    URL:         @uref{ftp://@value{RTEMS-FTPSITE}@value{RTEMS-FTPDIR}/c_tools,Download RTEMS Patches and Scripts}
123@end ifset
124@end example
125
126@section Unarchiving the Tools
127
128While in the @code{tools} directory, unpack the compressed
129tar files using the following command sequence:
130
131@example
132cd tools
133tar xzf ../archive/@value{GCC-TAR}
134tar xzf ../archive/@value{BINUTILS-TAR}
135tar xzf ../archive/@value{NEWLIB-TAR}
136tar xzf ../archive/@value{BUILDTOOLS-TAR}
137@end example
138
139After the compressed tar files have been unpacked, the following
140directories will have been created under tools.
141
142@itemize @bullet
143@item @value{BINUTILS-UNTAR}
144@item @value{GCC-UNTAR}
145@item @value{NEWLIB-UNTAR}
146@end itemize
147
148There will also be a set of scripts in the current directory
149which aid in building the tools and RTEMS.  They are:
150
151@itemize @bullet
152@item bit
153@item bit_gdb
154@item bit_rtems
155@item common.sh
156@item user.cfg
157@end itemize
158
159When the @code{bit} script is executed later in this process,
160it will automatically create this subdirectory:
161
162@itemize @bullet
163@item build-$@{CPU@}-tools
164@end itemize
165
166Similarly, the @code{bit_gdb} script will create the
167subdirectory @code{build-$@{CPU@}-gdb} and
168the @code{bit_rtems} script will create the
169subdirectory @code{build-$@{CPU@}-rtems}.
170
171The tree should look something like the following figure:
172
173@example
174@group
175/whatever/prefix/you/choose/
176        archive/
177            @value{GCC-TAR}
178            @value{BINUTILS-TAR}
179            @value{NEWLIB-TAR}
180            @value{RTEMS-TAR}
181            @value{BUILDTOOLS-TAR}
182@ifset GCC-RTEMSPATCH
183            @value{GCC-RTEMSPATCH}
184@end ifset
185@ifset BINUTILS-RTEMSPATCH
186            @value{BINUTILS-RTEMSPATCH}
187@end ifset
188@ifset NEWLIB-RTEMSPATCH
189            @value{NEWLIB-RTEMSPATCH}
190@end ifset
191            hello_world_c.tgz
192            bit
193        tools/
194            @value{BINUTILS-UNTAR}/
195            @value{GCC-UNTAR}/
196            @value{NEWLIB-UNTAR}/
197            bit
198            bit_gdb
199            bit_rtems
200            common.sh
201            user.cfg
202@end group
203@end example
204
205
206@c @ifset use-html
207@c @html
208@c <IMG SRC="bit_c.jpg" WIDTH=816 HEIGHT=267 ALT="Directory Organization">
209@c @end html
210@c @end ifset
211
212@c
213@c  Host Specific Notes
214@c
215
216@section Host Specific Notes
217
218@subsection Solaris 2.x
219
220The build scripts are written in "shell".  The program @code{/bin/sh}
221on Solaris 2.x is not robust enough to execute these scripts.  If you
222are on a Solaris 2.x host, then change the first line of the files
223@code{bit}, @code{bit_gdb}, and @code{bit_rtems} to use the
224@code{/bin/ksh} shell instead.
225
226@subsection Linux
227
228@subsubsection Broken install Program
229
230Certain versions of GNU fileutils include a version of @code{install} which
231does not work properly.  Please perform the following test to see if you
232need to upgrade:
233
234@example
235install -c -d /tmp/foo/bar
236@end example
237
238If this does not create the specified directories your install
239program will not install RTEMS properly.   You will need to upgrade
240to at least GNU fileutile version 3.16 to resolve this problem.
241
242@c
243@c  Reading the Documentation
244@c
245
246@section Reading the Tools Documentation
247
248Each of the tools in the GNU development suite comes with documentation.
249It is in the reader's and tool maintainers' interest that one read the
250documentation before posting a problem to a mailing list or news group.
251Much of that documentation is available on-line.  The following is
252a list of URLs where can find HTML versions of the manuals.
253
254@table @b
255GCC Documentation
256http://gcc.gnu.org/onlinedocs
257
258Newlib Documentation
259Not currently online at http://sourceware.cygnus.com/newlib
260
261Binutils Documentation
262Not currently online at http://sourceware.cygnus.com/binutils
263@end table
264
265@c
266@c  GCC patches
267@c
268
269@section Apply RTEMS Patch to GCC
270
271@ifclear GCC-RTEMSPATCH
272No RTEMS specific patches are required for @value{GCC-VERSION} to
273support @value{RTEMS-VERSION}.
274@end ifclear
275
276@ifset GCC-RTEMSPATCH
277
278Apply the patch using the following command sequence:
279
280@example
281cd tools/@value{GCC-UNTAR}
282zcat ../../archive/@value{GCC-RTEMSPATCH} | patch -p1
283@end example
284
285Check to see if any of these patches have been rejected using the following
286sequence:
287
288@example
289cd tools/@value{GCC-UNTAR}
290find . -name "*.rej" -print
291@end example
292
293If any files are found with the .rej extension, a patch has been rejected.
294This should not happen with a good patch file which is properly applied.
295
296@end ifset
297
298@c
299@c  BINUTILS patches
300@c
301
302@section Apply RTEMS Patch to binutils
303
304@ifclear BINUTILS-RTEMSPATCH
305No RTEMS specific patches are required for @value{BINUTILS-VERSION} to
306support @value{RTEMS-VERSION}.
307@end ifclear
308
309@ifset BINUTILS-RTEMSPATCH
310Apply the patch using the following command sequence:
311
312@example
313cd tools/@value{BINUTILS-UNTAR}
314zcat ../../archive/@value{BINUTILS-RTEMSPATCH} | patch -p1
315@end example
316
317Check to see if any of these patches have been rejected using the following
318sequence:
319
320@example
321cd tools/@value{BINUTILS-UNTAR}
322find . -name "*.rej" -print
323@end example
324
325If any files are found with the .rej extension, a patch has been rejected.
326This should not happen with a good patch file which is properly applied.
327
328@end ifset
329
330@c
331@c  Newlib patches
332@c
333
334@section Apply RTEMS Patch to newlib
335
336@ifclear NEWLIB-RTEMSPATCH
337No RTEMS specific patches are required for @value{NEWLIB-VERSION} to
338support @value{RTEMS-VERSION}.
339@end ifclear
340
341@ifset NEWLIB-RTEMSPATCH
342
343Apply the patch using the following command sequence:
344
345@example
346cd tools/@value{NEWLIB-UNTAR}
347zcat ../../archive/@value{NEWLIB-RTEMSPATCH} | patch -p1
348@end example
349
350Check to see if any of these patches have been rejected using the following
351sequence:
352
353@example
354cd tools/@value{NEWLIB-UNTAR}
355find . -name "*.rej" -print
356@end example
357
358If any files are found with the .rej extension, a patch has been rejected.
359This should not happen with a good patch file which is properly applied.
360
361@end ifset
362
363@c
364@c  Localizing the Configuration
365@c
366
367@section Localizing the Configuration
368
369Edit the @code{user.cfg} file to alter the settings of various
370variables which are used to tailor the build process.
371Each of the variables set in @code{user.cfg} may be modified
372as described below:
373
374@table @code
375@item INSTALL_POINT
376is the location where you wish the GNU C/C++ cross compilation tools for
377RTEMS to be built. It is recommended that the directory chosen to receive
378these tools be named so that it is clear from which egcs distribution it
379was generated and for which target system the tools are to produce code for.
380
381@b{WARNING}: The @code{INSTALL_POINT} should not be a subdirectory
382under the build directory.  The build directory will be removed
383automatically upon successful completion of the build procedure.
384
385@item BINUTILS
386is the directory under tools that contains @value{BINUTILS-UNTAR}.
387For example:
388
389@example
390BINUTILS=@value{BINUTILS-UNTAR}
391@end example
392
393@item GCC
394is the directory under tools that contains @value{GCC-UNTAR}.
395For example,
396
397@example
398GCC=@value{GCC-UNTAR}
399@end example
400
401@item NEWLIB
402is the directory under tools that contains @value{NEWLIB-UNTAR}.
403For example:
404
405@example
406NEWLIB=@value{NEWLIB-UNTAR}
407@end example
408
409@item BUILD_DOCS
410is set to "yes" if you want to install documentation.  This requires
411that tools supporting documentation production be installed.  This
412currently is limited to the GNU texinfo package.
413For example:
414
415@example
416BUILD_DOCS=yes
417@end example
418
419@item BUILD_OTHER_LANGUAGES
420is set to "yes" if you want to build languages other than C and C++.  At
421the current time, the set of alternative languages includes Java, Fortran,
422and Objective-C.  These alternative languages do not always build cross.
423Hence this option defaults to "no".
424
425For example:
426
427@example
428BUILD_OTHER_LANGUAGES=yes
429@end example
430
431@b{NOTE:} Based upon the version of the compiler being used, it may not
432be possible to build languages other than C and C++ cross.  In many cases,
433the language run-time support libraries are not "multilib'ed".  Thus the
434executable code in these libraries will be for the default compiler settings
435and not necessarily be correct for your CPU model.
436
437@item RTEMS
438is the directory under tools that contails @value{RTEMS-UNTAR}.
439
440@item ENABLE_RTEMS_POSIX
441is set to "yes" if you want to enable the RTEMS POSIX API support.
442At this time, this feature is not supported by the UNIX ports of RTEMS
443and is forced to "no" for those targets.  This corresponds to the
444@code{configure} option @code{--enable-posix}.
445
446@item ENABLE_RTEMS_ITRON
447is set to "yes" if you want to enable the RTEMS ITRON API support.
448At this time, this feature is not supported by the UNIX ports of RTEMS
449and is forced to "no" for those targets.  This corresponds to the
450@code{configure} option @code{--enable-itron}.
451
452@item ENABLE_RTEMS_MP
453is set to "yes" if you want to enable the RTEMS multiprocessing
454support.  This feature is not supported by all RTEMS BSPs and
455is automatically forced to "no" for those BSPs.  This corresponds to the
456@code{configure} option @code{--enable-multiprocessing}.
457
458@item ENABLE_RTEMS_CXX
459is set to "yes" if you want to build the RTEMS C++ support including
460the C++ Wrapper for the Classic API.  This corresponds to the
461@code{configure} option @code{--enable-cxx}.
462
463@item ENABLE_RTEMS_TESTS
464is set to "yes" if you want to build the RTEMS Test Suite.  If this
465is set to "no", then only the Sample Tests will be built.  Setting
466this option to "yes" significantly increases the amount of disk
467space required to build RTEMS.
468This corresponds to the @code{configure} option @code{--enable-tests}.
469
470@item ENABLE_RTEMS_TCPIP
471is set to "yes" if you want to build the RTEMS TCP/IP Stack.  If a
472particular BSP does not support TCP/IP, then this feature is automatically
473disabled.  This corresponds to the @code{configure} option
474@code{--enable-tcpip}.
475
476@item ENABLE_RTEMS_NONDEBUG
477is set to "yes" if you want to build RTEMS in a fully optimized
478state.  This corresponds to executing @code{make} after configuring
479the source tree.
480
481@item ENABLE_RTEMS_DEBUG
482is set to "yes" if you want to build RTEMS in a debug version.
483When built for debug, RTEMS will include run-time code to
484perform consistency checks such as heap consistency checks.
485Although the precise compilation arguments are BSP dependent,
486the debug version of RTEMS is usually built at a lower optimization
487level.  This is usually done to reduce inlining which can make
488tracing code execution difficult.  This corresponds to executing
489@code{make VARIANT=debug} after configuring
490the source tree.
491
492@item INSTALL_RTEMS
493is set to "yes" if you want to install RTEMS after building it.
494This corresponds to executing @code{make install} after configuring
495and building the source tree.
496
497@item ENABLE_RTEMS_MAINTAINER_MODE
498is set to "yes" if you want to enabled maintainer mode functionality
499in the RTEMS Makefile.  This is disabled by default and it is not
500expected that most users will want to enable this.  When this option
501is enabled, the build process may attempt to regenerate files that
502require tools not required when this option is disabled.
503This corresponds to the @code{configure} option
504@code{--enable-maintainer-mode}.
505
506@end table
507
508@section Running the bit Script
509
510After the @code{bit} script has been modified to reflect the
511local installation, the modified @code{bit} script is run
512using the following sequence:
513
514@example
515cd tools
516./bit <target configuration>
517@end example
518
519Where <target configuration> is one of the following:
520
521@itemize @bullet
522@item hppa1.1
523@item i386
524@item i386-elf
525@item i386-go32
526@item i960
527@item m68k
528@item mips64orion
529@item powerpc
530@item sh
531@item sparc
532@end itemize
533
534The build process can take a while to complete.  Many users find it
535handy to run the build process in the background, capture the output
536in a file, and monitor the output.  This can be done as follows:
537
538@example
539./bit_ada <target configuration> >bit.log 2>&1 &
540tail -f bit.log
541@end example
542
543If no errors are encountered, the @code{bit} script will conclude by
544printing messages similar to the following:
545
546@example
547
548The build-i386-tools subdirectory may now be removed.
549
550Started:  Fri Apr 10 10:14:07 CDT 1998
551Finished: Fri Apr 10 12:01:33 CDT 1998
552@end example
553
554If the @code{bit} script successfully completes, then the
555GNU C/C++ cross compilation tools are installed.
556
557If the @code{bit} script does not successfully complete, then investigation
558will be required to determine the source of the error.
559
560@section Common Problems
561
562@subsection Error Message Indicates Invalid Option to Assembler
563
564If a message like this is printed then the new cross compiler
565is most likely using the native assembler instead of the cross
566assembler or vice-versa (native compiler using new cross assembler).
567This can occur for one of the following reasons:
568
569@itemize @bullet
570
571@item Binutils Patch Improperly Applied
572@item Binutils Not Built
573@item Current Directory is in Your PATH
574
575@end itemize
576
577If you are using binutils 2.9.1 or newer with certain versions of
578egcs and gcc, they do not agree on what the name of the newly
579generated cross assembler is.  Older binutils called it @code{as.new}
580which became @code{as.new.exe} under Windows.  This is not a valid
581file name, so @code{as.new} is now called @code{as-new}.  By using the latest
582released tool versions and RTEMS patches, this problem will be avoided.
583
584If binutils did not successfully build the cross assembler, then
585the new cross gcc (@code{xgcc}) used to build the libraries can not
586find it.  Make sure the build of the binutils succeeded.
587
588If you include the current directory in your PATH, then there
589is a chance that the native compiler will accidentally use
590the new cross assembler instead of the native one.  This usually
591indicates that "." is before the standard system directories
592in your PATH.  As a general rule, including "." in your PATH
593is a security risk and should be avoided.  Remove "." from
594your PATH.
595
596NOTE:  In some environments, it may be difficult remove "."
597completely from your PATH.  In this case, make sure that "."
598is after the system directories containing "as" and "ld".
599
600@subsection Error Messages Indicating Configuration Problems
601
602If you see error messages like the following,
603
604@itemize @bullet
605
606@item cannot configure libliberty
607@item coff-emulation not found
608@item etc.
609
610@end itemize
611
612Then it is likely that one or more of your gnu tools is
613already configured locally in its source tree.  You can check
614for this by searching for the @code{config.status} file
615in the various tool source trees.  The following command
616does this for the binutils source:
617
618@example
619find @value{BINUTILS-UNTAR} -name config.status -print
620@end example
621
622The solution for this is to execute the command
623@code{make distclean} in each of the GNU tools
624root source directory.  This should remove all
625generated files including Makefiles.
626
627This situation usually occurs when you have previously
628built the tool source for some non-RTEMS target.  The
629generated configuration specific files are still in
630the source tree and the include path specified during
631the RTEMS build accidentally picks up the previous
632configuration.  The include path used is something like
633this:
634
635@example
636-I../../@value{BINUTILS-UNTAR}/gcc -I/@value{BINUTILS-UNTAR}/gcc/include -I.
637@end example
638
639Note that the tool source directory is searched before the
640build directory.
641
642This situation can be avoided entirely by never using
643the source tree as the build directory -- even for
644native builds.
Note: See TracBrowser for help on using the repository browser.