gcc: Interoperation
1
1 13.2 Interoperation
1 ===================
1
1 This section lists various difficulties encountered in using GCC
1 together with other compilers or with the assemblers, linkers, libraries
1 and debuggers on certain systems.
1
1 * On many platforms, GCC supports a different ABI for C++ than do
1 other compilers, so the object files compiled by GCC cannot be used
1 with object files generated by another C++ compiler.
1
1 An area where the difference is most apparent is name mangling.
1 The use of different name mangling is intentional, to protect you
1 from more subtle problems. Compilers differ as to many internal
1 details of C++ implementation, including: how class instances are
1 laid out, how multiple inheritance is implemented, and how virtual
1 function calls are handled. If the name encoding were made the
1 same, your programs would link against libraries provided from
1 other compilers--but the programs would then crash when run.
1 Incompatible libraries are then detected at link time, rather than
1 at run time.
1
1 * On some BSD systems, including some versions of Ultrix, use of
1 profiling causes static variable destructors (currently used only
1 in C++) not to be run.
1
1 * On a SPARC, GCC aligns all values of type 'double' on an 8-byte
1 boundary, and it expects every 'double' to be so aligned. The Sun
1 compiler usually gives 'double' values 8-byte alignment, with one
1 exception: function arguments of type 'double' may not be aligned.
1
1 As a result, if a function compiled with Sun CC takes the address
1 of an argument of type 'double' and passes this pointer of type
1 'double *' to a function compiled with GCC, dereferencing the
1 pointer may cause a fatal signal.
1
1 One way to solve this problem is to compile your entire program
1 with GCC. Another solution is to modify the function that is
1 compiled with Sun CC to copy the argument into a local variable;
1 local variables are always properly aligned. A third solution is
1 to modify the function that uses the pointer to dereference it via
1 the following function 'access_double' instead of directly with
1 '*':
1
1 inline double
1 access_double (double *unaligned_ptr)
1 {
1 union d2i { double d; int i[2]; };
1
1 union d2i *p = (union d2i *) unaligned_ptr;
1 union d2i u;
1
1 u.i[0] = p->i[0];
1 u.i[1] = p->i[1];
1
1 return u.d;
1 }
1
1 Storing into the pointer can be done likewise with the same union.
1
1 * On Solaris, the 'malloc' function in the 'libmalloc.a' library may
1 allocate memory that is only 4 byte aligned. Since GCC on the
1 SPARC assumes that doubles are 8 byte aligned, this may result in a
1 fatal signal if doubles are stored in memory allocated by the
1 'libmalloc.a' library.
1
1 The solution is to not use the 'libmalloc.a' library. Use instead
1 'malloc' and related functions from 'libc.a'; they do not have this
1 problem.
1
1 * On the HP PA machine, ADB sometimes fails to work on functions
1 compiled with GCC. Specifically, it fails to work on functions
1 that use 'alloca' or variable-size arrays. This is because GCC
1 doesn't generate HP-UX unwind descriptors for such functions. It
1 may even be impossible to generate them.
1
1 * Debugging ('-g') is not supported on the HP PA machine, unless you
1 use the preliminary GNU tools.
1
1 * Taking the address of a label may generate errors from the HP-UX PA
1 assembler. GAS for the PA does not have this problem.
1
1 * Using floating point parameters for indirect calls to static
1 functions will not work when using the HP assembler. There simply
1 is no way for GCC to specify what registers hold arguments for
1 static functions when using the HP assembler. GAS for the PA does
1 not have this problem.
1
1 * In extremely rare cases involving some very large functions you may
1 receive errors from the HP linker complaining about an out of
1 bounds unconditional branch offset. This used to occur more often
1 in previous versions of GCC, but is now exceptionally rare. If you
1 should run into it, you can work around by making your function
1 smaller.
1
1 * GCC compiled code sometimes emits warnings from the HP-UX assembler
1 of the form:
1
1 (warning) Use of GR3 when
1 frame >= 8192 may cause conflict.
1
1 These warnings are harmless and can be safely ignored.
1
1 * In extremely rare cases involving some very large functions you may
1 receive errors from the AIX Assembler complaining about a
1 displacement that is too large. If you should run into it, you can
1 work around by making your function smaller.
1
1 * The 'libstdc++.a' library in GCC relies on the SVR4 dynamic linker
1 semantics which merges global symbols between libraries and
1 applications, especially necessary for C++ streams functionality.
1 This is not the default behavior of AIX shared libraries and
1 dynamic linking. 'libstdc++.a' is built on AIX with
1 "runtime-linking" enabled so that symbol merging can occur. To
1 utilize this feature, the application linked with 'libstdc++.a'
1 must include the '-Wl,-brtl' flag on the link line. G++ cannot
1 impose this because this option may interfere with the semantics of
1 the user program and users may not always use 'g++' to link his or
1 her application. Applications are not required to use the
1 '-Wl,-brtl' flag on the link line--the rest of the 'libstdc++.a'
1 library which is not dependent on the symbol merging semantics will
1 continue to function correctly.
1
1 * An application can interpose its own definition of functions for
1 functions invoked by 'libstdc++.a' with "runtime-linking" enabled
1 on AIX. To accomplish this the application must be linked with
1 "runtime-linking" option and the functions explicitly must be
1 exported by the application ('-Wl,-brtl,-bE:exportfile').
1
1 * AIX on the RS/6000 provides support (NLS) for environments outside
1 of the United States. Compilers and assemblers use NLS to support
1 locale-specific representations of various objects including
1 floating-point numbers ('.' vs ',' for separating decimal
1 fractions). There have been problems reported where the library
1 linked with GCC does not produce the same floating-point formats
1 that the assembler accepts. If you have this problem, set the
1 'LANG' environment variable to 'C' or 'En_US'.
1
1 * Even if you specify '-fdollars-in-identifiers', you cannot
1 successfully use '$' in identifiers on the RS/6000 due to a
1 restriction in the IBM assembler. GAS supports these identifiers.
1