[x265] [PATCH 2 of 2] cmake: use flags which ignore -fprofile-use warnings

Steve Borho steve at borho.org
Tue Mar 31 09:05:32 CEST 2015


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1427785283 18000
#      Tue Mar 31 02:01:23 2015 -0500
# Branch stable
# Node ID a4c09974eeee5866fb9340908c7f5541e45b4626
# Parent  7635fec148da3d9e275756fdf987cf954867ad4b
cmake: use flags which ignore -fprofile-use warnings

Without these flags, PGO builds generally fail with recent GCC (on Linux and
MinGW)

diff -r 7635fec148da -r a4c09974eeee source/CMakeLists.txt
--- a/source/CMakeLists.txt	Tue Mar 31 00:55:15 2015 -0500
+++ b/source/CMakeLists.txt	Tue Mar 31 02:01:23 2015 -0500
@@ -155,12 +155,28 @@
         add_definitions(-march=armv6 -mfloat-abi=hard -mfpu=vfp)
     endif()
     if(FPROFILE_GENERATE)
-        add_definitions(-fprofile-generate)
-        list(APPEND LINKER_OPTIONS "-fprofile-generate")
+        check_cxx_compiler_flag(-fprofile-generate CC_HAS_PROFILE_GENERATE)
+        if(CC_HAS_PROFILE_GENERATE)
+            add_definitions(-fprofile-generate)
+            list(APPEND LINKER_OPTIONS "-fprofile-generate")
+        endif(CC_HAS_PROFILE_GENERATE)
     endif(FPROFILE_GENERATE)
     if(FPROFILE_USE)
-        add_definitions(-fprofile-use)
-        list(APPEND LINKER_OPTIONS "-fprofile-use")
+        check_cxx_compiler_flag(-fprofile-use CC_HAS_PROFILE_USE)
+        check_cxx_compiler_flag(-fprofile-correction CC_HAS_PROFILE_CORRECTION)
+        check_cxx_compiler_flag(-Wno-error=coverage-mismatch CC_HAS_COVMISMATCH)
+        if(CC_HAS_PROFILE_USE)
+            add_definitions(-fprofile-use)
+            list(APPEND LINKER_OPTIONS "-fprofile-use")
+        endif(CC_HAS_PROFILE_USE)
+        if(CC_HAS_PROFILE_CORRECTION)
+            # auto-correct corrupted counters (happens a lot with x265)
+            add_definitions(-fprofile-correction)
+        endif(CC_HAS_PROFILE_CORRECTION)
+        if(CC_HAS_COVMISMATCH)
+            # ignore coverage mismatches (also happens a lot)
+            add_definitions(-Wno-error=coverage-mismatch)
+        endif(CC_HAS_COVMISMATCH)
     endif(FPROFILE_USE)
     if(STATIC_LINK_CRT)
         add_definitions(-static)


More information about the x265-devel mailing list