There are two issues:

1. cxx11 features required. These crop up in more and more software as these 
features are increasingly used. Newer systems breeze right past them as their 
default compiler is new enough to handle this. Older systems (10.8 or less) 
hang up on them as their default compiler is too old. Port files are 
individually upgraded to the cxx11 portgroup to solve this, as this is 
recognized (newer systems wouldn't even know about it -- only older systems get 
errors).

Although you could say the Portfiles should all be updated as this is 
recognized, it is in the end MUCH easier to install a modern compiler on your 
system (say clang-3.8 or clang-3.9) and set that as the default compiler in 
macports.conf. Then you will use that as your default compiler and never see 
these errors either.


2. properly setting the standard c++ library. On newer systems, the compiler 
will add -stdlib=libc++ automatically to the build line on systems 10.9 or 
greater -- it's written into the clang code. Some software makefiles don't 
properly import the CXX flags, but these all work fine on newer systems because 
it gets added by default in the background for you. Newer systems will stumble 
on these ports as by default clang will add -stdlib=libstdc++ and that doesn't 
work with cxx11; you get link errors.


To fix this, when such software with improperly written makefiles is found, you 
can force the proper cxxflags as you have done. 

After coming across this issue one too many times for my own liking, and 
changing several dozen ports as you have done, I finally just patched clang to 
make it default to add -stdlib=lilbc++ by default on all systems, which solves 
this issue once and forever. 

If you're set up to use libc++, this is very desirable behaviour, and matches 
what the newer systems are doing.

Otherwise you can update each port as you find this particular error.

If you're interested in my clang patches (for clang 3.7, 3.8, and 3.9), they 
are here. In  the end, it's just a one character patch, changing the system 
test:
<https://github.com/kencu/SnowLeopardPorts/blob/master/lang/llvm-3.8/files/999-patch-clang-3.8-Toolchains-default-always-libcxx.diff>



3. There is another way to link against a different stdlib (gcc's version) that 
became possible in clang-3.9. The cxx11 1.1 portgroup forces this for 
clang-3.9. The only reason we entertained this particular rabbit hole was 
because of a buildbot naming issue that just never got resolved. I don't use 
this method myself, but some do.

Happy to answer any questions you have about this.


Best, 

Ken








On 2017-04-18, at 7:43 AM, db wrote:

> On 18 Apr 2017, at 09:50, db <iams...@gmail.com> wrote:
>> I filed #53994, #53995, #53996 for highlight, nmap and ostinato 
>> respectively, failing to build with libc++. I'd appreciate if anyone could 
>> peek at the logs and recognize a pattern or tell these are unrelated.
> 
> highlight (#53994) and nmap (#53995) build with
> 
> sudo port install [port] configure.cxxflags="-stdlib=libc++" 
> configure.cxx="clang++ -stdlib=libc++"
> 
> How do you emend a port file to take libc++ into account when this is the 
> default?

Reply via email to