您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

234 行
11KB

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