compilers on Lion

Werner LEMBERG wl at gnu.org
Sat Sep 8 15:46:02 UTC 2018


> 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.

> 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

  https://libcxx.llvm.org/docs/UsingLibcxx.html#using-libc-with-gcc

that gcc on MacOS actually *can* use libc++...

> You should instead use one of the clang compilers as your default.

I'll try.

>> * 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

  http://llvm.org/docs/GettingStarted.html#requirements

I see that llvm can be built with gcc > 4.8 – for this I can
definitely use my already installed gcc8, right?  It's funny that the
native Lion compiler can build gcc8 (since it only needs a C++98
compiler) but not the older clang-5.0...

So: What is the right option to enforce gcc8 for building clang-5.0?
And what about installing clang-7.0 instead of 5.0?  Will `port'
accept that for C++11 stuff as a default?

I can also imagine to follow this route in general (at least on Lion):
First, you build a recent gcc version with the native Apple compiler,
then you use it to build a recent clang version.  This would avoid the
compilation of three intermediate clang versions that probably nobody
needs later on.


    Werner


More information about the macports-users mailing list