⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interoperation.html

📁 gcc手册
💻 HTML
字号:
<html lang="en">

<head>

<title>Using the GNU Compiler Collection (GCC)</title>

<meta http-equiv="Content-Type" content="text/html">

<meta name="description" content="Using the GNU Compiler Collection (GCC)">

<meta name="generator" content="makeinfo 4.3">

<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">

<!--

Copyright &copy; 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,

1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.



   <p>Permission is granted to copy, distribute and/or modify this document

under the terms of the GNU Free Documentation License, Version 1.2 or

any later version published by the Free Software Foundation; with the

Invariant Sections being "GNU General Public License" and "Funding

Free Software", the Front-Cover texts being (a) (see below), and with

the Back-Cover Texts being (b) (see below).  A copy of the license is

included in the section entitled "GNU Free Documentation License".



   <p>(a) The FSF's Front-Cover Text is:



   <p>A GNU Manual



   <p>(b) The FSF's Back-Cover Text is:



   <p>You have freedom to copy and modify this GNU Manual, like GNU

     software.  Copies published by the Free Software Foundation raise

     funds for GNU development.-->

</head>

<body>

<div class="node">

<p>

Node:<a name="Interoperation">Interoperation</a>,

Next:<a rel="next" accesskey="n" href="External-Bugs.html#External%20Bugs">External Bugs</a>,

Previous:<a rel="previous" accesskey="p" href="Cross-Compiler-Problems.html#Cross-Compiler%20Problems">Cross-Compiler Problems</a>,

Up:<a rel="up" accesskey="u" href="Trouble.html#Trouble">Trouble</a>

<hr><br>

</div>



<h3 class="section">Interoperation</h3>



   <p>This section lists various difficulties encountered in using GCC

together with other compilers or with the assemblers, linkers,

libraries and debuggers on certain systems.



     <ul>

<li>On many platforms, GCC supports a different ABI for C++ than do other

compilers, so the object files compiled by GCC cannot be used with object

files generated by another C++ compiler.



     <p>An area where the difference is most apparent is name mangling.  The use

of different name mangling is intentional, to protect you from more subtle

problems. 

Compilers differ as to many internal details of C++ implementation,

including: how class instances are laid out, how multiple inheritance is

implemented, and how virtual function calls are handled.  If the name

encoding were made the same, your programs would link against libraries

provided from other compilers--but the programs would then crash when

run.  Incompatible libraries are then detected at link time, rather than

at run time.



     </p><li>Older GDB versions sometimes fail to read the output of GCC version

2.  If you have trouble, get GDB version 4.4 or later.



     <li>DBX rejects some files produced by GCC, though it accepts similar

constructs in output from PCC.  Until someone can supply a coherent

description of what is valid DBX input and what is not, there is

nothing I can do about these problems.  You are on your own.



     <li>The GNU assembler (GAS) does not support PIC.  To generate PIC code, you

must use some other assembler, such as <code>/bin/as</code>.



     <li>On some BSD systems, including some versions of Ultrix, use of profiling

causes static variable destructors (currently used only in C++) not to

be run.



     <li>On some SGI systems, when you use <code>-lgl_s</code> as an option,

it gets translated magically to <code>-lgl_s -lX11_s -lc_s</code>. 

Naturally, this does not happen when you use GCC. 

You must specify all three options explicitly.



     <li>On a SPARC, GCC aligns all values of type <code>double</code> on an 8-byte

boundary, and it expects every <code>double</code> to be so aligned.  The Sun

compiler usually gives <code>double</code> values 8-byte alignment, with one

exception: function arguments of type <code>double</code> may not be aligned.



     <p>As a result, if a function compiled with Sun CC takes the address of an

argument of type <code>double</code> and passes this pointer of type

<code>double *</code> to a function compiled with GCC, dereferencing the

pointer may cause a fatal signal.



     <p>One way to solve this problem is to compile your entire program with GCC. 

Another solution is to modify the function that is compiled with

Sun CC to copy the argument into a local variable; local variables

are always properly aligned.  A third solution is to modify the function

that uses the pointer to dereference it via the following function

<code>access_double</code> instead of directly with <code>*</code>:



     <pre class="smallexample">          inline double

          access_double (double *unaligned_ptr)

          {

            union d2i { double d; int i[2]; };

          

            union d2i *p = (union d2i *) unaligned_ptr;

            union d2i u;

          

            u.i[0] = p-&gt;i[0];

            u.i[1] = p-&gt;i[1];

          

            return u.d;

          }

          </pre>



     <p>Storing into the pointer can be done likewise with the same union.



     </p><li>On Solaris, the <code>malloc</code> function in the <code>libmalloc.a</code> library

may allocate memory that is only 4 byte aligned.  Since GCC on the

SPARC assumes that doubles are 8 byte aligned, this may result in a

fatal signal if doubles are stored in memory allocated by the

<code>libmalloc.a</code> library.



     <p>The solution is to not use the <code>libmalloc.a</code> library.  Use instead

<code>malloc</code> and related functions from <code>libc.a</code>; they do not have

this problem.



     </p><li>Sun forgot to include a static version of <code>libdl.a</code> with some

versions of SunOS (mainly 4.1).  This results in undefined symbols when

linking static binaries (that is, if you use <code>-static</code>).  If you

see undefined symbols <code>_dlclose</code>, <code>_dlsym</code> or <code>_dlopen</code>

when linking, compile and link against the file

<code>mit/util/misc/dlsym.c</code> from the MIT version of X windows.



     <li>The 128-bit long double format that the SPARC port supports currently

works by using the architecturally defined quad-word floating point

instructions.  Since there is no hardware that supports these

instructions they must be emulated by the operating system.  Long

doubles do not work in Sun OS versions 4.0.3 and earlier, because the

kernel emulator uses an obsolete and incompatible format.  Long doubles

do not work in Sun OS version 4.1.1 due to a problem in a Sun library. 

Long doubles do work on Sun OS versions 4.1.2 and higher, but GCC

does not enable them by default.  Long doubles appear to work in Sun OS

5.x (Solaris 2.x).



     <li>On HP-UX version 9.01 on the HP PA, the HP compiler <code>cc</code> does not

compile GCC correctly.  We do not yet know why.  However, GCC

compiled on earlier HP-UX versions works properly on HP-UX 9.01 and can

compile itself properly on 9.01.



     <li>On the HP PA machine, ADB sometimes fails to work on functions compiled

with GCC.  Specifically, it fails to work on functions that use

<code>alloca</code> or variable-size arrays.  This is because GCC doesn't

generate HP-UX unwind descriptors for such functions.  It may even be

impossible to generate them.



     <li>Debugging (<code>-g</code>) is not supported on the HP PA machine, unless you use

the preliminary GNU tools.



     <li>Taking the address of a label may generate errors from the HP-UX

PA assembler.  GAS for the PA does not have this problem.



     <li>Using floating point parameters for indirect calls to static functions

will not work when using the HP assembler.  There simply is no way for GCC

to specify what registers hold arguments for static functions when using

the HP assembler.  GAS for the PA does not have this problem.



     <li>In extremely rare cases involving some very large functions you may

receive errors from the HP linker complaining about an out of bounds

unconditional branch offset.  This used to occur more often in previous

versions of GCC, but is now exceptionally rare.  If you should run

into it, you can work around by making your function smaller.



     <li>GCC compiled code sometimes emits warnings from the HP-UX assembler of

the form:



     <pre class="smallexample">          (warning) Use of GR3 when

            frame &gt;= 8192 may cause conflict.

          </pre>



     <p>These warnings are harmless and can be safely ignored.



     </p><li>On the IBM RS/6000, compiling code of the form



     <pre class="smallexample">          extern int foo;

          

          ... foo ...

          

          static int foo;

          </pre>



     <p>will cause the linker to report an undefined symbol <code>foo</code>. 

Although this behavior differs from most other systems, it is not a

bug because redefining an <code>extern</code> variable as <code>static</code>

is undefined in ISO C.



     </p><li>In extremely rare cases involving some very large functions you may

receive errors from the AIX Assembler complaining about a displacement

that is too large.  If you should run into it, you can work around by

making your function smaller.



     <li>The <code>libstdc++.a</code> library in GCC relies on the SVR4 dynamic

linker semantics which merges global symbols between libraries and

applications, especially necessary for C++ streams functionality. 

This is not the default behavior of AIX shared libraries and dynamic

linking.  <code>libstdc++.a</code> is built on AIX with "runtime-linking"

enabled so that symbol merging can occur.  To utilize this feature,

the application linked with <code>libstdc++.a</code> must include the

<code>-Wl,-brtl</code> flag on the link line.  G++ cannot impose this

because this option may interfere with the semantics of the user

program and users may not always use <code>g++</code> to link his or her

application. Applications are not required to use the

<code>-Wl,-brtl</code> flag on the link line--the rest of the

<code>libstdc++.a</code> library which is not dependent on the symbol

merging semantics will continue to function correctly.



     <li>An application can interpose its own definition of functions for

functions invoked by <code>libstdc++.a</code> with "runtime-linking"

enabled on AIX.  To accomplish this the application must be linked

with "runtime-linking" option and the functions explicitly must be

exported by the application (<code>-Wl,-brtl,-bE:exportfile</code>).



     <li>AIX on the RS/6000 provides support (NLS) for environments outside of

the United States.  Compilers and assemblers use NLS to support

locale-specific representations of various objects including

floating-point numbers (<code>.</code> vs <code>,</code> for separating decimal

fractions). There have been problems reported where the library linked

with GCC does not produce the same floating-point formats that the

assembler accepts. If you have this problem, set the <code>LANG</code>

environment variable to <code>C</code> or <code>En_US</code>.



     <li>Even if you specify <code>-fdollars-in-identifiers</code>,

you cannot successfully use <code>$</code> in identifiers on the RS/6000 due

to a restriction in the IBM assembler.  GAS supports these

identifiers.



     <li>On Ultrix, the Fortran compiler expects registers 2 through 5 to be saved

by function calls.  However, the C compiler uses conventions compatible

with BSD Unix: registers 2 through 5 may be clobbered by function calls.



     <p>GCC uses the same convention as the Ultrix C compiler.  You can use

these options to produce code compatible with the Fortran compiler:



     <pre class="smallexample">          -fcall-saved-r2 -fcall-saved-r3 -fcall-saved-r4 -fcall-saved-r5

          </pre>



     </p><li>On the Alpha, you may get assembler errors about invalid syntax as a

result of floating point constants.  This is due to a bug in the C

library functions <code>ecvt</code>, <code>fcvt</code> and <code>gcvt</code>.  Given valid

floating point numbers, they sometimes print <code>NaN</code>. 

</ul>



   </body></html>



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -