I have a C/C++ program with various dependencies that come from my Linux distribution.
Some of the dependencies are linked with GCC's OpenMP library libgomp.so
.
My program itself has its code compiled with clang's -fopenmp
and linked with LLVM's OpenMP library libomp.so
.
This means that the program's ldd -v
shows both libgomp.so
and libomp.so
as dependencies that will be loaded on startup.
While my program seems to start correctly, I'm concerned about what happens in this case, with 2 OpenMP runtime libraries linked:
libgomp
?Thanks!
(Note that it is currently not possible to tell clang to just use GCC's libgomp
; while there's a flag -fopenmp=libgomp
that, it simply does nothing, disabling OpenMP, see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=227438#c2 and https://reviews.llvm.org/D2841)).
(This question is similar to Can/should libiomp5 and libgomp mix? which is about mixing Intel+GCC OpenMP, but that says nothing about clang+GCC.)
The answer is that having more than one OpenMP runtime in a process is not safe. The details are longer than will fit here, so I have written a blog post on CpuFun. See "Is Mixing OpenMP® Runtimes Safe?"