--On November 16, 2011 10:41:15 PM -0600 Ryan Schmidt <ryandes...@macports.org> wrote:

Is it only Apple gcc that's a problem? If so, does that mean the
problem is already resolved when using Xcode 4 on Lion and Snow
Leopard, where the default compiler is not gcc, but Apple llvm-gcc or
Apple clang (depending on Xcode version)?

Is Apple clang vs. plain clang also a problem?

The reason many ports depend on a gcc port is not because they need a
newer C or C++ compiler, but because they need a Fortran compiler,
which Apple doesn't provide at all. Many of these ports still happen
to switch to using the C and C++ compiler corresponding to that
Fortran compiler they need, because it's easy to do so (a single
configure.compiler directive to switch the entire compiler
collection). I don't know if we can mix and match fsf gcc Fortran
compiler plus system C and C++ compiler; if we can, would that solve
the problem? Or would code generated with Fortran also be vulnerable?


Mixing C++ compilers and hence run time libraries can lead to problems. Mixing C compilers is often ok, but C++ is a more complex language and different compilers have different ideas about object construction and destruction, VTable format, and other things that affect the generated code. In a previous lifetime where I wrote lots of C++ code, I sometimes had to worry about problems like this. You have to be careful that objects don't leak out of one library (compiled with compiler X) into another library (compiled with compiler Y). I suspect this isn't a problem with most libraries in MacPorts since the APIs have been designed to avoid problems like this, but it could happen. As long as any object created by a given library is treated as an opaque pointer outside that library, you're probably ok.

Mixing compilers inside one port is more likely to cause problems. I think that if a port needs a Fortran compiler it should use the corresponding C and C++ compilers.

--
Mike Alexander           m...@umich.edu
Ann Arbor, MI            PGP key ID: BEA343A6

_______________________________________________
macports-users mailing list
macports-users@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macports-users

Reply via email to