From 579212996f3c12343dc3017b5b68c5e34f8bb2ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Lepage=20Vall=C3=A9e?= Date: Tue, 12 Dec 2017 01:26:22 -0500 Subject: [PATCH] build: Do not set -g, -O3 and -Werror CFLAGS Hello, here are a few changes to the default CFLAGS ## Why Werror With each new compiler version, your code "break" and fail to compile. It is true that it's a sometime a "bug" in the code and need visibility to get fixed. However, Werror should *always* be a local CFLAGS and not a project one, see Google for endless people arguing back and forth and removing Werror is now the prevalent winner of that argument. In the latest GCC, it fails to compile because the fwrite result in unchecked. Even if you fix this in new releases, you cannot fix the past and all existing releases used in stable products suddenly fail to compile, wasting everybody time. ## Why -g This should be decided by the one who compiles the code. Some people want small and pre-stripped binaries and appending this to the CFLAGS breaks the standard way of achieving this. Prepend it if you wish, but please do not append it. ## Why -O3 On many systems with limited cache or higher memory latency, `O3` is slower than `O2`, so IMHO it should not be hardcoded. In my case I used `Os` and it's faster. The `O` value should be left to the system, not hardcoded. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f92363e7..c8638757 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,9 +237,9 @@ ENDIF () IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") IF (MSGPACK_ENABLE_SHARED) - SET_PROPERTY (TARGET msgpackc APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3 -DPIC") + SET_PROPERTY (TARGET msgpackc APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -DPIC") ENDIF () - SET_PROPERTY (TARGET msgpackc-static APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3" ) + SET_PROPERTY (TARGET msgpackc-static APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra" ) ENDIF () IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")