]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Use -flto if possible when optimizations are enabled
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 14 Jul 2016 11:54:41 +0000 (12:54 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 14 Jul 2016 11:54:41 +0000 (12:54 +0100)
CMakeLists.txt

index 22704af4e9ce9f580317714b2e9031a3469e89e4..5d126659deec9548a2c9c53e6f8d08cd11775d0d 100644 (file)
@@ -793,7 +793,13 @@ ENDIF(SUPPORT_FPIC)
  # Optimization flags
 IF(NOT CMAKE_C_OPT_FLAGS)
        IF(ENABLE_OPTIMIZATION MATCHES "ON")
-               SET(CMAKE_C_OPT_FLAGS "-O3 -fstrict-aliasing")
+               CHECK_C_COMPILER_FLAG(-flto SUPPORT_FLTO)
+               IF(SUPPORT_FLTO)
+                       SET(CMAKE_C_OPT_FLAGS "-O3 -fstrict-aliasing -flto")
+                       SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
+               ELSE()
+                       SET(CMAKE_C_OPT_FLAGS "-O3 -fstrict-aliasing")
+               ENDIF()
        ELSE(ENABLE_OPTIMIZATION MATCHES "ON")
                IF(DEBUG_MODE MATCHES "ON")
                        SET(CMAKE_C_OPT_FLAGS "-g -O0 -fstrict-aliasing")