Switching cxx_stdlib for C++11 on legacy macOS

Ken Cunningham ken.cunningham.webuse at gmail.com
Mon Sep 4 18:16:47 UTC 2017

On 2017-09-04, at 1:43 AM, Ryan Schmidt wrote:

> I have not followed the development of the cxx11 1.1 portgroup so I don't know the benefits and drawbacks of using it compared to using libc++.

After digging into this for a year and debugging and fixing a _great many_ ports, here are my thoughts for a starting framework. Marcus and Mojca have been deep in at times as well, of course.

stay with cxx11 1.1 PortGroup:


1. Newly built ports are c++ ABI and c++ stdlib compatible with old ports. No changes needed in MacPorts infrastructure, in anyone's MacPorts setup or in their installed ports. Buildbots are already working away.  
2. works with 10.4 and 10.5 PPC as well in most cases
3. helps Jeremy and the clang group find any errors in their new libstdc++ compatibility additions.
4. allows thread-local-storage on 10.4 to 10.8, at least when built with gcc6, maybe when built with clang (not fully tested)


1. as ports fail,  cxx11 1.1 PortGroup needs to be manually added. This comes up frequently, weekly for sure, as software updates come out requiring c11 features.  Adding this PortGroup's functions to base in systems 10.4 to 10.8 is tempting, but have to think about bootstrapping, and also that might break some ports on PPC that currently build OK.

2. We find build errors due to the tighter c++ rules applied by clang-3.9+ vs the older compilers in some ports  (you could say we might as well find these anyway as they are coming to everyone soon enough.)

3. there can be very slight differences in how the gcc libstdc++ headers work compared to the libc++ headers that need to be worked around
 this has happened once so far, but was easy enough to fix <https://trac.macports.org/ticket/54358#comment:26>

4. c++ ports are built in a non-standard (but supported) ABI-4 compatible mode, that may or may not turn up some issues someday. So far, none have turned up. This clang modification was developed to allow clang to build Linux software while the Linux distros stick with libstdc++ as their default standard library, so others are testing this too.

switch to libc++:


1. most builds are identical to 10.9+, most portfiles need no changes.


1. needs changes in macports infrastructure to support new buildbots and pre-built binaries
2. poorly-written software or Portfiles do not spec the stdlib on the compile line. Clang adds wrong default stdlib if we want libc++. Need to be manually fixed, usually be adding the -stdlib to the compiler spec. (see botan).
3. bootstrapping issues - no getting around the LibCxxOnOlderSystems instructions. Might be beyond some users.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-dev/attachments/20170904/eb5c0b56/attachment.html>

More information about the macports-dev mailing list