From 04debdd3f57518aea2d931ce481753103fc05f54 Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Tue, 13 Oct 2020 14:56:57 +0200 Subject: [FUSE] turn on compiler optimization to fix warning This change enables compiler optimization (-O2) in Release builds to fix the following error warning: _FORTIFY_SOURCE requires compiling with optimization (-O) --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89a44eb..079fd9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,7 @@ endmacro() # Common for gcc and clang #SET(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,relro,-z,now,-z,defs -pie") SET(CMAKE_C_FLAGS_RELEASE "-DNDEBUG") -SET(CMAKE_C_FLAGS "-std=c11 -Wno-multichar -fno-strict-aliasing -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 ${EXTRA_C_FLAGS}") +SET(CMAKE_C_FLAGS "-O2 -std=c11 -Wno-multichar -fno-strict-aliasing -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 ${EXTRA_C_FLAGS}") # Hardening. Try as much as is possible. #TRY_ADD_FLAG("-mmitigate-rop") #TRY_ADD_FLAG("-fstack-protector-strong") @@ -62,10 +62,10 @@ SET(CMAKE_C_FLAGS "-std=c11 -Wno-multichar -fno-strict-aliasing -D_GNU_SOURCE -D #TRY_ADD_FLAG("-Werror=format-security") if(CMAKE_C_COMPILER MATCHES "clang") message( "Using clang flags." ) - SET(CMAKE_C_FLAGS_DEBUG " -O1 -fno-omit-frame-pointer -g -Wall -Wextra -Wpedantic -Wno-unused-result -D_DEBUG") + SET(CMAKE_C_FLAGS_DEBUG " -Og -fno-omit-frame-pointer -g -Wall -Wextra -Wpedantic -Wno-unused-result -D_DEBUG") elseif (CMAKE_C_COMPILER MATCHES "(cc-)|(cc$)") message( "Using (g)cc flags." ) - SET(CMAKE_C_FLAGS_DEBUG " -O0 -g -Wall -Wextra -Wpedantic -Wconversion -Wno-sign-conversion -D_DEBUG") + SET(CMAKE_C_FLAGS_DEBUG " -Og -g -Wall -Wextra -Wpedantic -Wconversion -Wno-sign-conversion -D_DEBUG") else() message( FATAL_ERROR "Could not determine compiler type." ) endif() -- cgit v1.2.3-55-g7522