[tarantool-patches] [PATCH] Fix libgomp linking for static build

Kirill Yukhin kyukhin at tarantool.org
Fri Sep 7 10:30:16 MSK 2018


Since addition of -fopenmp to compiler also means
addition of -lgomp to the link stage, pass -fno-openmp
to the linking stage in case of static build. In that
case OMP functions are statically linked into libmisc.
---
 cmake/compiler.cmake | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake
index b3a0702..1c15616 100644
--- a/cmake/compiler.cmake
+++ b/cmake/compiler.cmake
@@ -282,9 +282,13 @@ endmacro(enable_tnt_compile_flags)
 
 if (HAVE_OPENMP)
     add_compile_flags("C;CXX" "-fopenmp")
+    if (BUILD_STATIC)
+        # libgomp was already linked into libmisc. Avoid linking
+        # against DSO version of libgomp.
+        set(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} -fno-openmp")
+    endif()
 endif()
 
-
 if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCC)
     set(HAVE_BUILTIN_CTZ 1)
     set(HAVE_BUILTIN_CTZLL 1)
-- 
2.16.2





More information about the Tarantool-patches mailing list