Allow whole program optimization to be switched off

This commit is contained in:
Roland Kaufmann
2013-04-04 23:25:01 +02:00
parent 2386325e57
commit 0b26514f0f
2 changed files with 16 additions and 5 deletions

View File

@@ -22,10 +22,13 @@ if (CMAKE_COMPILER_IS_GNUCXX)
set (_opt_flags "")
# link-time (a.k.a. global) optimizations
check_cxx_accepts_flag ("-flto" HAVE_LINK_OPTS)
if (HAVE_LINK_OPTS)
list (APPEND _opt_flags "-flto")
endif (HAVE_LINK_OPTS)
option (WHOLE_PROG_OPTIM "Whole program optimization (lto)" ON)
if (WHOLE_PROG_OPTIM)
check_cxx_accepts_flag ("-flto" HAVE_LINK_OPTS)
if (HAVE_LINK_OPTS)
list (APPEND _opt_flags "-flto")
endif (HAVE_LINK_OPTS)
endif (WHOLE_PROG_OPTIM)
# native instruction set tuning
option (WITH_NATIVE "Use native instruction set" ON)

10
configure vendored
View File

@@ -18,6 +18,7 @@ Optional Features:
--enable-static build a static library [default=no]. Note: only one
of the options shared and static may be built.
--disable-debug build a release version of the library [default=no]
--disable-lto do not use whole program optimization [default=yes]
--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
@@ -101,6 +102,8 @@ use_mpi=
silent_rules=
#debug_loc=" -DSYSTEM_DEBUG=OFF"
debug_loc=
#use_lto=" -DWHOLE_PROG_OPTIM=ON"
use_lto=
# default is to warn for unknown options, but this can be disabled
option_check=yes
@@ -232,6 +235,11 @@ for OPT in "$@"; do
debug_loc=" -DSYSTEM_DEBUG=OFF"
pkgname=""
;;
wpo |\
lto )
use_lto=" -DWHOLE_PROG_OPTIM=OFF"
pkgname=""
;;
openmp)
use_openmp=" -DUSE_OPENMP=OFF"
pkgname=""
@@ -333,7 +341,7 @@ for a in "${VARS[@]}"; do
done
# pass everything on to CMake
CMDLINE="env ${ENVVARS} ${CMAKE_COMMAND} \"${srcdir}\" \"-DCMAKE_INSTALL_PREFIX=$prefix\" -DCMAKE_BUILD_TYPE=${buildtype}${pch_use}${silent_rules}${debug_loc}${use_openmp}${use_mpi} ${FEATURES}"
CMDLINE="env ${ENVVARS} ${CMAKE_COMMAND} \"${srcdir}\" \"-DCMAKE_INSTALL_PREFIX=$prefix\" -DCMAKE_BUILD_TYPE=${buildtype}${pch_use}${silent_rules}${debug_loc}${use_openmp}${use_mpi}${use_lto} ${FEATURES}"
echo --- calling CMake ---
echo ${CMDLINE}
eval exec ${CMDLINE}