Trying to build OpenMP on Apple Silicon mac fails with link errors

Hello

Trying to build top of tree LLVM with openmp runtime on Apple Silicon Mac fails with the following link errors.

Undefined symbols for architecture arm64:
  "___divdc3", referenced from:
      ___kmpc_atomic_cmplx8_div in kmp_atomic.cpp.o
      ___kmpc_atomic_cmplx4_div_cmplx8 in kmp_atomic.cpp.o
      ___kmpc_atomic_cmplx8_div_cpt in kmp_atomic.cpp.o
      ___kmpc_atomic_cmplx10_div_cpt in kmp_atomic.cpp.o
  "___divsc3", referenced from:
      ___kmpc_atomic_cmplx4_div in kmp_atomic.cpp.o
      ___kmpc_atomic_cmplx4_div_cpt in kmp_atomic.cpp.o

Build command used

cmake -GNinja  ../llvm-project/llvm/ -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_RUNTIMES="openmp"  -DLLVM_TARGETS_TO_BUILD="X86;AArch64;AMDGPU;NVPTX" -DLLVM_ENABLE_ASSERTIONS=1 -DCLANG_OPENMP_NVPTX_DEFAULT_ARCH=sm_80 -DLIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES=35

It appears some of the builtins being used are not available?

Firstly, I would be surprised if you get OpenMP offload to run on Apple Silicon. You could try to add compiler-rt. It contains the builtins.

Thorsten,
“I would be surprised if you get OpenMP offload to run on Apple Silicon”, so would I, but that isn’t the point at hand, since kmp_atomic.cpp is not an offload file, it’s in the normal, host, runtime.
– Jim

Sorry. The compilation error can probably be solved by adding compiler-rt to the build. The other issue is the attempt to try OpenMP target on Apple Silicon.

This is going to be a waste of time and space.

FWIW, I’m about to get my hands on an M2 processor. Some others and me will check how unreasonable offload on Apple Silicon really is :wink:

1 Like

Hello, building compiler RT was all I needed do. As for why, satisfying my curiosity after seeing some cool talks in the dev meeting :slight_smile:

https://compiler-rt.llvm.org also contains the builtins like your ___divsc3.

I’m not sure why building OpenMP host runtime requires compiler-rt. That’s definitely not expected.

1 Like