Compilers and Variants and Architectures Oh My!

Lawrence Velázquez larryv at macports.org
Sun Mar 24 16:35:03 PDT 2013


On Mar 24, 2013, at 1:53 PM, Peter Johansson <rockets4kids at gmail.com> wrote:

> I am still running Snow Leopard but I upgraded to the latest XCode for
> SL, XCode 4.2.  This caused a bunch of problems which I eventually
> tracked down to a problem with the clang compiler shipped with XCode 4.2
> -- it does not properly respect CPATH causing a whole bunch of things to
> fail.

If these were problems with MacPorts or ports, please submit bug reports
so we can try fixing them.

http://guide.macports.org/chunked/project.html#project.tickets


> Although I have read the page "Using the Right Compiler" this page
> does not actually provide any insight as to which compiler should be
> used to build the MacPorts tree, particularly on older systems with
> rather outdated system compilers.

"Using the Right Compiler" is really a guide for portfile authors. Build
systems often try to choose compilers on their own, but we want to
ensure that MacPorts' chosen compiler is used instead.


> It seems as if MacPorts prefers clang, but by default it uses your
> system's default clang. While this is probably best if you are running
> the latest XCode, this is clearly not optimal if you are limited to an
> older version of XCode.

I assume you're talking about the compiler chosen to build ports.

MacPorts picks a compiler from a "fallback" list of compilers, chosen
based on Xcode version. Individual ports may specify a blacklist of
incompatible compilers that should *not* be used. They may also specify
a whitelist of compilers that *can* be used; this would override
MacPorts' fallback list entirely.

For instance, in the current release, the fallback list for Xcode 4.2
contains, in this order:

    - Clang from Xcode,
    - LLVM-GCC 4.2 from Xcode, and
    - Apple's custom GCC 4.2 from MacPorts' "apple-gcc42" port.

If a port does not compile correctly with Xcode's Clang, it can
blacklist it; then LLVM-GCC would be used instead. (Ideally this would
be fixed upstream at some point.)


> Would it indeed be wise to install clang 3.2 or 3.3

You can certainly install any compiler port and use it to build
individual ports. You can do this by setting configure.compiler on the
command line.

    sudo port install foo configure.compiler=macports-clang-3.2

The valid values for configure.compiler are listed in
UsingTheRightCompiler.


> If so, how does one set the default compiler in MacPorts?

MacPorts will read "default_compiler" from macports.conf, but this is
unsupported, and I really do not recommend using this. It should not be
necessary and would be suboptimal for us because it would mask build
issues with Xcode's compilers. We'd prefer to fix ports so that they
build correctly on as many OS X versions as possible, without any manual
compiler selection; if you encounter problems using a particular
compiler to build a particular port, please file a ticket.


> Furthermore, would it be wise to build a bootstrap install of MacPorts
> to obtain the desired compiler, and then use this to build the primary
> MacPorts install?

Are you talking about installing ports, or building MacPorts base?
Bootstrapping should not be necessary in either case.

vq


More information about the macports-users mailing list