compilers on Lion

Mojca Miklavec mojca.miklavec.lists at
Tue Sep 11 20:46:26 UTC 2018

Dear Werner,

If you try to avoid the troubles of installing a zillion compilers for
the sake of installing poppler, what about switching to a super
lightweight pplib (currently available only inside LuaTeX sources)? :)
:) :)

On Sat, 8 Sep 2018 at 17:46, Werner LEMBERG wrote:
> > What exactly did you do to set it as the ‘default’ gcc compiler ?
> > port select ?
> Yep.
> > This setting has no bearing on what ports use to build, its only
> > there as a convenience for you, to define what you get as ‘gcc’ at
> > the command line.
> OK, thanks.

You can manually specify the compiler being used to compile a particular port.

You could have in theory used something like
    sudo port install poppler configure.compiler=macports-gcc-8
but this would be a super bad idea in itself as then poppler would
link against stdlibc++ and everything would break.

You could have also used
    sudo port install clang-5.0 configure.compiler=macports-gcc-8
even though I'm almost sure that this would fail. I never tried
though. The "configure.compiler" flag is mostly used for debugging
purposes. It would be basically impossible to help users after they
use this a couple of times in a wrong way.

> > Also note that the gcc compilers do not use libc++ as their c++
> > runtime, but gcc default libstdc++.  Mixing both runtimes is a very
> > bad idea, so in fact using gcc is a bad choice.  No ports in
> > MacPorts will use it to build C++ sources.
> OK.  BTW, I see on
> that gcc on MacOS actually *can* use libc++...

This means that someone would need to spend a bit of time to try to
get it working correctly.

> >> * Saying
> >>
> >>    port install poppler
> >>
> >>  returns
> >>
> >>    --->  Computing dependencies for poppler
> >>    The following dependencies will be installed:
> >>     clang-3.7
> >>     clang-3.9
> >>     clang-4.0
> >>     clang-5.0
> >>     libomp
> >>     llvm-3.7
> >>     llvm-3.9
> >>     llvm-4.0
> >>     llvm-5.0    .
> >>
> >>  For me, this looks like a bad joke!  *Four* compilers are necessary
> >>  for poppler?
> >
> > No. Only one is needed for poppler.  The others are likely required
> > for the dependencies needed first, before you can instance poppler.
> Indeed.  Building clang-5.0 needs three previous versions!  This is
> bad...
> BTW, looking at
> I see that llvm can be built with gcc > 4.8 – for this I can
> definitely use my already installed gcc8, right?

See above. You can certainly try if you want (just don't complain if
it doesn't since nobody ever tested :) :) :)

Use something like
    port rdeps poppler
to see which port requires a particular dependency.

>  It's funny that the

No, it's not funny.

> native Lion compiler can build gcc8 (since it only needs a C++98
> compiler) but not the older clang-5.0...

It's a chicken-and-egg problem. You need a compiler to compile a
compiler. And you need a C++11-capable compiler to compile C++11 code
of another compiler. Apparently gcc8 fully supports C++11, but doesn't
require a working C++11 compliant compiler to build (bootstrap?)
itself. This is not the case for clang since version 3.5 or so.

On 10.9 and newer you get a C++11 compliant compiler for free. On
older systems you first need to get either a chicken or the egg to
start with ...

Add to that that nowadays you need CMake to compile a recent clang.
And that you need a C++11 compiler to compile CMake. (Maybe we should
sometimes in fact allow using a bit more of gcc for bootstrapping
purposes.) It's just that Apple is not allowed to touch GPL3, so also
one of Apple employees who maintains the clang toolchain for MacPorts
tries to stick with clang. And the species on < 10.9 and slowly going
extinct, so not too many people bother about the increasing troubles
of C++11-related joys on those older systems ...

> So: What is the right option to enforce gcc8 for building clang-5.0?

    sudo port -v install clang-5.0 configure.compiler=macports-gcc-8

Just don't expect extensive support in case stuff breaks (it most
likely will). This might still end up installing a zillion versions of
clang compilers for other dependencies.

> And what about installing clang-7.0 instead of 5.0?  Will `port'
> accept that for C++11 stuff as a default?

Yes. The instructions were probably written when there was no newer
clang compiler available.

It would certainly be nice to clean up the dependencies, but from what
I faintly remember, if you take gcc out of the game, you can only
compile clang-3.4 with the compiler that comes with Xcode, then you
need 3.4 to compiler a newer clang like 3.7. At some point you again
need clang 3.7 to build newer features which clang 3.4 doesn't support
yet etc. I'm sure there is room for improvements, it just needs a lot
of testing.


More information about the macports-users mailing list