Interoperation.html 11 KB

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