You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
199 lines
9.9 KiB
HTML
199 lines
9.9 KiB
HTML
4 years ago
|
<html lang="en">
|
||
|
<head>
|
||
|
<title>Interoperation - 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.13">
|
||
|
<link title="Top" rel="start" href="index.html#Top">
|
||
|
<link rel="up" href="Trouble.html#Trouble" title="Trouble">
|
||
|
<link rel="prev" href="Actual-Bugs.html#Actual-Bugs" title="Actual Bugs">
|
||
|
<link rel="next" href="Incompatibilities.html#Incompatibilities" title="Incompatibilities">
|
||
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
||
|
<!--
|
||
|
Copyright (C) 1988-2015 Free Software Foundation, Inc.
|
||
|
|
||
|
Permission is granted to copy, distribute and/or modify this document
|
||
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||
|
any later version published by the Free Software Foundation; with the
|
||
|
Invariant Sections being ``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''.
|
||
|
|
||
|
(a) The FSF's Front-Cover Text is:
|
||
|
|
||
|
A GNU Manual
|
||
|
|
||
|
(b) The FSF's Back-Cover Text is:
|
||
|
|
||
|
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.-->
|
||
|
<meta http-equiv="Content-Style-Type" content="text/css">
|
||
|
<style type="text/css"><!--
|
||
|
pre.display { font-family:inherit }
|
||
|
pre.format { font-family:inherit }
|
||
|
pre.smalldisplay { font-family:inherit; font-size:smaller }
|
||
|
pre.smallformat { font-family:inherit; font-size:smaller }
|
||
|
pre.smallexample { font-size:smaller }
|
||
|
pre.smalllisp { font-size:smaller }
|
||
|
span.sc { font-variant:small-caps }
|
||
|
span.roman { font-family:serif; font-weight:normal; }
|
||
|
span.sansserif { font-family:sans-serif; font-weight:normal; }
|
||
|
--></style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="node">
|
||
|
<a name="Interoperation"></a>
|
||
|
<p>
|
||
|
Next: <a rel="next" accesskey="n" href="Incompatibilities.html#Incompatibilities">Incompatibilities</a>,
|
||
|
Previous: <a rel="previous" accesskey="p" href="Actual-Bugs.html#Actual-Bugs">Actual Bugs</a>,
|
||
|
Up: <a rel="up" accesskey="u" href="Trouble.html#Trouble">Trouble</a>
|
||
|
<hr>
|
||
|
</div>
|
||
|
|
||
|
<h3 class="section">12.2 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.
|
||
|
|
||
|
<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 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 ‘<samp><span class="samp">*</span></samp>’:
|
||
|
|
||
|
<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->i[0];
|
||
|
u.i[1] = p->i[1];
|
||
|
|
||
|
return u.d;
|
||
|
}
|
||
|
</pre>
|
||
|
<p class="noindent">Storing into the pointer can be done likewise with the same union.
|
||
|
|
||
|
<li>On Solaris, the <code>malloc</code> function in the <samp><span class="file">libmalloc.a</span></samp> 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
|
||
|
<samp><span class="file">libmalloc.a</span></samp> library.
|
||
|
|
||
|
<p>The solution is to not use the <samp><span class="file">libmalloc.a</span></samp> library. Use instead
|
||
|
<code>malloc</code> and related functions from <samp><span class="file">libc.a</span></samp>; they do not have
|
||
|
this problem.
|
||
|
|
||
|
<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 (<samp><span class="option">-g</span></samp>) 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 >= 8192 may cause conflict.
|
||
|
</pre>
|
||
|
<p>These warnings are harmless and can be safely ignored.
|
||
|
|
||
|
<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 <samp><span class="file">libstdc++.a</span></samp> 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. <samp><span class="file">libstdc++.a</span></samp> is built on AIX with “runtime-linking”
|
||
|
enabled so that symbol merging can occur. To utilize this feature,
|
||
|
the application linked with <samp><span class="file">libstdc++.a</span></samp> must include the
|
||
|
<samp><span class="option">-Wl,-brtl</span></samp> 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 ‘<samp><span class="samp">g++</span></samp>’ to link his or her
|
||
|
application. Applications are not required to use the
|
||
|
<samp><span class="option">-Wl,-brtl</span></samp> flag on the link line—the rest of the
|
||
|
<samp><span class="file">libstdc++.a</span></samp> 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 <samp><span class="file">libstdc++.a</span></samp> 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 (<samp><span class="option">-Wl,-brtl,-bE:exportfile</span></samp>).
|
||
|
|
||
|
<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 (‘<samp><span class="samp">.</span></samp>’ vs ‘<samp><span class="samp">,</span></samp>’ 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 <samp><span class="env">LANG</span></samp>
|
||
|
environment variable to ‘<samp><span class="samp">C</span></samp>’ or ‘<samp><span class="samp">En_US</span></samp>’.
|
||
|
|
||
|
<li><a name="index-fdollars_002din_002didentifiers-4244"></a>Even if you specify <samp><span class="option">-fdollars-in-identifiers</span></samp>,
|
||
|
you cannot successfully use ‘<samp><span class="samp">$</span></samp>’ in identifiers on the RS/6000 due
|
||
|
to a restriction in the IBM assembler. GAS supports these
|
||
|
identifiers.
|
||
|
|
||
|
</ul>
|
||
|
|
||
|
</body></html>
|
||
|
|