Building LLVM 3.7.1 on OS X

Hello,

I haven't found any relevant info in the docs about this. I'm trying to
build LLVM 3.7.1 on OS X but it fails in the configuration phase. Here
are the relevant parts of the output:

$ cmake -DCMAKE_INSTALL_PREFIX=/Volumes/HD2/jenkins/workspace/LLVMDev/label/osxbuild/miniconda/envs/_build -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=host -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_UTILS=OFF -DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF ..
-- The C compiler identification is AppleClang 4.1.0.4211166
-- The CXX compiler identification is AppleClang 4.1.0.4211166
[...]
-- Looking for __atomic_fetch_add_4 in atomic
-- Looking for __atomic_fetch_add_4 in atomic - not found
CMake Error at cmake/modules/CheckAtomic.cmake:36 (message):
  Host compiler appears to require libatomic, but cannot find it.
Call Stack (most recent call first):
  cmake/config-ix.cmake:291 (include)
  CMakeLists.txt:360 (include)

How is libatomic supposed to be installed on OS X?
(perhaps it's somewhat of a newbie question - I'm not a OS X user...)

Thank you,

Antoine.

Antoine Pitrou via llvm-dev <llvm-dev@lists.llvm.org> writes:

Hello,

I haven't found any relevant info in the docs about this. I'm trying to
build LLVM 3.7.1 on OS X but it fails in the configuration phase. Here
are the relevant parts of the output:

$ cmake
-DCMAKE_INSTALL_PREFIX=/Volumes/HD2/jenkins/workspace/LLVMDev/label/osxbuild/miniconda/envs/_build
-DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=host
-DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_UTILS=OFF
-DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF ..
-- The C compiler identification is AppleClang 4.1.0.4211166
-- The CXX compiler identification is AppleClang 4.1.0.4211166
[...]
-- Looking for __atomic_fetch_add_4 in atomic
-- Looking for __atomic_fetch_add_4 in atomic - not found
CMake Error at cmake/modules/CheckAtomic.cmake:36 (message):
  Host compiler appears to require libatomic, but cannot find it.
Call Stack (most recent call first):
  cmake/config-ix.cmake:291 (include)
  CMakeLists.txt:360 (include)

How is libatomic supposed to be installed on OS X?
(perhaps it's somewhat of a newbie question - I'm not a OS X user...)

libatomic happens to be the first thing that cmake checks for, so this
is often the error message you get if your compiler isn't useable at all
for some reason.

You might be able to find more details about what's wrong by looking at
CMakeFiles/CMakeError.log in your build directory.

Antoine,
      The llvm 3.7.1 build requires Apple Clang 5.0 or later which can
be gotten from Xcode 5.1 on 10.8. In general, it is best to keep your
OS X upgraded to the latest release supported on the hardware for
building llvm. For example, llvm 3.8 currently requires Xcode 7
(available on OS X 10.10 or 10.11) in order to build the new tsan
support in compiler-rt or using
-DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=ON to use the just built
compiler.
               Jack

Hi Jack,