From bfeac75fa91364f79eedb252e4f6c40162f60564 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 13 Jun 2013 23:19:27 +0200 Subject: [PATCH 1/2] Disable link-time, whole program optimization When using LTO, the linker calls back to the compiler to figure out where a certain symbol is defined. However, in many versions there is apparently a bug that is triggered if a template in inlined in both a used library and in the main program, but with different versions of the compiler. The Boost exception class is particular prone for this. Thus, we disable the -lto from the development builds by default; if anyone wants to test of the behaviour of their own compiler, they must now explicitly turn on this flag. --- cmake/Modules/UseOptimization.cmake | 3 ++- configure | 4 ++-- debian/rules | 2 +- redhat/opm-core.spec | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmake/Modules/UseOptimization.cmake b/cmake/Modules/UseOptimization.cmake index 4cb99f3d..f4e67150 100644 --- a/cmake/Modules/UseOptimization.cmake +++ b/cmake/Modules/UseOptimization.cmake @@ -16,7 +16,8 @@ if (CMAKE_COMPILER_IS_GNUCXX) set (_opt_flags "") # link-time (a.k.a. global) optimizations - option (WHOLE_PROG_OPTIM "Whole program optimization (lto)" ON) + # disabled due to widespread bugs in the linker plugin + option (WHOLE_PROG_OPTIM "Whole program optimization (lto)" OFF) if (WHOLE_PROG_OPTIM) check_cxx_accepts_flag ("-flto" HAVE_LINK_OPTS) if (HAVE_LINK_OPTS) diff --git a/configure b/configure index 37b7f11a..a5a68f40 100755 --- a/configure +++ b/configure @@ -19,7 +19,7 @@ Optional Features: of the options shared and static may be built. --enable-debug build a non-optimized version of the library [default=no] - --disable-lto do not use whole program optimization [default=yes] + --enable-lto use whole program optimization [default=no] --disable-pch do not use precompiled headers (if buggy compiler) --disable-silent-rules print every compilation statement as executed --enable-system-debug put .debug files in global GDB debug dir @@ -104,7 +104,7 @@ use_mpi= silent_rules= #debug_loc=" -DSYSTEM_DEBUG=OFF" debug_loc= -#use_lto=" -DWHOLE_PROG_OPTIM=ON" +#use_lto=" -DWHOLE_PROG_OPTIM=OFF" use_lto= # default is to warn for unknown options, but this can be disabled diff --git a/debian/rules b/debian/rules index 317db881..d6fcf5f4 100755 --- a/debian/rules +++ b/debian/rules @@ -19,7 +19,7 @@ override_dh_auto_build: dh_auto_build --buildsystem=cmake override_dh_auto_configure: - dh_auto_configure --buildsystem=cmake -- -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_DOCDIR=share/doc/libopm-core1 + dh_auto_configure --buildsystem=cmake -- -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_DOCDIR=share/doc/libopm-core1 -DWHOLE_PROG_OPTIM=ON override_dh_auto_install: dh_auto_install -- install-html diff --git a/redhat/opm-core.spec b/redhat/opm-core.spec index 90d8c4ba..4a9622ba 100644 --- a/redhat/opm-core.spec +++ b/redhat/opm-core.spec @@ -59,7 +59,7 @@ This package contains the applications for opm-core %setup -q %build -cmake28 -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_INSTALL_DOCDIR=share/doc/%{name}-%{version} +cmake28 -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_INSTALL_DOCDIR=share/doc/%{name}-%{version} -DWHOLE_PROG_OPTIM=ON make %install From 28406d287db35f7f773a8ba1d35fa1abea61a861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Fri, 14 Jun 2013 00:52:00 +0200 Subject: [PATCH 2/2] Include flag for enabling link-time optimizations When LTO is disabled by default, we need a flag to re-enable it. --- configure | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure b/configure index a5a68f40..87218223 100755 --- a/configure +++ b/configure @@ -299,6 +299,10 @@ for OPT in "$@"; do pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON" shared="" ;; + lto) + use_lto=" -DWHOLE_PROG_OPTIM=ON" + shared="" + ;; # this flag is just for compatibility with the deprecation # flag in DUNE, so we can build without warnings fieldvector-size-is-method)