From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 275CA2AE25 for ; Fri, 7 Sep 2018 05:26:00 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gTjDGUk5s28y for ; Fri, 7 Sep 2018 05:26:00 -0400 (EDT) Received: from smtp48.i.mail.ru (smtp48.i.mail.ru [94.100.177.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id DE4E42AE15 for ; Fri, 7 Sep 2018 05:25:59 -0400 (EDT) From: Kirill Yukhin Subject: [tarantool-patches] [PATCH] Fix libgomp linking for static build Date: Fri, 7 Sep 2018 12:17:33 +0300 Message-Id: <672863676de78877643103e1b57820578eb21fa6.1536312243.git.kyukhin@tarantool.org> In-Reply-To: <20180906175907.dom562rutbpalfnl@tarantool.org> References: <20180906175907.dom562rutbpalfnl@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: alexander.turenko@tarantool.org Cc: tarantool-patches@freelists.org, Kirill Yukhin 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. Also, emit error if trying to perform static build using clang. --- Branch: https://github.com/tarantool/tarantool/commits/kyukhin/gh-xxxx-fix-gomp-in-static-build Issue: n/a cmake/compiler.cmake | 5 ++++- src/CMakeLists.txt | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index b3a0702..5b323c7 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -33,6 +33,10 @@ if (CMAKE_COMPILER_IS_GNUCC) Your GCC version is ${CMAKE_CXX_COMPILER_VERSION}, please update ") endif() +else() + if (BUILD_STATIC) + message(FATAL_ERROR "Static build is supported for GCC only") + endif() endif() # @@ -284,7 +288,6 @@ if (HAVE_OPENMP) add_compile_flags("C;CXX" "-fopenmp") endif() - if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCC) set(HAVE_BUILTIN_CTZ 1) set(HAVE_BUILTIN_CTZLL 1) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ebda098..aa39d8b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -277,6 +277,13 @@ if(BUILD_STATIC) endif() endforeach(libstatic) string(REPLACE ";" " " EXPORT_LIST "${EXPORT_LIST}") + + if (HAVE_OPENMP) + # Link libgomp explicitly to make it static. Avoid linking + # against DSO version of libgomp, which implied by -fopenmp + set (common_libraries ${common_libraries} "libgomp.a") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-openmp") + endif () endif() # Exports syntax is toolchain-dependent, preprocessing is necessary -- 2.16.2