|
|
Cloudy can be built with either llvm or gcc on a Mac. If you only install
|
|
|
XCODE or the command line tools a very old version of gcc will also be installed.
|
|
|
That version would be used by default in our makefiles and cannot work.
|
|
|
Some care has to be taken to either use only llvm or a recent gcc when building Cloudy.
|
|
|
Instructions for installing gcc using Homebrew are given below.
|
|
|
|
|
|
## Install the Apple Command Line Tools
|
|
|
|
... | ... | @@ -6,25 +11,6 @@ This is available with Xcode (a very large download from the App Store) or by it |
|
|
You do need to register on the Developer website to get the tools for free. Make sure you get the version of the download for your version of OS X or MacOS.
|
|
|
The installation will create an alias called "gcc" which points to the LLVM compiler but it does not install gcc.
|
|
|
|
|
|
Recent versions of the LLVM compiler cannot build Cloudy C13.03 and before. It can build C13.04 and later.
|
|
|
For more on this problem, see the *FPE trapping* section below.
|
|
|
If you want to build C13.03 or before you need to use gcc or obtain an older version of LLVM.
|
|
|
|
|
|
|
|
|
## The situation in early 2017
|
|
|
|
|
|
LLVM is the preferred and best-supported compiler under OS X. As described in the *FPE trapping* section below, more recent versions of LLVM had trouble and versions of Cloudy through 13.03 could not be built.
|
|
|
We recommended using homebrew to install gcc. Versions of Cloudy after 13.03 have been modified to work with LLVM.
|
|
|
|
|
|
~~There currently is an incompatibility when installing both gcc and LLVM, as described in [this bug report](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71767). For now, it is better to use LLVM from Apple and not
|
|
|
install the homebrew gcc. Problems with LLVM can arise if you install homebrew gcc and have it on your path.~~
|
|
|
|
|
|
~~These problems may be fixed someday. For now, we leave the instructions for homebrew here, even though we do not recommend using it.~~
|
|
|
|
|
|
|
|
|
## Mid 2017 update
|
|
|
|
|
|
I installed Homebrew GCC 6.4.0 and built on macOS 10.12.6 / current Xcode without warnings. The LLVM lldb debugger seemed to work with the gcc executable.
|
|
|
|
|
|
-------------
|
|
|
|
... | ... | @@ -41,19 +27,18 @@ 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
|
|
|
==> Formulae
|
|
|
gcc gcc@6 i686-elf-gcc ghc
|
|
|
gcc@10 ✔ gcc@7 libgccjit scc
|
|
|
gcc@4.9 gcc@8 ✔ x86_64-elf-gcc tcc
|
|
|
gcc@5 gcc@9 ✔ grc ncc
|
|
|
==> Casks
|
|
|
```
|
|
|
|
|
|
Select one and install it by
|
|
|
```
|
|
|
brew install homebrew/versions/gcc48
|
|
|
brew install gcc@10
|
|
|
```
|
|
|
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
|
... | ... | @@ -62,26 +47,32 @@ 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
|
|
|
g++ gcc gcc-ar-10 gcc-nm-8 gcc-ranlib-9
|
|
|
g++-10 gcc-10 gcc-ar-8 gcc-nm-9
|
|
|
g++-8 gcc-8 gcc-ar-9 gcc-ranlib-10
|
|
|
g++-9 gcc-9 gcc-nm-10 gcc-ranlib-8
|
|
|
```
|
|
|
|
|
|
Cloudy will use `g++` when it builds, so we will create an alias to g++-4.8 by doing
|
|
|
Cloudy will use `g++` when it builds, so we will create an alias to g++-10 by doing
|
|
|
```
|
|
|
ln -s g++-4.8 g++
|
|
|
ln -s g++-10 g++
|
|
|
```
|
|
|
If, as in the above example, we already have g++ and gcc as an alias, they must be
|
|
|
deleted before ln will work.
|
|
|
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.
|
|
|
g++ (Homebrew GCC 10.3.0) 10.3.0
|
|
|
Copyright (C) 2020 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.
|
|
|
Next you need to make sure that we can find this version of g++ rather than the version
|
|
|
provided with XCODE.
|
|
|
You will need to change your `PATH` so that `/usr/local/bin` comes before `/usr/bin`.
|
|
|
Do this by adding the line
|
|
|
```
|
... | ... | @@ -90,76 +81,6 @@ export PATH=/usr/local/bin:$PATH |
|
|
towards the end of your `.profile` file.
|
|
|
|
|
|
|
|
|
## 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 to run Cloudy correctly even with recent versions of Xcode / clang++.
|
|
|
|
|
|
In earlier versions of Cloudy you can achieve the same effect by commenting out the call to enable_traps() in the file cpu.cpp
|
|
|
```
|
|
|
/* set FP environment to trap FP exceptions */
|
|
|
// enable_traps();
|
|
|
```
|
|
|
before compiling.
|
|
|
|
|
|
|
|
|
### 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](http://hpc.sourceforge.net/) is collection of software for high-performance computing on a Mac. This includes a
|
|
|
downloadable version of gcc.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### 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](http://llvm.org/bugs/show_bug.cgi?id=18673).
|
|
|
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.
|
|
|
|
|
|
We know that on Linux, LLVM/clang++ versions 3.5.0, 3.5.1, and 3.6.0 cannot compile the code correctly (the unit tests fail). According to [wikipedia](https://en.wikipedia.org/wiki/Xcode) this corresponds to Xcode versions 6.0.1 through 6.2 (and possibly even up to 6.4). These Xcode versions should be considered suspicious.
|
|
|
|
|
|
------
|
|
|
|
|
|
Return to [CompileCode](CompileCode)
|
... | ... | |