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 35A2B2B0B8 for ; Fri, 7 Sep 2018 13:10:58 -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 6bmnn8FoZR_T for ; Fri, 7 Sep 2018 13:10:58 -0400 (EDT) Received: from smtp54.i.mail.ru (smtp54.i.mail.ru [217.69.128.34]) (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 E0ED52B0B6 for ; Fri, 7 Sep 2018 13:10:57 -0400 (EDT) Date: Fri, 7 Sep 2018 20:10:58 +0300 From: Alexander Turenko Subject: [tarantool-patches] Re: [PATCH] Fix libgomp linking for static build Message-ID: <20180907171058.zzfmhrjdrmnijlfd@tkn_work_nb> References: <20180906175907.dom562rutbpalfnl@tarantool.org> <672863676de78877643103e1b57820578eb21fa6.1536312243.git.kyukhin@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <672863676de78877643103e1b57820578eb21fa6.1536312243.git.kyukhin@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: Kirill Yukhin Cc: tarantool-patches@freelists.org Hi! The patch looks good to me. Two comments about formatting are below. Checked static + dynamic build locally (on Gentoo) with gcc and checked dynamic build locally with clang. It works. I think we should file an issue re adding Linux/clang target into CI. WBR, Alexander Turenko. On Fri, Sep 07, 2018 at 12:17:33PM +0300, Kirill Yukhin wrote: > 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") Double indent. > + 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 () -> endif() > endif() > > # Exports syntax is toolchain-dependent, preprocessing is necessary > -- > 2.16.2 >