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