• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2011.09/share/doc/arm-arm-none-eabi/html/gcc/
1<html lang="en">
2<head>
3<title>Interoperation - Using the GNU Compiler Collection (GCC)</title>
4<meta http-equiv="Content-Type" content="text/html">
5<meta name="description" content="Using the GNU Compiler Collection (GCC)">
6<meta name="generator" content="makeinfo 4.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="up" href="Trouble.html#Trouble" title="Trouble">
9<link rel="prev" href="Cross_002dCompiler-Problems.html#Cross_002dCompiler-Problems" title="Cross-Compiler Problems">
10<link rel="next" href="Incompatibilities.html#Incompatibilities" title="Incompatibilities">
11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12<!--
13Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
141998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
152010 Free Software Foundation, Inc.
16
17Permission is granted to copy, distribute and/or modify this document
18under the terms of the GNU Free Documentation License, Version 1.3 or
19any later version published by the Free Software Foundation; with the
20Invariant Sections being ``Funding Free Software'', the Front-Cover
21Texts being (a) (see below), and with the Back-Cover Texts being (b)
22(see below).  A copy of the license is included in the section entitled
23``GNU Free Documentation License''.
24
25(a) The FSF's Front-Cover Text is:
26
27     A GNU Manual
28
29(b) The FSF's Back-Cover Text is:
30
31     You have freedom to copy and modify this GNU Manual, like GNU
32     software.  Copies published by the Free Software Foundation raise
33     funds for GNU development.-->
34<meta http-equiv="Content-Style-Type" content="text/css">
35<style type="text/css"><!--
36  pre.display { font-family:inherit }
37  pre.format  { font-family:inherit }
38  pre.smalldisplay { font-family:inherit; font-size:smaller }
39  pre.smallformat  { font-family:inherit; font-size:smaller }
40  pre.smallexample { font-size:smaller }
41  pre.smalllisp    { font-size:smaller }
42  span.sc    { font-variant:small-caps }
43  span.roman { font-family:serif; font-weight:normal; } 
44  span.sansserif { font-family:sans-serif; font-weight:normal; } 
45--></style>
46<link rel="stylesheet" type="text/css" href="../cs.css">
47</head>
48<body>
49<div class="node">
50<a name="Interoperation"></a>
51<p>
52Next:&nbsp;<a rel="next" accesskey="n" href="Incompatibilities.html#Incompatibilities">Incompatibilities</a>,
53Previous:&nbsp;<a rel="previous" accesskey="p" href="Cross_002dCompiler-Problems.html#Cross_002dCompiler-Problems">Cross-Compiler Problems</a>,
54Up:&nbsp;<a rel="up" accesskey="u" href="Trouble.html#Trouble">Trouble</a>
55<hr>
56</div>
57
58<h3 class="section">11.3 Interoperation</h3>
59
60<p>This section lists various difficulties encountered in using GCC
61together with other compilers or with the assemblers, linkers,
62libraries and debuggers on certain systems.
63
64     <ul>
65<li>On many platforms, GCC supports a different ABI for C++ than do other
66compilers, so the object files compiled by GCC cannot be used with object
67files generated by another C++ compiler.
68
69     <p>An area where the difference is most apparent is name mangling.  The use
70of different name mangling is intentional, to protect you from more subtle
71problems. 
72Compilers differ as to many internal details of C++ implementation,
73including: how class instances are laid out, how multiple inheritance is
74implemented, and how virtual function calls are handled.  If the name
75encoding were made the same, your programs would link against libraries
76provided from other compilers&mdash;but the programs would then crash when
77run.  Incompatible libraries are then detected at link time, rather than
78at run time.
79
80     <li>On some BSD systems, including some versions of Ultrix, use of profiling
81causes static variable destructors (currently used only in C++) not to
82be run.
83
84     <li>On some SGI systems, when you use <samp><span class="option">-lgl_s</span></samp> as an option,
85it gets translated magically to &lsquo;<samp><span class="samp">-lgl_s -lX11_s -lc_s</span></samp>&rsquo;. 
86Naturally, this does not happen when you use GCC. 
87You must specify all three options explicitly.
88
89     <li>On a SPARC, GCC aligns all values of type <code>double</code> on an 8-byte
90boundary, and it expects every <code>double</code> to be so aligned.  The Sun
91compiler usually gives <code>double</code> values 8-byte alignment, with one
92exception: function arguments of type <code>double</code> may not be aligned.
93
94     <p>As a result, if a function compiled with Sun CC takes the address of an
95argument of type <code>double</code> and passes this pointer of type
96<code>double *</code> to a function compiled with GCC, dereferencing the
97pointer may cause a fatal signal.
98
99     <p>One way to solve this problem is to compile your entire program with GCC. 
100Another solution is to modify the function that is compiled with
101Sun CC to copy the argument into a local variable; local variables
102are always properly aligned.  A third solution is to modify the function
103that uses the pointer to dereference it via the following function
104<code>access_double</code> instead of directly with &lsquo;<samp><span class="samp">*</span></samp>&rsquo;:
105
106     <pre class="smallexample">          inline double
107          access_double (double *unaligned_ptr)
108          {
109            union d2i { double d; int i[2]; };
110          
111            union d2i *p = (union d2i *) unaligned_ptr;
112            union d2i u;
113          
114            u.i[0] = p-&gt;i[0];
115            u.i[1] = p-&gt;i[1];
116          
117            return u.d;
118          }
119</pre>
120     <p class="noindent">Storing into the pointer can be done likewise with the same union.
121
122     <li>On Solaris, the <code>malloc</code> function in the <samp><span class="file">libmalloc.a</span></samp> library
123may allocate memory that is only 4 byte aligned.  Since GCC on the
124SPARC assumes that doubles are 8 byte aligned, this may result in a
125fatal signal if doubles are stored in memory allocated by the
126<samp><span class="file">libmalloc.a</span></samp> library.
127
128     <p>The solution is to not use the <samp><span class="file">libmalloc.a</span></samp> library.  Use instead
129<code>malloc</code> and related functions from <samp><span class="file">libc.a</span></samp>; they do not have
130this problem.
131
132     <li>On the HP PA machine, ADB sometimes fails to work on functions compiled
133with GCC.  Specifically, it fails to work on functions that use
134<code>alloca</code> or variable-size arrays.  This is because GCC doesn't
135generate HP-UX unwind descriptors for such functions.  It may even be
136impossible to generate them.
137
138     <li>Debugging (<samp><span class="option">-g</span></samp>) is not supported on the HP PA machine, unless you use
139the preliminary GNU tools.
140
141     <li>Taking the address of a label may generate errors from the HP-UX
142PA assembler.  GAS for the PA does not have this problem.
143
144     <li>Using floating point parameters for indirect calls to static functions
145will not work when using the HP assembler.  There simply is no way for GCC
146to specify what registers hold arguments for static functions when using
147the HP assembler.  GAS for the PA does not have this problem.
148
149     <li>In extremely rare cases involving some very large functions you may
150receive errors from the HP linker complaining about an out of bounds
151unconditional branch offset.  This used to occur more often in previous
152versions of GCC, but is now exceptionally rare.  If you should run
153into it, you can work around by making your function smaller.
154
155     <li>GCC compiled code sometimes emits warnings from the HP-UX assembler of
156the form:
157
158     <pre class="smallexample">          (warning) Use of GR3 when
159            frame &gt;= 8192 may cause conflict.
160</pre>
161     <p>These warnings are harmless and can be safely ignored.
162
163     <li>In extremely rare cases involving some very large functions you may
164receive errors from the AIX Assembler complaining about a displacement
165that is too large.  If you should run into it, you can work around by
166making your function smaller.
167
168     <li>The <samp><span class="file">libstdc++.a</span></samp> library in GCC relies on the SVR4 dynamic
169linker semantics which merges global symbols between libraries and
170applications, especially necessary for C++ streams functionality. 
171This is not the default behavior of AIX shared libraries and dynamic
172linking.  <samp><span class="file">libstdc++.a</span></samp> is built on AIX with &ldquo;runtime-linking&rdquo;
173enabled so that symbol merging can occur.  To utilize this feature,
174the application linked with <samp><span class="file">libstdc++.a</span></samp> must include the
175<samp><span class="option">-Wl,-brtl</span></samp> flag on the link line.  G++ cannot impose this
176because this option may interfere with the semantics of the user
177program and users may not always use &lsquo;<samp><span class="samp">g++</span></samp>&rsquo; to link his or her
178application.  Applications are not required to use the
179<samp><span class="option">-Wl,-brtl</span></samp> flag on the link line&mdash;the rest of the
180<samp><span class="file">libstdc++.a</span></samp> library which is not dependent on the symbol
181merging semantics will continue to function correctly.
182
183     <li>An application can interpose its own definition of functions for
184functions invoked by <samp><span class="file">libstdc++.a</span></samp> with &ldquo;runtime-linking&rdquo;
185enabled on AIX.  To accomplish this the application must be linked
186with &ldquo;runtime-linking&rdquo; option and the functions explicitly must be
187exported by the application (<samp><span class="option">-Wl,-brtl,-bE:exportfile</span></samp>).
188
189     <li>AIX on the RS/6000 provides support (NLS) for environments outside of
190the United States.  Compilers and assemblers use NLS to support
191locale-specific representations of various objects including
192floating-point numbers (&lsquo;<samp><span class="samp">.</span></samp>&rsquo; vs &lsquo;<samp><span class="samp">,</span></samp>&rsquo; for separating decimal
193fractions).  There have been problems reported where the library linked
194with GCC does not produce the same floating-point formats that the
195assembler accepts.  If you have this problem, set the <samp><span class="env">LANG</span></samp>
196environment variable to &lsquo;<samp><span class="samp">C</span></samp>&rsquo; or &lsquo;<samp><span class="samp">En_US</span></samp>&rsquo;.
197
198     <li><a name="index-fdollars_002din_002didentifiers-3295"></a>Even if you specify <samp><span class="option">-fdollars-in-identifiers</span></samp>,
199you cannot successfully use &lsquo;<samp><span class="samp">$</span></samp>&rsquo; in identifiers on the RS/6000 due
200to a restriction in the IBM assembler.  GAS supports these
201identifiers.
202
203 </ul>
204
205 </body></html>
206
207