122 lines
3.7 KiB
CMake
122 lines
3.7 KiB
CMake
include (compile_flag)
|
|
include (link_flag)
|
|
include (canonical_host)
|
|
|
|
|
|
###############################################################################
|
|
option(ENABLE_LTO "enable link-time optimisation" OFF)
|
|
|
|
|
|
##-----------------------------------------------------------------------------
|
|
if (ENABLE_LTO)
|
|
append_compile_flag("-flto")
|
|
append_compile_flag("-fno-fat-lto-objects")
|
|
append_link_flag("-fuse-linker-plugin")
|
|
append_compile_flags("-fdevirtualize-at-ltrans")
|
|
endif (ENABLE_LTO)
|
|
|
|
|
|
###############################################################################
|
|
option(ENABLE_FRAMEPOINTER "retain the framepointer even if optimising" OFF)
|
|
|
|
|
|
##-----------------------------------------------------------------------------
|
|
if (ENABLE_FRAMEPOINTER)
|
|
append_compile_flags("-fno-omit-frame-pointer")
|
|
endif (ENABLE_FRAMEPOINTER)
|
|
|
|
|
|
###############################################################################
|
|
canonical_host()
|
|
|
|
|
|
##-----------------------------------------------------------------------------
|
|
if (${HOST_CPU} STREQUAL "x86_64")
|
|
append_compile_flag(-mtune=generic)
|
|
append_compile_flag(-msse)
|
|
append_compile_flag(-msse2)
|
|
append_compile_flag(-msahf)
|
|
elseif (${HOST_CPU} STREQUAL "i686")
|
|
append_compile_flag(-march=prescott)
|
|
append_compile_flag(-mtune=generic)
|
|
append_compile_flag(-mcmov)
|
|
append_compile_flag(-mfpmath=sse)
|
|
else ()
|
|
message (FATAL_ERROR "unknown HOST_CPU '${HOST_CPU}'")
|
|
endif ()
|
|
|
|
|
|
###############################################################################
|
|
if (CMAKE_BUILD_TYPE MATCHES DEBUG)
|
|
else()
|
|
append_compile_flag(-ftree-vectorize)
|
|
|
|
# clang vectorisation
|
|
append_compile_flag(-fvectorize)
|
|
append_compile_flag(-fslp-vectorize)
|
|
append_compile_flag(-fslp-vectorize-aggressive)
|
|
|
|
# loop hosting/distribution
|
|
append_compile_flag(-floop-nest-optimize)
|
|
|
|
append_compile_flag(-ftree-loop-distribution)
|
|
append_compile_flag(-ftree-loop-distribute-patterns)
|
|
append_compile_flag(-ftree-loop-im)
|
|
append_compile_flag(-ftree-loop-if-convert-stores)
|
|
|
|
append_compile_flag(-fivopts)
|
|
|
|
append_compile_flag(-funsafe-loop-optimizations)
|
|
append_compile_flag(-floop-interchange)
|
|
|
|
append_compile_flag(-fpredictive-commoning)
|
|
append_compile_flag(-funswitch-loops)
|
|
|
|
# options that require substantial time/memory
|
|
# GCC: ipa-pta can produce broken code when using LTO
|
|
#AS_IF([test "x$ax_cv_cxx_compiler_vendor" != "xgnu" ||
|
|
# test "x$enable_lto" != "xyes"], [
|
|
# AX_APPEND_COMPILE_FLAGS([-fipa-pta])
|
|
#])
|
|
|
|
# safety removal for performance
|
|
append_compile_flag(-fno-stack-protector)
|
|
endif()
|
|
|
|
|
|
###############################################################################
|
|
if (CMAKE_BUILD_TYPE MATCHES DEBUG)
|
|
else ()
|
|
append_compile_flag(-fdevirtualize)
|
|
append_compile_flag(-fdevirtualize-speculatively)
|
|
|
|
check_link_flag(TEST_GC_SECTIONS, "-Wl,--gc-sections")
|
|
if (TEST_LD_GC_SECTIONS)
|
|
append_compile_flag(-fdata-sections)
|
|
append_compile_flag(-ffunction-sections)
|
|
append_link_flag("-Wl,--gc-sections")
|
|
endif ()
|
|
endif ()
|
|
|
|
|
|
###############################################################################
|
|
if (CMAKE_BUILD_TYPE MATCHES DEBUG)
|
|
add_definitions(-DENABLE_DEBUGGING)
|
|
add_definitions(-D_GLIBCXX_DEBUG)
|
|
|
|
append_compile_flag(-O0)
|
|
append_compile_flag(-Werror)
|
|
# this was protected for xmingw32, find out why
|
|
append_compile_flag(-fstack-protector)
|
|
else ()
|
|
append_compile_flag(-O2)
|
|
append_compile_flag(-fno-rtti)
|
|
add_definitions(-DNO_RTTI)
|
|
add_definitions(-DNDEBUG)
|
|
endif ()
|
|
|
|
|
|
###############################################################################
|
|
append_compile_flag(-g)
|
|
append_compile_flag(-ggdb)
|