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