wiki:CompilingCloudyOSX

Version 11 (modified by mchatzikos, 22 months ago) (diff)

Report that 'save species' command is broken under two versions of LLVM on MacOS X

Compiling Cloudy on OS X

FPE trapping

Versions 5.1 and later of Xcode are broken and cannot compile Cloudy versions up to and including C13.03. Find out which version you have by typing this at a command prompt:

clang++ --version

If it says

Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)

or later, you have the broken version. Previous versions should work fine.

Note that the bug stems from a broken LLVM 3.4 release and is inherited by later releases. So clang++ 3.4 and later on other operating systems will not work either (this includes Linux and likely also FreeBSD). As of C13.04 Cloudy will disable trapping FPEs when using clang++, allowing it run Cloudy correctly even with recent versions of Xcode / clang++.

Some solutions

One solution is to download an older version of the command line tools from the Apple Developer web site. The late October 2013 Xcode command line tools does have a working LLVM. This is the last version that worked.

here is collection of software for high-performance computing on a Mac. This includes a downloadable version of gcc.

Another solution is to install gcc on your Mac using a distribution manager such as Homebrew. Note that there does appear to be a version of gcc on Macs but that is aliased to LLVM since Apple no longer support gcc. But you can install a real gcc yourself.

Download and install Homebrew from http://brew.sh/. Next see which versions of gcc are available by doing

brew search gcc

It will reply with something like

gcc
homebrew/versions/gcc43			 homebrew/versions/gcc48
homebrew/versions/gcc44			 homebrew/versions/gcc49
homebrew/versions/gcc45			 homebrew/versions/llvm-gcc28
homebrew/versions/gcc46			 homebrew/dupes/apple-gcc42
homebrew/versions/gcc47

Select one and install it by

brew install homebrew/versions/gcc48

This will take some time - about an hour on my Mac.

Next go to the /usr/local/bin directory, the location where Homebrew installs software, and do

ls gcc* g++*

which will result in something like

g++-4.8		gcc-4.8		gcc-ar-4.8	gcc-nm-4.8	gcc-ranlib-4.8

Cloudy will use g++ when it builds, so we will create an alias to g++-4.8 by doing

ln -s g++-4.8 g++

We should now have a working version of g++ in this directory. To test it do

./g++ --version

You should get something like

g++ (Homebrew gcc48 4.8.3) 4.8.3
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Next you need to make sure that we can find this version of g++ rather than the broken LLVM version. You will need to change your PATH so that /usr/local/bin comes before /usr/bin. Do this by adding the line

export PATH=/usr/local/bin:$PATH

towards the end of your .profile file.

Subscribing to the bug may, or may not, help

We hope that the LLVM developers will fix the bug in the compiler. The problem is how the compiler handles floating point exceptions when it optimizers code. It is important that science and engineering codes handle floating point exceptions, things like division by zero, correctly. It may, or may not, help if you let them know that the LLVM bug affects you by subscribing to the bug report, posted here. It probably will not help making comments since it will appear that we are lobbying for the bug to be fixed, but subscribing to the report will indicate interest and that it affects you.

'save species' broken

The save species command can cause an abrupt termination of Cloudy execution. This occurs for at least the following platforms:

$ clang++ --version
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix

$ clang++ --version
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.0.0
Thread model: posix

GCC is immune to this problem.


Return to nublado.org